Windows 注册表存储已安装的所有软件的名称和详细信息。PowerShell 可以读取该信息,并为您提供完整的软件清单:
1 2 3 4 5 6 7 8 9 10 11 12
# read all child keys (*) from all four locations and do not emit # errors if one of these keys does not exist Get-ItemProperty-Path'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKCU:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'-ErrorAction Ignore | # list only items with the DisplayName Where-Object DisplayName | # show these registry values per item Select-Object-Property DisplayName, DisplayVersion, UninstallString, InstallDate | # sort by DisplayName Sort-Object-Property DisplayName
CommandType Name Version Source ---------------------------- FunctionNew-PSOneQRCodeGeolocation2.2QRCodeGenerator FunctionNew-PSOneQRCodeTwitter2.2QRCodeGenerator FunctionNew-PSOneQRCodeVCard2.2QRCodeGenerator FunctionNew-PSOneQRCodeWifiAccess2.2QRCodeGenerator
Version Name Repository Description -------------------------------- 2.2.3 PowerShellGet PSGallery PowerShell module with commands for discovering, installing, upd...
If you own Administrator privileges, you can even change this setting. To turn off automatic reset booting, run this: 如果您拥有管理员特权,甚至可以更改此设置。要关闭自动重置启动,请运行以下命令:
1
Set-CimInstance-Query'Select * From Win32_ComputerSystem'-Property@{AutomaticResetBootOption=$false}
classValidatePathExistsAttribute : System.Management.Automation.ValidateArgumentsAttribute { # the value to be checked surfaces in $path and must be of type [object] [void]Validate([object]$path, [System.Management.Automation.EngineIntrinsics]$engineIntrinsics) { # if anything is wrong with the value, throw an exception if([string]::IsNullOrWhiteSpace($path)) { Throw [System.ArgumentNullException]::new() } if(-not (Test-Path-Path$path)) { Throw [System.IO.FileNotFoundException]::new() }
# if NO exception was thrown, the value is accepted } } #endregion
# get all WMI instances Get-WmiObject-Class CIM_LogicalDevice | # display propertes Select-Object-Property __Class, Name, Description, __Path | # let user select some Out-GridView-Title'Select one or more (hold CTRL)'-PassThru | # retrieve the full selected instance by path ForEach-Object { [wmi]$_.__Path | Select-Object * | Out-Default }