$UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange...

44

Transcript of $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange...

Page 1: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"
Page 2: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Black Belt Exchange and Office 365 PowerShellSteve GoodmanSenior Consultant, Ciber

OFC-B220

Page 3: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

WelcomeSteve GoodmanExchange Server MVPSenior Consultant as Ciber in the UKWriter for MSExchange.org and SearchExchange.comHost of the UC Architects Podcast

Page 4: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Basics AutomationMonitoringTroubleshootingUseful scripts

Welcome

Page 5: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Basics AutomationMonitoringTroubleshootingUseful scripts

Agenda

Page 6: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Starting with the basics

Page 7: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Similar in concept to Unix-like management shellsSimpler in operation as PowerShell is object-orientedCommands and parameters are easy to discover through the use of verbs and autocompletion

For example Get-Mailbox, Set-Mailbox, New-Mailbox –Firstname –Lastname

Pass the output of one command to the next with the pipeline, or store in variables

Get-User | Set-User –Company Contoso$TemplateUser = Get-User “Template User”Get-User | Set-User –Company $TemplateUser.Company

Key concepts of PowerShell in one slide

Page 8: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

PowerShell allows you to pretty much manage anythingWe’ll focus on a few core Exchange and Office 365 technologies in this sessionExchange On-PremisesExchange OnlineWindows Azure Active Directory

What will we focus on managing?

Page 9: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

What will we focus on managing?

Page 10: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Connecting to Exchange On-Premises$UserCredential = Get-Credential$Session = New-PSSession

-ConfigurationName Microsoft.Exchange -ConnectionUri "http://<FQDN>/PowerShell/" -Authentication Kerberos -Credential $UserCredential

Import-PSSession $Session

Get-Mailbox "Steve Goodman"

Page 11: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Connecting to Exchange Online$UserCredential = Get-Credential$Session = New-PSSession

-ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-

liveid/" -Credential $UserCredential -Authentication Basic -AllowRedirection

Import-PSSession $Session

Get-Mailbox "Lisa Goodman"

Page 12: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Using Both$UserCredential = Get-Credential$CloudSession = New-PSSession

-ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $UserCredential -Authentication Basic -AllowRedirection

Import-PSSession $CloudSession -Prefix Cloud $OnPremSession = New-PSSession

-ConfigurationName Microsoft.Exchange -ConnectionUri "http://<FQDN>/PowerShell/"-Authentication Kerberos -Credential $UserCredential

Import-PSSession $OnPremSession

Get-CloudMailbox "Lisa Goodman"Get-Mailbox "Steve Goodman"

Page 13: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Connecting to Azure Active Directory$UserCredential = Get-CredentialConnect-MsolService -Credential $UserCredential

Get-MsolUser -UserPrincipalName [email protected]

Page 14: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Managing WAAD Sync OperationsImport-Module DirSync

Start-OnlineCoexistenceSync

Page 15: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

The ability to automate on-premises and cloud Exchange operations including…Creating new on-premises Active Directory accounts with Exchange or Office 365 mailboxes attachedForcing creation in Office 365Assigning licensing to new Mailboxes in the CloudAssigning policies in Exchange Online

What does all that give us?

Page 16: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Exchange On-Premises

New-RemoteMailboxSet-RemoteMailboxAdd-DistributionGroupMember

DirSync Start-OnlineCoexistenceSync

Azure Active Directory

Set-MSOLUserSet-MSOLUserLicence

Exchange Online Set-CASMailboxSet-MailboxRegionalConfiguration

For example:

Page 17: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Demo

Page 18: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Automation

Page 19: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Mailbox CreationsMailbox DeletionsUpdate of email addressesRemoval of old addresses like X400 addressesAddition and removal from distribution groupsAssigning policies to users, like In-Place Hold, Retention Policies, Mobile Device Policies

What can you automate?

Page 20: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Enable or disable OWA for usersEnabling users for Unified MessagingChanging department or job title detailsUpdating contact phone numbersSetting account expiry dateRe-balancing mailboxes across databasesCreating shared calendars with standard settings

A few more

Page 21: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Collection of information about the organizationRemediation of settings, such as UPN updatesSetup and configuration of Office 365 tenantsLicensing automation Mailbox Migration to Exchange 2013Creating Migration Batches for Office 365 migrationsThe list goes on..

Even more… and the list doesn’t end here

Page 22: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Figure out what value you will get from automating using some sort of criteria, for example:Will you do it more than once?

This includes doing something once to everyone!

Will it save you time to automate it?Sometimes a simple procedure is fine!

But what should you automate?

Page 23: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Can you avoid errors by automating it?Or will it mean errors affect everyone else?

Will you be able to delegate it?Replacing someone else doing it with the EAC with you doing it via PowerShell isn't great

Can you plug it into something else?Does your service desk have the ability to interface with PowerShell?

But what should you automate?

Page 24: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

If you know PowerShell, perform the task once using PowerShell

Start-Transcript

If you don't know PowerShell wellIf it's on-premises Exchange, use the EAC or EMC

If it's not are their examples in the TechNet Gallery already?

Licensing is a good exampleRebalancing

More examples of my scripts

Learning from others is a GREAT WAY

Get the template for doing it once

Page 25: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Get the template for doing it one timeBasic Script

InputVariablesLoopError Checking

For example:Automate one time task

Disable ActiveSync for Group MembersAutomate regular task

Setup Shared MailboxAssign Default Set of Permissions

Create the template for doing it once

Page 26: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

The template allows you to make it repeatable

Make a Basic ScriptDo you need input?Do you have variables to setWill you want to loop through a list (for example, mailboxes)Should you check for errors?

A couple of demos….Automate a one time task

Disable ActiveSync for Group MembersAutomate a regular task

Setup Shared MailboxAssign Default Set of Permissions

Use the template for doing it once

Page 27: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Demo

Page 28: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Monitoring and Troubleshooting

Page 29: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

For pro-active monitoring, use an off-the-shelf solutionBut, there are times you want to gain an insight into your Exchange infrastructure

Getting a regular overview of the environmentCollecting data to monitor changes or growthExporting logs for historical value or to import into a third-party system,Building a bespoke interface into your existing monitoring systemAnd of course – collecting data for Troubleshooting

Let’s have a look at a few examples…

What should you monitor?

Page 30: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

You can export data from Exchange or Office 365 and store it, then compare historical data at a later dateFor example – keeping an record of mailbox growthUse the Export-CliXML cmdlet to export the results of a PowerShell cmdlet as a point in time snapshotThen use the Import-CliXML cmdlet to import the snapshot at a later date for comparison

Monitoring your environment for growth

Page 31: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Demo

Page 32: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

An example - troubleshooting Availability:Switch on increased logging across all CAS serversRetrieve and collate logs, filtered for relevant errors from the Event LogsSearch for particular errors in IIS Logs

Automating Troubleshooting

Page 33: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Demo

Page 34: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

What is the Exchange Environment ReportUseful for:

Overview of patch levelsMailbox distribution across the environmentLast backups etc

Demo of usage and results

Generating Environment Reports

Page 35: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Exchange Environment Report

Page 36: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

For example a report on your Office 365 tenantWe will use the following PowerShell featuresHashtables to store dataFunctions to collect individual pieces of data or output contentOutput the results as HTML

Creating your own environment report

Page 37: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Demo

Page 38: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Summary

Page 39: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Use PowerShell to automate managementLaborious tasks, Error prone tasksAutomation with PowerShell should equal less human mistakes (but test!)

Monitor and report using PowerShellYou don't need to reinvent the wheel, good scripts are out there to assistDon't create a new monitoring system, and use Managed Availability cmdlets

Use PowerShell to switch on troubleshooting and retrieve data centrally

An Exchange admin's PowerShell knowledge extends outside of the Exchange Management Shell and also includes areas like Event Logs, Disks, Parsing Text Log Files

Summary

Page 40: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Resources

Learning

Microsoft Certification & Training Resources

www.microsoft.com/learning

Developer Network

http://developer.microsoft.com

TechNet

Resources for IT Professionals

http://microsoft.com/technet

Sessions on Demand

http://channel9.msdn.com/Events/TechEd

Page 41: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Technical Network

Join the conversation!Share tips and best

practices with other Office 365 expertshttp://aka.ms/o365technetwork

Page 42: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

Managing Office 365 Identities and Services

5

Office 365

Deploying Office 365 Services

Classroomtraining

Exams

+

Introduction to Office 365

Managing Office 365 Identities and Requirements

FLC

40041

Onlinetraining

Managing Office 365 Identities and ServicesOffice 365 Fundamentals

http://bit.ly/O365-Cert

http://bit.ly/O365-MVA

http://bit.ly/O365-Training

Get certified for 1/2 the price at TechEd Europe 2014!http://bit.ly/TechEd-CertDeal

MOC

20346 Designing for Office

365 Infrastructure

MOC

10968

3

EXAM

346EXAM

347

MVA MVA

Page 43: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

TechEd Mobile app for session evaluations is currently offline

SUBMIT YOUR TECHED EVALUATIONSFill out an evaluation via

CommNet Station/PC: Schedule Builder

LogIn: europe.msteched.com/catalog

We value your feedback!

Page 44: $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:// /PowerShell/"

© 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.