common powershell uses in office 365

3
Common Exchange 2013 Hybrid \ Office 365 PowerShell Uses The following PowerShell commands have been used in an Exchange 2013 Hybrid – Exchange Online environment, where the authoritative identity remains on premise with Active Directory. This should be used as a starter while different business scenarios may require different attribute filtering or different options chosen to be configured. Below some commands are run from on premise Exchange PowerShell and others are run from a PowerShell connected to MSOL Service. Let’s get connected Exchange Online Import-Module MSOnline $O365Cred = Get-Credential $O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365Cred -Authentication Basic -AllowRedirection Import-PSSession $O365Session Let’s get connected Office 365 Connect-MsolService –Credential $O365Cred Let’s get the Office 365 licenses for an individual user (PowerShell Connected to MSOL Service) (Get-MSOLUser –UserPrincipalName [email protected] ).Licenses[0].ServiceStatus Let’s get the Office 365 licenses for our organization (PowerShell Connected to MSOL Service) get-msoluser -all | ForEach-Object { "============="; $_.DisplayName; $_.Country; $_.licenses[0].servicestatus}

Upload: nathan-swift

Post on 19-Jan-2016

35 views

Category:

Documents


0 download

DESCRIPTION

The following PowerShell commands have been used in an Exchange 2013 Hybrid – Exchange Online environment, where the authoritative identity remains on premise with Active Directory. This should be used as a starter while different business scenarios may require different attribute filtering or different options chosen to be configured. Below some commands are run from on premise Exchange PowerShell and others are run from a PowerShell connected to MSOL Service.

TRANSCRIPT

Page 1: Common PowerShell Uses in Office 365

Common Exchange 2013 Hybrid \ Office 365 PowerShell Uses

The following PowerShell commands have been used in an Exchange 2013 Hybrid – Exchange Online environment, where the authoritative identity remains on premise with Active Directory. This should be used as a starter while different business scenarios may require different attribute filtering or different options chosen to be configured. Below some commands are run from on premise Exchange PowerShell and others are run from a PowerShell connected to MSOL Service.

Let’s get connected Exchange Online

Import-Module MSOnline$O365Cred = Get-Credential$O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365Cred -Authentication Basic -AllowRedirectionImport-PSSession $O365Session

Let’s get connected Office 365

Connect-MsolService –Credential $O365Cred

Let’s get the Office 365 licenses for an individual user (PowerShell Connected to MSOL Service)

(Get-MSOLUser –UserPrincipalName [email protected] ).Licenses[0].ServiceStatus

Let’s get the Office 365 licenses for our organization (PowerShell Connected to MSOL Service)

get-msoluser -all | ForEach-Object { "============="; $_.DisplayName; $_.Country; $_.licenses[0].servicestatus}

Let’s bulk enable remote mailboxes and set with archive (On Premise Exchange PowerShell)

Get-user –organizationalUnit “domain.com/Asia Pacific/Vietnam/Users”| where-object {$_.RecipientType –eq “User”} | foreach {Enable-RemoteMailbox -identity $_.userprincipalname -primarysmtpaddress ($_.firstname+'.'+$_.lastname+’@primarysmtpaddress.com’) -RemoteRoutingAddress ($_.samaccountname+’@domain.mail.onmicrosoft.com’)} | set-remotemailbox -emailaddresspolicyenabled:$true Get-user –organizationalUnit “domain.com/Asia Pacific/Vietnam/Users”| where-object{$_.RecipientType –eq “User”} | foreach {Set-RemoteMailbox -identity $_.userprincipalname -archive}

Page 2: Common PowerShell Uses in Office 365

Using a filter to prevent some accounts from receiving a remote mailbox while setting in bulk (On Premise Exchange PowerShell) Retrieve List of No MBX users Get-user –organizationalUnit “domain.com/Europe/Austria/Users”| where-object {$_.RecipientType –eq “User”} | where { $_.notes -like "*No MBX*" }

Enable Remote Mailbox and Archive Get-user –organizationalUnit “domain.com/Europe/Austria/Users”| where-object {$_.RecipientType –eq “User”} | where { $_.notes -notlike "*No MBX*" } | foreach {Enable-RemoteMailbox -identity $_.userprincipalname -primarysmtpaddress ($_.firstname+'.'+$_.lastname+’@primarysmtpaddress.com’) -RemoteRoutingAddress ($_.samaccountname+’@domain.mail.onmicrosoft.com’)} | set-remotemailbox -emailaddresspolicyenabled:$true Get-user –organizationalUnit “domain.com/Asia Pacific/Vietnam/Users”| where-object{$_.RecipientType –eq “User”} | where { $_.notes -notlike "*No MBX*" } | foreach {Set-RemoteMailbox -identity $_.userprincipalname -archive}

Let’s set usage location, assign licenses, and set mailbox language to Office 365 users in bulk (PowerShell Connected to MSOL Service) Get-msoluser -maxresults 40000 | where-object{$_.Country –eq “Vietnam”} | foreach {Set-MsolUser -UserPrincipalName $_.UserPrincipalName -UsageLocation "VN"} Get-msoluser -maxresults 40000 | where-object{$_.Country –eq “Vietnam”} | foreach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses 'domain:ENTERPRISEPACK'}

Get-msoluser -maxresults 40000 | where-object{$_.Country –eq “Germany”} | foreach {set-MailboxRegionalConfiguration -Identity $_.UserPrincipalName -Language de-de -DateFormat "dd.MM.yyyy" -TimeFormat HH:mm -LocalizeDefaultFolderName:$True}

Let’s get the Encryption Configuration (PowerShell Connected to Exchange Online Service)

Get-OMEConfiguration