Firstly we must store your administrative Office 365 login details:
$UserCredential = Get-Credential
And then we create the powershell session to remotely access office 365 servers:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
This will import all of the relevent modules so you can use them on your local shell:
Import-PSSession $Session
We can now run the following command in order to allow the administrator to view all user accounts:
Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox') -and (Alias -ne 'Admin')} | Add-MailboxPermission -User admin -AccessRights fullaccess -InheritanceType all -AutoMapping $False
And finally when done you can disconnect from the powershell session by using:
Remove-PSSession $Session
No comments:
Post a Comment