17 lines
637 B
PowerShell
17 lines
637 B
PowerShell
Function HostnamesByPrinter($ComputerName){
|
|
|
|
$SiteName="100"
|
|
|
|
$SCCMServer="shscm01.int.samhealth.net"
|
|
|
|
$SCCMNameSpace="root\sms\site_100"
|
|
|
|
$FindHostnamesByPrinterQuery = "select SMS_R_System.Name from SMS_R_System inner join SMS_G_System_PRINTER_DEVICE on
|
|
SMS_G_System_PRINTER_DEVICE.ResourceId = SMS_R_System.ResourceId where SMS_G_System_PRINTER_DEVICE.Name = '$ComputerName'"
|
|
|
|
$FindHostnamesByPrinterSCCM = Get-WmiObject -namespace $SCCMNameSpace -DirectRead -computer $SCCMServer -query $FindHostnamesByPrinterQuery |
|
|
Select-Object -ExpandProperty Name
|
|
|
|
Return $FindHostnamesByPrinterSCCM
|
|
|
|
} |