$PrinterPath = "\\server\printer"
$net = new-Object -com WScript.Network
$net.AddWindowsPrinterConnection($PrinterPath)
$a = Get-WMIObject -query "Select * from Win32_Printer where sharename = 'printersharename'"
$a.SetDefaultPrinter()
I've also decided it best that I cover my ass and prevent certain machines from being able to accidently be re-imaged. Basically I've modified my task sequences to look for a file called IT.SEC on the C drive. If the file is found, then the task sequence skips the rest of the imaging process and goes straight to rebooting the PC back to the logon screen. If the file isn't found, it reboots into WinPE. However if you PXE boot or boot off the CD, the whole file checking process is stopped. Below is a image of my TS now that it has this in it, along with the script that runs.
# check to see if workstation is protected
$path = 'C:\SCCM\IT.SEC'if (test-path $path)
{
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$tsenv.Value("Protected") = "True"
}
else
{
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$tsenv.Value("Protected") = "False"
}
Enjoy

No comments:
Post a Comment