Skip to content

Instantly share code, notes, and snippets.

@DexterPOSH
Created July 30, 2014 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DexterPOSH/83b2ec66d4e2baee320a to your computer and use it in GitHub Desktop.
Save DexterPOSH/83b2ec66d4e2baee320a to your computer and use it in GitHub Desktop.
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