Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Connect-<TENANT>
- {
- Param(
- $cred_<TENANT> = (Get-Credential -Message "<TENANT> Credentials" -UserName "admin@<TENANT>")
- )
- Try{
- #CONNECT TO OFFICE365
- Connect-MsolService -Credential $cred_<TENANT>
- #CONNECT TO SHAREPOINT ONLINE
- Connect-SPOService -Url https://<TENANT>-admin.sharepoint.com -Credential $cred_<TENANT>
- #CONNECT TO SKYPE FOR BUSINESS ONLINE
- $sfboSession_<TENANT> = New-CsOnlineSession -Credential $cred_<TENANT>
- Import-PSSession $sfboSession_<TENANT>
- #CONNECT TO EXCHANGE ONLINE
- $exchangeSession_<TENANT> = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $cred_<TENANT> -Authentication Basic -AllowRedirection
- Import-PSSession $exchangeSession_<TENANT> -DisableNameChecking
- #CONNECT TO COMPLIANCE CENTER
- $ccSession_<TENANT> = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.compliance.protection.outlook.com/powershell-liveid/" -Credential $cred_<TENANT> -Authentication Basic -AllowRedirection
- Import-PSSession $ccSession_<TENANT> -Prefix cc
- Clear-Host
- Write-Host 'You are now managing the <TENANT> domain'
- (Get-Host).UI.RawUI.WindowTitle = ($originalUIRawUIWindowTitle + " - You are now managing the <TENANT> domain")
- }
- Catch{
- $_.Exception.Message
- }
- }
- Function Disconnect-<TENANT>
- {
- Param()
- #Remove-PSSession $sfboSession_<TENANT>
- #Remove-PSSession $exchangeSession_<TENANT>
- #Remove-PSSession $ccSession_<TENANT>
- Get-PSSession | Remove-PSSession
- Disconnect-SPOService
- Write-Host 'You are no longer managing the <TENANT> domain'
- (Get-Host).UI.RawUI.WindowTitle = ($originalUIRawUIWindowTitle + " - You are no longer managing the <TENANT> domain")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement