Listing 3: The Set-PrinterVariable Function That Assigns Printer Names to Variables function Set-PrinterVariable{ # ******* BEGIN CALLOUT A ******* # Clear the variables that might exist for printer names. Get-Variable lp* -Scope Global | Where-Object {$_.Name -match "^lp[0-9]+$"} | Remove-Variable -Scope Global # ******* END CALLOUT A ******* # ******* BEGIN CALLOUT B ******* $i = -1 Get-WmiObject Win32_Printer | ForEach-Object {$i+=1; Set-Variable -Name "lp$i" -Value $_.Name -Scope Global} # ******* END CALLOUT B ******* }