Created
July 30, 2014 18:31
-
-
Save DexterPOSH/83b2ec66d4e2baee320a to your computer and use it in GitHub Desktop.
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
function Get-OffilnePrinter | |
{ | |
[CmdletBinding()] | |
[OutputType([int])] | |
Param | |
( | |
# Param1 help description | |
[Parameter(Mandatory=$true, | |
ValueFromPipeline=$true, | |
ValueFromPipelineByPropertyName=$true, | |
Position=0)] | |
[string[]]$ComputerName | |
) | |
Begin | |
{ | |
Write-Verbose -Message "[BEGIN] Function Starting" | |
} | |
Process | |
{ | |
foreach ($computer in $ComputerName) | |
{ | |
if (Test-Connection -ComputerName $computer -Count 2 -Quiet) | |
{ | |
Write-Verbose -Message "[PROCESS] $computer is online , querying it" | |
#Take a look at the MSDN documentation why the below filters are used | |
Get-WmiObject -query "Select * From Win32_Printer WHERE (PrinterStatus='7') OR (ExtendedPrinterStatus='9')" -ComputerName $computer | |
} | |
} | |
} | |
End | |
{ | |
Write-Verbose -Message "[END] Function Ending" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment