Something like this should do:
Get-User -Filter {RemotePowerShellEnabled -eq $true} | % { Set-User -Identity $_.UserPrincipalName -RemotePowerShellEnabled $false -Confirm:$false }
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hey team,
I've been racking my brain for the last hour and I think I just need a fresh perspective.
In short -
The following command would disable remote PowerShell for all users within the tenant:
Get-User | Set-User -RemotePowerShellEnabled $false
Given the size of the tenant, there are multiple accounts with the same display name so the command fails about 1/4 of the way through. The following command shows me the email address/username (rather than the display name) of each account, and the remote PowerShell enabled status:
Get-User -ResultSize Unlimited | Select-Object UserPrincipalName, RemotePowerShellEnabled
How can I append (or pipe) the first command to change the RemotePowerShellEnabled to "false" using the UserPrincipalName rather than the display name? I'm trying to avoid creating individual Set-User commands for thousands of accounts, if possible.
Thanks in advance
Something like this should do:
Get-User -Filter {RemotePowerShellEnabled -eq $true} | % { Set-User -Identity $_.UserPrincipalName -RemotePowerShellEnabled $false -Confirm:$false }