Tidied up SHSPrinter in preparation for making it a job
This commit is contained in:
parent
3397a29df4
commit
69f3146070
|
|
@ -13,15 +13,24 @@ function Get-SHSPrinter {
|
|||
[string]$printer
|
||||
)
|
||||
|
||||
Write-Progress -Activity "Getting printer details for $name" -Status 'Getting IP Address' -PercentComplete 10 -ParentId 1
|
||||
Write-Progress -Activity "Getting printer details for $printer" -Status 'Getting IP Address' -PercentComplete 10 -ParentId 1
|
||||
$snmp = New-Object -ComObject olePrn.OleSNMP
|
||||
|
||||
#Gets the printer ip and full domain name
|
||||
$result = Get-PrinterIP $printer
|
||||
$domains = @('.gsrmc.int.samhealth.net','.avery.int.samhealth.net','.sagh.int.samhealth.net','.snlh.int.samhealth.net','.slch.int.samhealth.net','.spch.int.samhealth.net')
|
||||
$result = Resolve-DnsName $printer -ErrorAction SilentlyContinue
|
||||
|
||||
if($null -eq $result){
|
||||
foreach ($domain in $domains) {
|
||||
$search = "$printer$domain"
|
||||
$result = Resolve-DnsName $search -ErrorAction SilentlyContinue
|
||||
if($null -ne $result){ break }
|
||||
}
|
||||
}
|
||||
|
||||
#CMDB Data
|
||||
|
||||
Write-Progress -Activity "Getting printer details for $name" -Status 'Getting CMDB data' -PercentComplete 20 -ParentId 1
|
||||
Write-Progress -Activity "Getting printer details for $printer" -Status 'Getting CMDB data' -PercentComplete 20 -ParentId 1
|
||||
# $cmdbRecord = Get-LANDeskCMDBItem -Name $printer
|
||||
$cmdbRecord = Search-ISMBO -BO cis -filter "Name eq '$Printer'" -RawFilter
|
||||
|
||||
|
|
@ -409,46 +418,6 @@ function Get-PrinterIP {
|
|||
[parameter(ValueFromPipeline)]
|
||||
[string]$printer
|
||||
)
|
||||
$hit = $false
|
||||
$domains = @('.gsrmc.int.samhealth.net','.avery.int.samhealth.net','.sagh.int.samhealth.net','.snlh.int.samhealth.net','.slch.int.samhealth.net','.spch.int.samhealth.net')
|
||||
$result = Resolve-DnsName $printer -ErrorAction SilentlyContinue
|
||||
|
||||
if($result -eq $null){
|
||||
$hit = $false
|
||||
foreach ($domain in $domains) {
|
||||
$search = "$printer$domain"
|
||||
$result = Resolve-DnsName $search -ErrorAction SilentlyContinue
|
||||
if($result -ne $null){
|
||||
$hit = $true
|
||||
$name = $result.Name
|
||||
$ip = $result.IPAddress
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($result -eq $null){
|
||||
if($hit -eq $false){
|
||||
$ip = $null
|
||||
$name = $null
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
$name = $result.Name
|
||||
$ip = $result.IPAddress
|
||||
|
||||
}
|
||||
|
||||
$props = [ordered]@{Hostname=$printer
|
||||
IP=$ip
|
||||
Path=$name
|
||||
}
|
||||
$obj = New-Object -TypeName PSObject -Property $props
|
||||
|
||||
return $obj
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue