Category Archives: O365

Office 365 Posts

Post Migration Scripts for O365 – Part 2 Set Retention Policy and Retain Deleted items from a csv file

When migrating users to O365, you may need to set a group of users or specific users Item Retention and Deleted Item retention policies. If you have a list of users who need specific settings you can run the following command against the list to only apply the desired settings to those users. You will need to connect to O365 to run these scripts for O365 Users.

### This script will list all users in a csv file who have a Deleted Items retention setting if 14 Days and change it to 30 Days.

Import-CSV "C:\UKUsers.csv" | %{Get-Mailbox -identity $_.UserPrincipleName | where {$_.retaindeleteditemsfor -eq "14.00:00:00"} | Set-Mailbox -RetainDeletedItemsFor "30.00:00:00"}
 

### This script will search for users in a csv file who have a particular Retention Policy assigned and set it to another policy.

Import-CSV "C:\UKUsers.csv" | %{Get-Mailbox -identity $_.UserPrincipleName | where{$_.RetentionPolicy -eq "Incorrect Policy Name"} | Set-Mailbox -RetentionPolicy "Correct Policy Name"}
Facebooktwittergoogle_pluslinkedinby feather

Post Migration Scripts for O365 – Part 1 Set usage location and Enable License from a csv file

When you are migrating users to O365 there may be a requirement to run post migration scripts, for setting the users location, and enabling licenses. You may be performing the migrations using a csv, and users may be in different locations, so you cannot just run the commands against the entire organisation. The csv contains a list of User UPNs.

### First we must find out our License SKU to apply

Connect-MsolService

Get-MsolAccountSku

### Set a users location to GB

Connect-MsolService

Import-CSV "C:\UKUsers.csv" | %{Get-MSolUser -SearchString $_.UserPrincipleName | Set-MsolUser -UsageLocation GB | ft UserPrincipalName,DisplayName,IsLicensed,UsageLocation}

### Set users license, also disable Plans that are not needed, in our case we are just using Exchange Online so we disable everything else

Connect-MsolService

$LicenseOptions = New-MsolLicenseOptions -AccountSkuId companyname:ENTERPRISEPACK -DisabledPlans SHAREPOINTENTERPRISE,MCOSTANDARD,OFFICESUBSCRIPTION,YAMMER_ENTERPRISE,SHAREPOINTWAC,RMS_S_ENTERPRISE

Import-CSV "C:\UKUsers.csv" | %{Set-MsolUserLicense $_.UserPrincipleName –AddLicenses companyname:ENTERPRISEPACK –LicenseOptions $LicenseOptions}

Facebooktwittergoogle_pluslinkedinby feather