Get-PC/Private/HostnamesByPrinter.ps1
Zachary Gorman 4a01da0e5d Init commit
2024-06-11 11:27:55 -07:00

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
}