一種方法是格式化日期,如下面的示例。
$date=Get-Date
週一,2013年12月9日上午5時29分50秒
$date.ToString("dd/MM/yyyy")
2013年9月12日
編輯: 我沒有獲得Win32Reg_AddRemovePrograms,所以未經測試。
嘗試添加這到底:
| %{ $_.InstallDate = ($_.InstallDate.tostring("dd/MM/yyyy")); $_ }
所以最後:(加`換行)
get-wmiobject -Class Win32Reg_AddRemovePrograms -ComputerName AComputer| `
where {$_.DisplayName -notlike "hotfix" -and $_.DisplayName -notlike "Security Update" -and $_.DisplayName -notlike "*Update for Windows *"} | `
select DisplayName,Version,Publisher,InstallDate | `
%{ $_.InstallDate = ($_.InstallDate.tostring("dd/MM/yyyy")); $_ }
,或者如果在日期格式,與吉文所提到的,
| %{ $_.InstallDate = ([DateTime]::ParseExact($_.InstallDate,'yyyyMMdd',$null).ToString('dd/MM/yyyy')) ;$_}
全文:
get-wmiobject -Class Win32Reg_AddRemovePrograms -ComputerName AComputer| `
where {$_.DisplayName -notlike "hotfix" -and $_.DisplayName -notlike "Security Update" -and $_.DisplayName -notlike "*Update for Windows *"} | `
select DisplayName,Version,Publisher,InstallDate | `
%{ $_.InstallDate = ([DateTime]::ParseExact($_.InstallDate,'yyyyMMdd',$null).ToString('dd/MM/yyyy')) ;$_}
謝謝Shay。正如我從另一個答覆中看到的,這不會從64位安裝的軟件獲取信息。所以我想我需要從註冊表中獲取這些信息,如果這是比使用Win32_Product更快的方法。 – user1890242
無論如何,就我所知,日期值的格式是相同的。 –