簡體   English   中英

如何在Powershell中以可讀格式(mm-dd-yyyy)獲取DriverDate

[英]How to get DriverDate in Readable format (mm-dd-yyyy) in powershell

我在powershell中使用以下命令來獲取驅動程序版本和驅動程序日期:

Get-WmiObject Win32_PnPSignedDriver |?{$_.DeviceName -ne $null}|select DeviceName,DriverVersion,DriverDate |export-csv -path DeviceDriverVersion.csv -NoTypeInformation -Encoding UTF8

但是,對於DriverDate ,我正在以“ 20060621000000。****** + ***”這樣的格式獲取日期,需要將其轉換為(mm-dd-yyyy)

根據MSDN上的這篇文章Win32_OperatingSystem ConvertToDateTime可用於解析此日期/時間字符串,例如:

$os = Get-WmiObject –Class Win32_OperatingSystem
Get-WmiObject Win32_PnPSignedDriver `
    |?{$_.DeviceName -ne $null}`
    |select DeviceName,DriverVersion,@{Label="DriverDate";Expression={$os.ConvertToDateTime($_.DriverDate).ToString("MM-dd-yyyy")}}`
    |export-csv -path DeviceDriverVersion.csv -NoTypeInformation -Encoding UTF8

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM