I am learning powershell and I need to write the NETBOOTGUID value to computer object attribute field for computers in a given AD group.
The pwersheelscript below is working partially.
It gets succesfully the NETGUID VALUE from computers online at the time the script is ran, but is writing the SAME NETBOOTGUID value on all computers on the given group.
So I suspect my code is wrong somewhere in the ForEach-Object. Can anyone help? Thanks.
Import-Module ActiveDirectory
# Get all members of the MP-W-Test-Netguid
Get-ADGroupMember 'MP-W-Test-Netguid' |
# Loop through each object
ForEach-Object {
# Do this for each member
# $guid = [guid](Get-WmiObject Win32_ComputerSystemProduct).UUID
$guid = [guid](Get-CimInstance -Classname Win32_ComputerSystemProduct).UUID
Set-ADComputer -Identity $_.SamAccountName -Replace @{ netbootGUID = $guid.ToByteArray() }
}
The pwersheelscript below is working partially.
It gets succesfully the NETGUID VALUE from computers online at the time the script is ran, but is writing the SAME NETBOOTGUID value on all computers on the given group.
So I suspect my code is wrong somewhere in the ForEach-Object. Can anyone help? Thanks.
Import-Module ActiveDirectory
# Get all members of the MP-W-Test-Netguid
Get-ADGroupMember 'MP-W-Test-Netguid' |
# Loop through each object
ForEach-Object {
# Do this for each member
# $guid = [guid](Get-WmiObject Win32_ComputerSystemProduct).UUID
$guid = [guid](Get-CimInstance -Classname Win32_ComputerSystemProduct).UUID
Set-ADComputer -Identity $_.SamAccountName -Replace @{ netbootGUID = $guid.ToByteArray() }
}