New
-WebServiceProxy -Uri
"http://webserver/mdtws/ad.asmx?WSDL"
$wsCall =
-ErrorAction SilentlyContinue
$wsCall | Get-Member
$wsCall.DoesComputerExist(computername)
#use WMI to get the current computername
$csProp =
Get
-WmiObject -
Class
Win32_ComputerSystem -ErrorAction SilentlyContinue
$myName = $csProp.Name
#use the MDT webservice to see if the computer exists
$isComputer = $wsCall.DoesComputerExist($myName)
#display the results
if($isComputer) {
Write-Host
"Computeraccount $myName was found in AD"
} else {
"Computeraccount $myName does not exist"
}
#use WMI to get the current computer's uuid
$cpProp =
Win32_ComputerSystemProduct -ErrorAction SilentlyContinue
$myUUID = $cpProp.UUID
#use the MDT webservice to set the computers netbootGUID
$wsResp = $wsCall.SetComputerNetbootGuid($myName,$myUUID)
if($wsResp) {
Write-EventLog -LogName System -EntryType Information -EventID 10001 -Source eventlog -Message
"SetNetbootGuid: UUID correctly set for $myName."
"UUID correctly set for $myName"
Write-EventLog -LogName System -EntryType
Error
-EventID 10001 -Source eventlog -Message
"SetNetbootGuid: Failed to set UUID for $myName."
"FAILED to set UUID for $myName"
Using this today in a large enterprise...fantastic post. Thanks