$newVmNames=@(
'SERVER0001',
'SERVER0002'
)
$newUsers=@(
'domain\user1'
)
$groupNames='Administrators','Remote Desktop Users'
$newVmNames|%{
invoke-command -computername $_ {
param($newUsers,$groupNames)
try{
$groupNames|%{
Add-LocalGroupMember -Group $_ -Member $newUsers
write-host "$env:computername`: Group name '$groupName' now has these users`r`n$(get-localgroupmember $groupName)"
}
}catch{
write-warning $_
}
} -ArgumentList $newUsers,$groupNames
}
Categories: