Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Get-PSSession | Remove-PSSession
- $User = 'My-User@My-MSOL-Email-Domain'
- $Pass = ConvertTo-SecureString -String 'DontWorryImNotDumbEnoughtoPutARealPasswordHere' -AsPlainText -Force
- #Encrypt password for transmission to Office365
- $SecureOffice365Password = ConvertTo-SecureString -AsPlainText $Pass -Force
- #Build credentials object
- $Office365Credentials = New-Object System.Management.Automation.PSCredential $User, $Pass
- #Create remote Powershell session
- $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $Office365credentials -Authentication Basic –AllowRedirection
- #Import the session
- Import-PSSession $Session -AllowClobber | Out-Null
- #Connect
- Import-Module MSOnline
- $LiveCred = Get-Credential -Credential $Office365Credentials
- Connect-MsolService -Credential $LiveCred
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement