This script disables RemotePowerShell for all users except members of a specific AD group.
- Create an AD group e.g. "AllowRemotePowerShell".
- Change line 2 of this script to your AD group
- Run this script:
.\Disable-RemotePowerShell.ps1
- Create a Windows Scheduler Task to run this script every day
- Exchange Server 2019
- Windows Server 2022