If you are like me and use “All Unknown Computers” to deploy your OSD to you will also be fairly familiar of making sure you have cleared an object from the SCCM Database before trying to re-image, otherwise … well its not Unknown now is it?
Typically this would involve a tech opening AD searching for the computer and removing it, then opening the SCCM console and doing the same. I have spent some time adding to a tool i previously released , adding many more functions.
- Remove AD Objects
- Remove SCCM Objects
- Remove both SCCM/AD objects
- View LAPS (Local Admin Password)
- View additional machine details
- Remote control
Download Tool – if LAPS is deployed in your environment
Download Tool – if LAPS is NOT deployed in your environment
Requirements of Tool.
Under the hood.
Settings for your environment are referenced in the file “settings.xml”
Settings.XML
https://gist.github.com/danjpadgett/9fd48031fbf9a1e7f184592b542744f4.js
SCCMServer: Location of SCCM instance
SearchBase: the root location for workstations (in format of DistinguishedName)
SCCMSite: your SCCM Site Code
SystemOUName: Same path as SearchBase , but in the format of CanocialName
CMRCViewer: Location of the SCCM Remote control viewer files – see below for more info
Spaces in the search base should be accepted without worry.
Ensure that you set these values to match your environment. The settings file MUST reside in the same root folder as the Remove Objects executable, if not you will see this error.
Logging
You will get an output file stored in the same location as the executable, this will be recreated each time the “search/filter” button is used, this is used in case you face issues with objects not being found.
Remote Control
I have provided a “InstallRemote.cmd” which would copy these files to the default path in C:\Program Files (x86)\ConfigMgrConsole\bin\i386 . I haven’t included the actual remote control files in my download as these are copyrighted.
Usage.
(Note: If you dont have LAPS deployed, script will still work but you will not see the column for it)
Note, your SystemOUName variable should be the root location for your workstations, if your system OU name doesnt match your searchbase, items will be shown as yellow , as they cannot be matched against the same computer names in AD.
The lookup code that manages this is: $sccmQuery = get-wmiobject -query “select * from SMS_R_SYSTEM WHERE Name like ‘%’ ” -computername $sccmserver -namespace “ROOT\SMS\site_$sccmsite” | Where-Object { $_.SystemOUName -contains $SystemOUName }
A block of code will run for each computer loaded that will check that each AD Hostname has a matching record in the above lookup code, if the Hostname is not found, the row will be shown as yellow.
Code for that lookup is :
if ($datagridviewResults.Rows[$i].Cells[‘SCCMResourceID’].Value -eq $null)
{
$row.defaultcellstyle.backcolor = ‘yellow’
}
Limitations.
Disclaimer.
Full code can be viewed here – Note this is created with PS studio therefore all object controls are held separately, if you would like the full code export with object controls, let me know.
Hello, i m unable to download your nice script since OneDrive, could you send me by email, please ?
LikeLike
emailed.
LikeLike
Looks like onedrive is locked? Can you email a link? Interesting. Thank you
LikeLike