Last active
January 1, 2016 10:07
-
-
Save megamorf/0604e4fd5264c5213940 to your computer and use it in GitHub Desktop.
Printer Wake Up Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# with different set of printer shares | |
.\WakeUpPrinters.ps1 -PrinterShareNames @('printer4_ShareName','printer5_ShareName','printer6_ShareName') | |
# with additional verbose output | |
.\WakeUpPrinters.ps1 -Verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
Param( | |
[ValidateNotNullOrEmpty()] | |
[string[]]$PrinterShareNames = @('printer1_ShareName','printer2_ShareName','printer3_ShareName') | |
) | |
$Date = Get-Date | |
if( @("Sunday","Saturday") -notcontains $Date.DayOfWeek) | |
{ | |
if( ($Date.Hour -ge 8) -and ($Date.Hour -lt 17) ) | |
{ | |
foreach($PrinterShareName in $PrinterShareNames) | |
{ | |
$Printer = Get-WmiObject win32_printer -Filter "ShareName='$PrinterShareName'" | |
Write-Verbose "$PrinterShareName - Status [$($Printer.PrinterStatus)]" | |
if($Printer.PrinterStatus -ne 4) | |
{ | |
Write-Verbose "$PrinterShareName - Status not '4' - Printing test page..." | |
$Printer.PrintTestPage() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment