Get-Hostname tested and functioning, PCMonitor now uses Output pipeline
This commit is contained in:
parent
0ba1dcee20
commit
f5224ff3fc
|
|
@ -3,10 +3,6 @@ function Get-Hostname ($name) {
|
||||||
$res = Get-AssetConversion $name
|
$res = Get-AssetConversion $name
|
||||||
if ($res) { return $res }
|
if ($res) { return $res }
|
||||||
}
|
}
|
||||||
if ($name.Length -eq 7) {
|
|
||||||
$res = Get-ServiceTagConversion $name
|
|
||||||
if ($res) { return $res }
|
|
||||||
}
|
|
||||||
# Regex to match IP Address brought to you by https://stackoverflow.com/a/36760050
|
# Regex to match IP Address brought to you by https://stackoverflow.com/a/36760050
|
||||||
if ($name -match "^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$") {
|
if ($name -match "^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$") {
|
||||||
$res = Resolve-DnsName $name
|
$res = Resolve-DnsName $name
|
||||||
|
|
@ -14,9 +10,14 @@ function Get-Hostname ($name) {
|
||||||
return $Matches[1]
|
return $Matches[1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($name.Length -eq 7) {
|
||||||
|
$res = Get-ServiceTagConversion $name
|
||||||
|
if ($res) { return $res }
|
||||||
|
}
|
||||||
# Regex to match MAC Address brought to you by https://stackoverflow.com/a/4260512
|
# Regex to match MAC Address brought to you by https://stackoverflow.com/a/4260512
|
||||||
if ($name -match "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$") {
|
if ($name -match "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$") {
|
||||||
|
$res = Get-SCCM_PCFromMAC $name
|
||||||
|
if ($res) { return $res }
|
||||||
}
|
}
|
||||||
|
|
||||||
return $name
|
return $name
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ function Invoke-PCMonitor {
|
||||||
if ($notify) {
|
if ($notify) {
|
||||||
$null = [System.Windows.MessageBox]::Show($msg)
|
$null = [System.Windows.MessageBox]::Show($msg)
|
||||||
}
|
}
|
||||||
Write-Host "$msg"
|
Write-Output "$msg"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Update date and time so user knows script hasn't frozen
|
# Update date and time so user knows script hasn't frozen
|
||||||
|
|
|
||||||
|
|
@ -421,3 +421,12 @@ Function Get-SCCM_USB($ComputerName) {
|
||||||
|
|
||||||
return Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $usbDevicesQuery
|
return Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $usbDevicesQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Get-SCCM_PCFromMAC($mac) {
|
||||||
|
# Try to get address in the right format first like 12:34:56:78:9A:BC
|
||||||
|
# Covers deliminating '-', '.', or no delimeter
|
||||||
|
$mac = $mac -replace '([^:.-]{2})[-.]?[^:](?!$)', '$1:'
|
||||||
|
$pcFromMacQuery = "select SMS_R_System.Name from SMS_R_System where SMS_R_System.MACAddresses = '$mac'"
|
||||||
|
|
||||||
|
return (Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $pcFromMacQuery).Name
|
||||||
|
}
|
||||||
|
|
@ -178,88 +178,49 @@ Function Get-PC {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
#Asset Tag Check
|
$oldcomp = $comp
|
||||||
if ($comp.length -eq 5 -and !$SHSPrinter) {
|
$comp = Get-Hostname $comp
|
||||||
$assettag = $comp
|
if (($oldcomp -eq $comp) -and (($comp.length -eq 5 -and !$SHSPrinter) -or ($comp.length -eq 7))) {
|
||||||
$comp = Get-AssetConversion $comp
|
if ($comp.length -eq 5 -and !$SHSPrinter) {
|
||||||
|
$msg = "$comp Asset Tag not in SMBIOS or CMDB"
|
||||||
if ($null -eq $comp) {
|
Write-Host "`n$msg" -ForegroundColor Red
|
||||||
Write-Host "`n$assettag Asset Tag not in SMBIOS or CMDB" -ForegroundColor Red
|
}
|
||||||
|
elseif ($comp.length -eq 7) {
|
||||||
$props = [Ordered]@{
|
$msg = "$comp Service Tag not found in SCCM"
|
||||||
Hostname = "$assettag Asset Tag not in SMBIOS"
|
Write-Host "`n$msg" -ForegroundColor Red
|
||||||
Status = ""
|
|
||||||
'Current User' = ""
|
|
||||||
'Last User(s)' = ""
|
|
||||||
'IP | MAC' = ""
|
|
||||||
Model = ""
|
|
||||||
'OS' = ""
|
|
||||||
'OS Build' = ""
|
|
||||||
'BIOS Ver' = ""
|
|
||||||
Encryption = ""
|
|
||||||
'Free Space' = ""
|
|
||||||
RAM = ""
|
|
||||||
'SSO Client' = ""
|
|
||||||
'Kiosk Role' = ""
|
|
||||||
'Citrix Ver' = ""
|
|
||||||
'Asset Tag' = ""
|
|
||||||
'Service Tag' = ""
|
|
||||||
'Last Reboot' = ""
|
|
||||||
'TPM Status' = ""
|
|
||||||
'MBAM GPO' = ""
|
|
||||||
Printers = ""
|
|
||||||
}
|
|
||||||
$obj = New-Object -TypeName PSObject -Property $props
|
|
||||||
|
|
||||||
$outPutArray += $obj
|
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#Service Tag Check
|
$props = [Ordered]@{
|
||||||
|
Hostname = "$msg"
|
||||||
|
Status = ""
|
||||||
|
'Current User' = ""
|
||||||
|
'Last User(s)' = ""
|
||||||
|
'IP | MAC' = ""
|
||||||
|
Model = ""
|
||||||
|
'OS' = ""
|
||||||
|
'OS Build' = ""
|
||||||
|
'BIOS Ver' = ""
|
||||||
|
Encryption = ""
|
||||||
|
'Free Space' = ""
|
||||||
|
RAM = ""
|
||||||
|
'SSO Client' = ""
|
||||||
|
'Kiosk Role' = ""
|
||||||
|
'Citrix Ver' = ""
|
||||||
|
'Asset Tag' = ""
|
||||||
|
'Service Tag' = ""
|
||||||
|
'Last Reboot' = ""
|
||||||
|
'TPM Status' = ""
|
||||||
|
'MBAM GPO' = ""
|
||||||
|
Printers = ""
|
||||||
|
}
|
||||||
|
$obj = New-Object -TypeName PSObject -Property $props
|
||||||
|
|
||||||
|
$outPutArray += $obj
|
||||||
|
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
elseif ($comp.length -eq 7) {
|
|
||||||
if (Resolve-DnsName $comp) {
|
|
||||||
#DREW SUCKS
|
#DREW SUCKS
|
||||||
}
|
|
||||||
else {
|
|
||||||
$serviceTag = $comp
|
|
||||||
$comp = Get-ServiceTagConversion $comp
|
|
||||||
|
|
||||||
if ($null -eq $comp) {
|
|
||||||
Write-Host "`n$serviceTag Service Tag not found in SCCM" -ForegroundColor Red
|
|
||||||
|
|
||||||
$props = [Ordered]@{
|
|
||||||
Hostname = "$serviceTag Service Tag not found in SCCM"
|
|
||||||
Status = ""
|
|
||||||
'Current User' = ""
|
|
||||||
'Last User(s)' = ""
|
|
||||||
'IP | MAC' = ""
|
|
||||||
Model = ""
|
|
||||||
'OS' = ""
|
|
||||||
'OS Build' = ""
|
|
||||||
'BIOS Ver' = ""
|
|
||||||
Encryption = ""
|
|
||||||
'Free Space' = ""
|
|
||||||
RAM = ""
|
|
||||||
'SSO Client' = ""
|
|
||||||
'Kiosk Role' = ""
|
|
||||||
'Citrix Ver' = ""
|
|
||||||
'Asset Tag' = ""
|
|
||||||
'Service Tag' = ""
|
|
||||||
'Last Reboot' = ""
|
|
||||||
'TPM Status' = ""
|
|
||||||
'MBAM GPO' = ""
|
|
||||||
Printers = ""
|
|
||||||
}
|
|
||||||
$obj = New-Object -TypeName PSObject -Property $props
|
|
||||||
|
|
||||||
$outPutArray += $obj
|
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#Pulls basic SNMP Data from printer $comp
|
#Pulls basic SNMP Data from printer $comp
|
||||||
if ($SHSPrinter) {
|
if ($SHSPrinter) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue