GidNumber Powershell?
That use of $groups
looks like a failed attempt at combining 2 lines of code in to one.
This is probably what the code originally looked like:
$groups = Get-ADGroup -LDAPFilter "(!gidNumber=*)" | ? {$_.GroupCategory -eq "Security"}
$groups | Set-ADGroup -Add @{ gidNumber=++$highGid }
And this is the equivalent as a one-liner:
Get-ADGroup -LDAPFilter "(!gidNumber=*)" | ? {$_.GroupCategory -eq "Security"} | Set-ADGroup -Add @{ gidNumber=++$highGid }
$gighGid
must be defined as System.Double
. I don't have any GID's assigned to AD object in my domain, so I can't test this, but you could probably just cast $highGid to an int
somewhere. It would make the most sense to do it on the first line, like so:
$highGid = [int](Get-ADGroup ...)