Powershell 檢測裝置管理器

2022-08-16 23:48:19 字數 1287 閱讀 1738

下圖為其中乙個裝置的詳細資訊

name存在且 pnpclass 為 $null 的裝置為其他裝置(other devices)

status 為 "error" 的裝置為未正常工作裝置(yellow bang)

pnpclass 表示裝置所屬類

通過比較資料的改變來檢測裝置的變化

function catchchange 

$device_change=get-wmiobject -class win32_pnpentity

$device_compare=compare-object $device $device_change

write-host($device_compare.inputobject.name)

}

檢測裝置管理器,監聽裝置變化

# 檢測device manager 

# 0 other devices

# 1 error devices (yellow bang)

# 2 camera number

function getdevstatus

if ($i.status -eq "error")

if ($i.pnpclass -eq "camera")

}return $device_other, $device_yellowbang,$cameranum

}function catchchange

if ($device_num -gt((get-wmiobject -class win32_pnpentity).length))

else

$device_change=get-wmiobject -class win32_pnpentity

$device_compare=compare-object $device $device_change

write-host($device_compare.inputobject.name)

}# catchchange

$a = getdevstatus

if ($null -eq $a)

else

while ($true)

Powershell檢測並啟動多個服務

恢復powershell的預設執行策略,預設不允許執行任何指令碼 set executionpolicy default force 設定powershell的執行策略為,可以執行任何指令碼 set executionpolicy unrestricted force 定義乙個傳送郵件的函式send...

Android裝置檢測

前些日子,自己接手專門為android裝置開發的資料恢復軟體,第一次作為專案經理帶隊進行專案開發。其中為了解決裝置和型號的對應關係,用於區分當前接入系統的裝置是usb裝置,並且是android裝置而不是通常的usb裝置或者其他的手機裝置。故需要獲得裝置的硬體裝置序號,根據硬體資訊特徵碼來和andro...

檢測裝置是否iPhone X

1.通過獲取裝置的 device model 來判斷 每一台 ios 裝置都有對應的硬體編碼 識別符號,稱為 device model 或者叫 machine name 機型對應的device model iphone x iphone10,3 和 iphone10,6 iphone xs ipho...