Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Need a script to find computers missing the UUID in AD

Posted on 2014-10-31
10
346 Views
Last Modified: 2014-11-01
I use the following script to add UUID's to AD for use in Windows Deployment Services (WDS)


for /f %%I IN (
'psexec  \\^%1 cmd /c "echo csproduct get UUID|wmic.exe" ^| ^
findstr /r ........-....-....-....-............ '
) do wdsutil /set-device /device:%1 /id /JoinDomain:Yes /Domain:<DOMAIN NAME>

I have added hundreds of computers to the WDS server with this method.  I now need to find and export to a txt file all the computers in an AD OU that are missing the UUID.

Your help in this matter is appreciated.
0
Comment
Question by:mrfite
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 16

Expert Comment

by:Joshua Grantom
ID: 40415782
This should get what your looking for.

$computers = Get-ADComputer -Filter * | % {
Get-WMIObject -ComputerName $_ -Class Win32_ComputerSystemProduct | Select @{Name="ComputerName";Expression={"$_"}},UUID | Where {$_.UUID -eq $Null -OR $_.UUID -eq ""} | Out-File C:\UUIDMissingReport.txt -append
}

Open in new window

0
 

Author Comment

by:mrfite
ID: 40415844
I created a batch file and ran it.  It says that $computers is not recognized as an internal or external command.  Also, how do I target a specific OU on the domain?
0
 
LVL 16

Expert Comment

by:Joshua Grantom
ID: 40415851
this is a powershell command, sorry. I didnt specify that
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:mrfite
ID: 40415966
I ran this as a powershell script and the file that is created is blank.  

Also, how do I specify the Domain and the OU in the domain to scan?
0
 
LVL 16

Expert Comment

by:Joshua Grantom
ID: 40416019
if the file is blank then you may not have any blank UUID's. To get all of them you can run this.

$computers = Get-ADComputer -Filter * -server "domain.com" -SearchBase "CN=Computers,DC=DOMAIN,DC=COM" | % {
Get-WMIObject -ComputerName $_ -Class Win32_ComputerSystemProduct | Select @{Name="ComputerName";Expression={"$_"}},UUID } | Out-File C:\UUIDReport.txt -append
}

Open in new window

0
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 40416039
I think what you're looking for is computer accounts that don't have the NetBootGUID set.
Get-ADComputer -Filter {netbootguid -notlike "*"} -SearchBase "ou=someou,dc=domain,dc=com" | Select Name | Out-File results.txt

Open in new window

0
 

Author Closing Comment

by:mrfite
ID: 40416093
Great this method is exactly what I was looking for.  Thank both of you for your quick support in this matter.  I am still a powershell novice but I am learning.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 40416147
footech has it I think, the NetBootGUID...

Interesting way of setting it originally, I plumped for a different approach - it also works with the MAC address in that field for WDS which you can soon get from ARP table, WMI or from log files created during PC startup. in that case set using script for new pC's and rebuilding ones checks if ID in AD, moves to new correct OU and sets the ID from Mac address.

BTW you should be able to do it without PSEXEC too, e.g.

@echo off
for /f "skip=1" %%a in ('WMIC /namespace:%1 CSPRODUCT GET UUID') do (
  echo %%a is now your ID to use with WDSutil etc.
)
0
 

Author Comment

by:mrfite
ID: 40416913
Thanks for the additional method Steve Knight,

I did try your script and I am getting "Invalid Global switch"
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 40416952
Odd, you did pass a pc name still? Anyway never mind you are already ok.

WMIC /namespace:otherpcbame CSPRODUCT GET UUID

That should work though.

Steve
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
Synchronize a new Active Directory domain with an existing Office 365 tenant
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question