Solved

Need a script to find computers missing the UUID in AD

Posted on 2014-10-31
10
336 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 39

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 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