Q: How can I manage mysubscription using PowerShell?
A: Several options exist for integrating Office 365 with PowerShell. The easiest approach is to create a PowerShell session to the Office 365 service, which then has all the required PowerShell modules available without you needing to install anything locally. The following PowerShell code will trigger an authentication window for your Office 365 credentials, establishing a session to Office 365 where you can run your commands.
- $UserCredential = Get-Credential
- $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
- Import-PSSession $Session
- #Run you commands here, for example
- Get-accepteddomain | ft DomainName, DomainType, Default, PendingRemoval -AutoSize
- #Close the session
- Remove-PSSession $Session