Monday, 18 June 2012

PowerShell Script to copy and verify smsdef.mof files.

In an effort to simply the tedious task of updating the MOF files on SCCM site servers I have written a PowerShell script which will perform a MD5 HASH comparison of your MOF file between the target server and its child servers. The script will use a SQL query to determine the child site server list and their install folders. When the file HASHes being compared differ you will be prompted to overwrite the incorrect file with the file from the target server. The output of the script is a table displaying all the file HASHes generated for visual comparison. If you choose to overwrite any files be sure to run the script a second time to re-check all the file HASHes. By default the script only checks the SMS_DEF.MOF, an alternate filename can be specified with the '-MOFFile' parameter. Full help and syntax examples can be seen by running the help option below. Any feedback or suggestions are always appreciated.

1. Copy the script to any local folder.
2. Open PowerShell with your Admin account from the startmenu.
3. Type ‘Set-executionpolicy RemoteSigned’ and agree to prompt with 'Y’
4. Run the script from any location using an explicit path.
                  e.g. ‘help .\SCCM_MOF_Replicate.ps1 -full' to view syntax examples.

Note: To view script information and syntax type 'help SCCM_MOF_Replicate.ps1 -full'

Running the script:

PowerShell Script:

No comments:

Post a Comment