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
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: https://scriptimus.wordpress.com
# Rename the Computer using WMI
# 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.