LTI/ZTI PowerShell: Comment Based Help

I recommend using PowerShell comment based help to document your deployment scripts as described on Technet in about_Comment_Based_Help. This makes your scripts self documenting so colleagues can see who wrote it, what it does and examples and parameter usage. Below, I’ve added an example of comment based help to my evolving rename-computer script.

Anything between the <# and #> in PowerShell is a comment. I’ve also documented it internally by adding a # comment line to each section of code.



Lite-Touch Deployment script to rename a computer



The ZTIRename-Computer.ps1 script will rename a computer and join a new workgroup.



Specifies the new computername


.PARAMETER WorkgroupName

Specifies the new Workgroup name




Add this line to your add powershell task sequence to take values from the deployment

properties OSDComputername and Workgroup. Remember to add the task sequence step

Restart Computer immediately after this step.



ZTIRename-Computer.ps1 -Name PC01 -Workgroup Continuum

This will rename the computer to PC01 and the workgroup to Continuum after a reboot.



Author: Andrew Barnes

Date: 14 September 2012



Online version:          



Param (







    # Rename the Computer using WMI

    (Get-WmiObject win32_computersystem).rename($Name)


    # Add the computer to a new workgroup

    Add-Computer -WorkGroupName $WorkGroupName -WarningAction SilentlyContinue



From a console, other users of the script can use the Get-Help cmdlet to access the documentation.


About Andrew Barnes

A Scripting and Deployment Specialist.
This entry was posted in Deployment, MDT 2010, MDT 2012, PowerShell, SCCM, Scripting and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s