I have a powershell script that I want to run nightly that will go and check three designated groups and remove any disabled users. (this is for a licensing thing) The script works fine. I could run it with a scheduled task, but I'd rather do it with a scheduled workflow. I am confused on what function I should choose to add the script?
Import-Module ActiveDirectory
$groups = "Test Group Universal", "Test Group Global", "Test Group Domain Local"
foreach($group in $groups){
$DisabledUser = Get-ADGroupMember -Identity "$group" | Get-ADUser | Where-Object {$_.Enabled -eq $false} | Where-Object {$_.SamAccountName -notlike "_New*"}
Remove-ADGroupMember -Identity $group -Members $DisabledUser -Confirm:$false
}