powershell

Error message when no Asset Tag Detected

Set the computer name using the BIOS Asset Tag

If you are setting the Asset Tag the same name that the computer is, it makes sense to only have to input it once. I created a powershell script that will do the following:

If VM or Mac: Exit 0

If  computer exists in SCCM: Exit 0

If AssetTag Exists/Not empty: Set OSDComputerName to AssetTag, Exit 0

If AssetTag doesn't exist: Bring up an error message, Exit 1

 

Tested with HP and Dell machines.

Download Script https://github.com/happysccm/Files/tree/master/Check%20for%20Asset%20Tag%20-%20OSD%20AssetTag%20Check%20-%20Most%20code%20by%20Nickolaj%20and%20Dave%20Green

Update: Added optional script that uses the HP Ownership Tag

How to use:
Create a package for the script

Copy serviceUI.exe (From MDT Toolkit) to the same folder.

In the Task Sequence after initial format of the drive create a Run Command Line step using the package that you created

with the command: ServiceUI.exe -process:TSProgressUI.exe %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File AssetTag.ps1

 

Thanks Nickolaj and Dave Green for the initial form

 

Create a compliance baseline to remove a folder

compliant

In this example we are killing the Silverlight start menu folder enabling us to use the Windows Updates while keeping the start menu clean.

Create the Configuration Item

1. In the console click Create Configuration Item

2. Name your configuration item, click 'This configuration item contains application settings' and click Next

Screenshot 2014-11-14 10.03.58

3. Select 'Always assume application is installed' and click Next

Screenshot 2014-11-14 10.05.15

4. Click New, Change the Setting type to 'Script'. Change the Data type to 'String'. Also name your Setting.

Screenshot 2014-11-14 10.29.17

5. Under Discovery Script click 'Add Script'

6. Ensure Script language is 'Windows Powershell' and paste the following

$false -eq (Test-Path "C:ProgramDataMicrosoftWindowsStart MenuProgramsMicrosoft Silverlight")

Screenshot 2014-11-14 10.32.38

7. Under Remediation Script click 'Add Script'

8. Ensure Script language is 'Windows Powershell' and paste the following

remove-item "C:ProgramDataMicrosoftWindowsStart MenuProgramsMicrosoft Silverlight" -recurse

Screenshot 2014-11-14 10.42.37

9. Click 'Ok',  then click the 'Compliance Rules' tab

10. Click 'New'

Screenshot 2014-11-14 10.47.35

11. Configure the Compliance rule: Set 'Rule type' to Value. Set the Value returned to equal 0. Click 'Run the specified remediation script when this setting is non complaint'.

Screenshot 2014-11-14 10.52.10

12. Click 'OK' then 'Next', 'Next' on the Wizard Screen.

13. Choose the OS Environments for compliance

Screenshot 2014-11-14 10.54.33

14. Click 'Next' until you finish the Wizard.

15. Under Configuration Baselines click 'Create Configuration Baseline' and add the configuration item we just created, then click 'OK'

Screenshot 2014-11-14 10.57.31

 

16. The Baseline is now ready to be deployed to your test collection!

Right click and select Deploy, Enable the remediation options and change the Schedule if needed.

Screenshot 2014-11-14 11.00.15

 

 

17. On your test machine, request a new machine policy, then click on the Components tab. Clicking Refresh should show the new baseline which you can then evaluate.

baselines

18. Within a minute the remediation runs and the folder disappears!

baselinesComp