Updated Devices to query SCCM when offline
This commit is contained in:
parent
c6457d4684
commit
1646d2cdec
|
|
@ -1,9 +1,14 @@
|
||||||
function Get-Devices {
|
function Get-Devices {
|
||||||
param (
|
param (
|
||||||
[string]$comp
|
[string]$comp,
|
||||||
|
[Parameter(Mandatory=$false)][string]$status
|
||||||
)
|
)
|
||||||
try {
|
try {
|
||||||
$usb = Get-WmiObject Win32_USBControllerDevice -ComputerName $comp | ForEach-Object {[wmi]($_.Dependent)} | Sort-Object Manufacturer,Description,DeviceID | Select-Object Manufacturer,Description,@{N="DeviceID\SerialNumber";E={$_.DeviceID}}
|
if ($status -eq "Online") {
|
||||||
|
$usb = Get-WmiObject Win32_USBControllerDevice -ComputerName $comp | ForEach-Object {[wmi]($_.Dependent)} | Sort-Object Manufacturer,Description,DeviceID | Select-Object Manufacturer,Description,@{N="DeviceID\SerialNumber";E={$_.DeviceID}}
|
||||||
|
} else {
|
||||||
|
$usb = Get-SCCM_USB $comp | Sort-Object Manufacturer,Description,DeviceID | Select-Object Manufacturer,Description,@{N="DeviceID\SerialNumber";E={$_.DeviceID}}
|
||||||
|
}
|
||||||
$usb | Add-Member -NotePropertyName Type -NotePropertyValue USB
|
$usb | Add-Member -NotePropertyName Type -NotePropertyValue USB
|
||||||
$usb | Add-Member -NotePropertyName AttachedComputer -NotePropertyValue $comp
|
$usb | Add-Member -NotePropertyName AttachedComputer -NotePropertyValue $comp
|
||||||
foreach($item in $usb){
|
foreach($item in $usb){
|
||||||
|
|
@ -39,35 +44,36 @@ function Get-Devices {
|
||||||
$usb = $null
|
$usb = $null
|
||||||
}
|
}
|
||||||
|
|
||||||
$monitors = @()
|
if ($status -eq 'Online') {
|
||||||
$monitors += Get-Monitor $comp | Select-Object Manufacturer,@{N='Description';E={$_.Model}},@{N="DeviceID\SerialNumber";E={$_.SerialNumber}},AttachedComputer,ActivePort
|
$monitors = @()
|
||||||
$monitors | Add-Member -NotePropertyName Type -NotePropertyValue Monitor
|
$monitors += Get-Monitor $comp | Select-Object Manufacturer,@{N='Description';E={$_.Model}},@{N="DeviceID\SerialNumber";E={$_.SerialNumber}},AttachedComputer,ActivePort
|
||||||
|
$monitors | Add-Member -NotePropertyName Type -NotePropertyValue Monitor
|
||||||
|
|
||||||
$PortsHash = @{
|
$PortsHash = @{
|
||||||
'DELL P170S'= @('DVI','VGA');
|
'DELL P170S'= @('DVI','VGA');
|
||||||
'DELL P2317H'= @('DP','HDMI','VGA');
|
'DELL P2317H'= @('DP','HDMI','VGA');
|
||||||
'DELL P2314H'= @('DP','DVI','VGA');
|
'DELL P2314H'= @('DP','DVI','VGA');
|
||||||
'DELL P2312H'= @('DVI','VGA');
|
'DELL P2312H'= @('DVI','VGA');
|
||||||
'DELL P2319H'= @('DP','HDMI','VGA');
|
'DELL P2319H'= @('DP','HDMI','VGA');
|
||||||
'DELL P2422H'= @('DP','VGA');
|
'DELL P2422H'= @('DP','VGA');
|
||||||
'DELL P2412H'= @('DP','VGA','HDMI');
|
'DELL P2412H'= @('DP','VGA','HDMI');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($item in $monitors){
|
foreach($item in $monitors){
|
||||||
$portList = ''
|
$portList = ''
|
||||||
$found = $false
|
$found = $false
|
||||||
foreach ($port in $PortsHash.($item.Description)) {
|
foreach ($port in $PortsHash.($item.Description)) {
|
||||||
if ($port -eq $item.ActivePort) { $portList += '*'; $found = $true }
|
if ($port -eq $item.ActivePort) { $portList += '*'; $found = $true }
|
||||||
$portList += $port + ','
|
$portList += $port + ','
|
||||||
|
}
|
||||||
|
$portList = $portList -replace "\,$"
|
||||||
|
$item.Description = $item.Description + ' (' + $portList + ')'
|
||||||
|
if ($found -ne $true) { $item.Description += " *" + $item.ActivePort }
|
||||||
}
|
}
|
||||||
$portList = $portList -replace "\,$"
|
|
||||||
$item.Description = $item.Description + ' (' + $portList + ')'
|
|
||||||
if ($found -ne $true) { $item.Description += " *" + $item.ActivePort }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = @()
|
$out = @()
|
||||||
|
|
||||||
|
|
||||||
foreach($item in ($monitors + $usb)){
|
foreach($item in ($monitors + $usb)){
|
||||||
$item.PSObject.TypeNames.Insert(0,'GetPC.Devices')
|
$item.PSObject.TypeNames.Insert(0,'GetPC.Devices')
|
||||||
$out += $item
|
$out += $item
|
||||||
|
|
@ -217,7 +223,7 @@ Function Get-Monitor {
|
||||||
#Translates port numeric code to a readable port identifier
|
#Translates port numeric code to a readable port identifier
|
||||||
$activePorts[ $data.InstanceName ] = $ActivePortHash["$($data.VideoOutputTechnology)"]
|
$activePorts[ $data.InstanceName ] = $ActivePortHash["$($data.VideoOutputTechnology)"]
|
||||||
#Uses the raw code if the code isn't recognized (it's a really weird one)
|
#Uses the raw code if the code isn't recognized (it's a really weird one)
|
||||||
if ($activePorts[ $data.InstanceName ] -eq $null) {
|
if ($null -eq $activePorts[ $data.InstanceName ]) {
|
||||||
$activePorts[ $data.InstanceName ] = $data.VideoOutputTechnology
|
$activePorts[ $data.InstanceName ] = $data.VideoOutputTechnology
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -231,7 +237,7 @@ Function Get-Monitor {
|
||||||
ForEach ($Monitor in $Monitors) {
|
ForEach ($Monitor in $Monitors) {
|
||||||
|
|
||||||
#Grabs respective data and converts it from ASCII encoding and removes any trailing ASCII null values
|
#Grabs respective data and converts it from ASCII encoding and removes any trailing ASCII null values
|
||||||
If ([System.Text.Encoding]::ASCII.GetString($Monitor.UserFriendlyName) -ne $null) {
|
If ($null -ne [System.Text.Encoding]::ASCII.GetString($Monitor.UserFriendlyName)) {
|
||||||
$Mon_Model = ([System.Text.Encoding]::ASCII.GetString($Monitor.UserFriendlyName)).Replace("$([char]0x0000)","")
|
$Mon_Model = ([System.Text.Encoding]::ASCII.GetString($Monitor.UserFriendlyName)).Replace("$([char]0x0000)","")
|
||||||
} else {
|
} else {
|
||||||
$Mon_Model = $null
|
$Mon_Model = $null
|
||||||
|
|
@ -245,7 +251,7 @@ Function Get-Monitor {
|
||||||
|
|
||||||
#Sets a friendly name based on the hash table above. If no entry found sets it to the original 3 character code
|
#Sets a friendly name based on the hash table above. If no entry found sets it to the original 3 character code
|
||||||
$Mon_Manufacturer_Friendly = $ManufacturerHash.$Mon_Manufacturer
|
$Mon_Manufacturer_Friendly = $ManufacturerHash.$Mon_Manufacturer
|
||||||
If ($Mon_Manufacturer_Friendly -eq $null) {
|
If ($null -eq $Mon_Manufacturer_Friendly) {
|
||||||
$Mon_Manufacturer_Friendly = $Mon_Manufacturer
|
$Mon_Manufacturer_Friendly = $Mon_Manufacturer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -414,3 +414,10 @@ Function Get-SCCMChassisType($ComputerName){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Function Get-SCCM_USB($ComputerName) {
|
||||||
|
$usbDevicesQuery = "select SMS_G_System_USB_DEVICE.* from SMS_R_System inner join
|
||||||
|
SMS_G_System_USB_DEVICE on SMS_G_System_USB_DEVICE.ResourceID =
|
||||||
|
SMS_R_System.ResourceId where SMS_R_System.Name = '$ComputerName'"
|
||||||
|
|
||||||
|
return Get-WmiObject -namespace $SCCMNAMESPACE -DirectRead -computer $SCCMSERVER -query $usbDevicesQuery
|
||||||
|
}
|
||||||
|
|
@ -337,11 +337,10 @@ Function Get-PC {
|
||||||
$PCID++
|
$PCID++
|
||||||
|
|
||||||
if ($compStatus -ne 'Online') {
|
if ($compStatus -ne 'Online') {
|
||||||
Write-Warning "$comp is $compStatus unable to proccess command"
|
Write-Warning "$comp is $compStatus skipping monitor query"
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = Get-Devices $comp
|
$out = Get-Devices $comp $compStatus
|
||||||
if ($null -eq $out) {
|
if ($null -eq $out) {
|
||||||
Write-Warning "Unable to get device info for $comp"
|
Write-Warning "Unable to get device info for $comp"
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
Patch: 2024-06-24
|
||||||
|
-Add option in UserProfileBackup to specify custom path
|
||||||
|
-Fix Apps so no longer creates profile
|
||||||
|
-Update Devices to query SCCM when PC offline
|
||||||
Patch: 2024-06-12
|
Patch: 2024-06-12
|
||||||
-Added Wake flag to attempt to wake pc over LAN
|
-Added Wake flag to attempt to wake pc over LAN
|
||||||
-Added LastLogon field to SHSUser
|
-Added LastLogon field to SHSUser
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue