Well, there exist dozens of Blog posts like “Howto connect PowerShell to Office 365″ etc. In this post I want to share those commands that I use frequently:
First, creating a connection to Office 365:
PS > $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection PS > Set-ExecutionPolicy -ExecutionPolicy unrestricted PS > Import-PSSession $Session
Changing the principal name of a user:
PS > Set-MsolUserPrincipalName –UserPrincipalName user@example.onmicrosoft.com -newUserPrincipalName user@example.com
Set the passwords of all users to never expire:
PS > Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $true
Add/Remove mailbox permissions:
PS > Add-MailboxPermission user@example.com -User admin@example.com -AccessRights FullAccess -InheritanceType All -AutoMapping $false PS > Remove-MailboxPermission user@example.com -User admin@example.com -AccessRights FullAccess -InheritanceType All
Hide/Show a mailbox in the GAL:
PS > Set-Mailbox user@example.com -HiddenFromAddressListsEnabled $true
To be contd.



0 Responses to “Office 365 PowerShell Snippets”