Power shell -- Get-installedsoftwares

 

function Get-InstalledSoftwares
{
   
    function ConvertTo-ProductEntity
    {
        param([Microsoft.Win32.RegistryKey]$RegKey)
        $product = '' | select Name,Publisher,Version
        $product.Name =  $_.GetValue("DisplayName")
        $product.Publisher = $_.GetValue("Publisher")
        $product.Version =  $_.GetValue("DisplayVersion")

        if( -not [string]::IsNullOrEmpty($product.Name)){
            $product
        }
    }

    $UninstallPaths = @(,
 
    'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
  
    'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall')

    
    if([Environment]::Is64BitOperatingSystem) {
        $UninstallPaths += 'HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
    }
    $UninstallPaths | foreach {
        Get-ChildItem $_ | foreach {
            ConvertTo-ProductEntity -RegKey $_
        }
    }
}

  

 

posted @ 2022-02-25 14:25  XXLLA  阅读(42)  评论(0)    收藏  举报