[英]How do I get the first install date of a disk drive in PowerShell?
使用Get-PnpDeviceProperty
您可以提取您正在尋找的附加信息。 它不像你想象的那么直觀,但它確實有效,我相信你可以找到確切的 Class 並直接拉取它。 但這是一種功能性方式 n.netheless。
# Get PNPDeviceID from the disk driver
$PNPDeviceID = Get-CimInstance -ClassName CIM_DiskDrive | Select-Object -ExpandProperty PNPDeviceID
# Get friendly name to verify and first install date
Get-PnpDeviceProperty -InstanceId $PNPDeviceID -KeyName DEVPKEY_Device_FriendlyName, DEVPKEY_Device_FirstInstallDate | Select-Object KeyName, Data
憑借Almighty 的回答中的出色指示,我想出了以下解決方案:
Get-PnpDevice -Class DiskDrive -Status OK | ForEach-Object {
[PSCustomObject]@{
FriendlyName=(Get-PnpDeviceProperty -InputObject $_ -KeyName DEVPKEY_Device_FriendlyName).Data;
FirstInstallDate=(Get-PnpDeviceProperty -InputObject $_ -KeyName DEVPKEY_Device_FirstInstallDate).Data
}
}
它獲取所有當前安裝的磁盤驅動器並返回它們的友好名稱和首次安裝日期作為自定義 object 以供進一步處理。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.