Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Writing NETGUID value to computer object attribute field for computers in group (using Powershell)

$
0
0
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() }

}

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>