Mastering PowerShell For Exchange Online - WordPress

Transcription

Mastering PowerShell forExchange OnlineMike CrowleyBaseline Technologies#ITDEVCON

MASTERING POWERSHELL FOR EXCHANGE ONLINESession Agenda Introduction Environment Setup Connecting to Exchange Online &Azure Active Directory PowerShell Techniques Exchange Online Reporting#ITDEVCON

MASTERING POWERSHELL FOR EXCHANGE ONLINEIntroduction Background–––PowerShell 1.0 used by Exchange 2007Built on .NET FrameworkAll of Microsoft’s enterprise products support it – Many GUIs literally use PS behind the scenes.Broad 3rd party support and use (AWS, VMware,KEMP, etc.)Great for––––––––Recipient Management & Bulk AutomationEnsuring consistent configurationsReportingHidden ConfigurationsDocumentationCustom ToolingDeeper understanding of the serviceGetting the status of your Dominos pizza order*#ITDEVCON*http://poshcode.org/1355

MASTERING POWERSHELL FOR EXCHANGE ONLINEIntroduction CMDlets– Performs an action andreturn an object(s)– Verb-Noun– Named and PositionalParameters#ITDEVCON The Pipeline– I prefer: “conveyer belt”– Objects placed to theleft come out the right

MASTERING POWERSHELL FOR EXCHANGE ONLINEIntroduction Exploring–––Tab to auto-completeGet-Help -OnlineGet-whatever select *–ISE Commands Add-On–Strings–Arrays Common Objects– “Just a line of text” @(“a group of”“multiple objects”)Hash Tables To explore possible fields@{Maryland “Annapolis”Nevada “Carson City”Alaska “Juneau”}Common Functions–Where-Object–ForEach-Object #ITDEVCON-EQ –NE –GE –GT –LE –LT -LIKE

MASTERING POWERSHELL FOR EXCHANGE ONLINEEnvironment Setup Download the latest version–4.0–5.0 (Production preview) px?id ap.aspxDownload modules as necessary–––Azure AD: http://msdn.microsoft.com/jj151815Remote Server Administration Tools: Search for (RSAT YourOS)No module necessary for Exchange Online–“Class III Authenticode Code-Signing Certificate”Execution Policy AD CSInternet CASelf-signed (limited use Don’t forget to reinstate once done–Set-ExecutionPolicy -ExecutionPolicy Unrestricted–Powershell.exe -executionpolicy bypass –file myfile.ps1–Automatically load frequently-used functions, modules, settings etc.Profiles#ITDEVCON

MASTERING POWERSHELL FOR EXCHANGE ONLINEEnvironment Setup PowerShell IntegratedScripting Environment (ISE)– You really need to use this!– Kinda stunk before 3.0– Might not be installed bydefault on your workstation– Helps keep track ofcommands you’ve run– Facilitates script debugging– Preserves formatting forprofessional looking andeasy to readdocumentation#ITDEVCON

MASTERING POWERSHELL FOR EXCHANGE ONLINEConnecting to ExO & AAD Exchange Online / EOP– Remote PowerShell (2.0 and later) Azure Active Directory– Requires MSOnline module#ITDEVCON

MASTERING POWERSHELL FOR EXCHANGE ONLINEConnecting to ExO & AAD A few tweaks:– Credential Handling– Splatting– Session Prefixes ExO & AAD Multi-factor Authentication– “Coming soon”#ITDEVCON

MASTERING POWERSHELL FOR EXCHANGE ONLINEPowerShell Techniques Comments & Comment-Based Help Variables– Leverage environmental variables– Be careful with object type mismatches– Variable scopes technet.microsoft.com/hh847849 Functions– Function Get-Beer {Signal-Bartender; Place-Order -Id Killians } Dates and Date Spans XML– Surprisingly easy to work with in later PS versions– Be aware of CLIXML’s depth#ITDEVCON

MASTERING POWERSHELL FOR EXCHANGE ONLINEPowerShell Techniques Formatting– Out-Default– Format-List (meh)– Format-Table -Auto-wrap– Select-Object#ITDEVCON Out-Gridview

MASTERING POWERSHELL FOR EXCHANGE ONLINEExO Reporting EAC Reports WebDashboard– Also available as Excelworkbook x?id 30716#ITDEVCON

MASTERING POWERSHELL FOR EXCHANGE ONLINEExO Reporting Reporting CMDlets– technet.microsoft.com/dn641232 Web Service API– aspx#ITDEVCON

MASTERING POWERSHELL FOR EXCHANGE ONLINE Getting Started Stuff–A Windows PowerShell Tutorial –Windows: 46Exchange Online: 80Azure AD 54330Windows PowerShell Best Practices and Patterns (Webcast) let Reference –Additional orthAmerica/2014/DCIM-B418Repositories–TechNet Gallery owerShell Gallery –http://poshcode.orgPower Tips (& Tip of the day) Blogs–Windows PowerShell Blog dn.com/b/powershell–Hey, Scripting Guy! Blog http://blogs.technet.com/b/heyscriptingguy–Mike Crowley’s Whiteboard (Demo Scripts Here) e –https://www.powershellgallery.comScripts for Your Exchange Server Toolkit –https://github.com/powershell

Rate This Session Now!Tell UsWhatYouThoughtof ThisSession#ITDEVCONRate with Mobile App: Select the session from theAgenda or Speakers menus Select the Actions tab Click Rate SessionBe Entered toWINPrizes!Rate with Website:Register at www.devconnections.com/logintoratesessionGo to www.devconnections.com/ratesessionSelect this session from the list and rate it

TOPIC DIVIDER

MASTERING POWERSHELL FOR EXCHANGE ONLINE Introduction Background – PowerShell 1.0 used by Exchange 2007 – Built on .NET Framework – All of Microsoft’s enterprise products support it Many GUIs literally use PS behind the scenes. – Broad 3rd pa