Add "Local Group" Pre-Requisite into Least Privileges Script
under consideration
S
Sam Walker
As per the Least Privileges documentation, the Liongard service account requires to be a member of the "Hyper-V Administrators" and "Remote Management Users" local user groups for each server.This should be added into the existing Liongard PowerShell script that handles the WMI/SC Manager permissions as saves considerable time.I've added this functionality myself at the end of the current script and it works great.
Write-Host -BackgroundColor Blue -ForegroundColor Yellow "Adding Liongard Service Account to Local User Groups"
$GroupName = "Remote Management Users", "Hyper-V Administrators"
$DomainName = $env:USERDOMAIN
$ErrorActionPreference = "Stop"
foreach($server in $x) {
$Server = $Server.trim()
$ComputerName = $Server
Write-Host "Processing $ComputerName" -ForegroundColor Green
Foreach($localgroup in $groupname){
Try{
$Group = [ADSI]"WinNT://$ComputerName/$localgroup,group"
$User = [ADSI]"WinNT://$DomainName/$serviceuser,user"
$Group.Add($User.Path)
}
Catch{
$_.Exception.innerexception
Continue
}
}
}