- Launch Powershell as an admin
- Install-Module -Name ExchangeOnlineManagement -RequiredVersion 3.1.0
(only need this first time on computer)
Login:
- Import-Module ExchangeOnlineManagement
- Connect-ExchangeOnline -UserPrincipalName youremailhere
Get-User -ResultSize unlimited | Format-Table -Auto Name, DisplayName, RemotePowerShellEnabled | Out-File -FilePath d:\output.txt
(This command will get the list of all users and the status of powershell true/false. It will also push it to a file, rather then screen)
Turn off:
Set-User -Identity user@vbrick.com -RemotePowerShellEnabled $false
Turn on:
Set-User -Identity user@vbrick.com -RemotePowerShellEnabled $true
To do by list of employees by text file:
$<VariableName> = Get-Content <text file>
$<VariableName> | foreach {Set-User -Identity $_ -RemotePowerShellEnabled $false}
$NPS = Get-Content "C:\My Documents\NoPowerShell.txt" $NPS | foreach {Set-User -Identity $_ -RemotePowerShellEnabled $false} |
To get a list of all people and email addresses: (Out put to text file)
Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName,PrimarySmtpAddress | Out-File -FilePath d:\allemail.txt
*** When you try to run the scrips in powershell and you get a restricted message, do the following:
undo restrictins:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
put restrictions back:
Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope CurrentUser