Hi ,
Maybe generate a CSV with GetADMemberGroup with the list of restricted users and then read line by line from this CSV to run in the disconnect command?
Yes, you can. The example of the script or something along these lines:
Get-ADGroupMember -Identity "Restricted_VPN" | ForEach-Object{
$name = 'YourDomain\' + $_.SamAccountName
Disconnect-VpnUser -UserName $name
}
Since I am not expert in scripting, if there are some errors in the script, you can have this asked in PowerShell forum for better answers. Open a new thread and add the tag of windows-server-PowerShell, PowerShell experts here will help you improve the script.
Best Regards,
Candy
--------------------------------------------------------------
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.