• Powershell-抓取已安装软件


    function Get-InstalledSoftwares
    {
        #
        # Read registry key as product entity.
        #
        $script:lastname=@();
        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($product.Name  -in $script:lastname){            
            }
            else{
                if(-not [string]::IsNullOrEmpty($product.Name) -and -not [string]::IsNullOrEmpty($product.Publisher)){
                    $product
                    $script:lastname=$script:lastname+$_.GetValue("DisplayName")
                }
                
            }
            
    
            
        }
    
        $UninstallPaths = @(,
        # For local machine.
        'HKLM:SOFTWAREMicrosoftWindowsCurrentVersionUninstall',
        # For current user.
        'HKCU:SoftwareMicrosoftWindowsCurrentVersionUninstall')
    
        # For 32bit softwares that were installed on 64bit operating system.
        if([Environment]::Is64BitOperatingSystem) {
            $UninstallPaths += 'HKLM:SOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall'
        }
    
    
        $UninstallPaths | foreach {
            Get-ChildItem $_ |foreach {
                ConvertTo-ProductEntity -RegKey $_
            }
        }
    }
    
    
    Get-InstalledSoftwares
    
  • 相关阅读:
    实验一 GIT 代码版本管理
    实验五、单元测试
    实验四 代码审查
    结对编程 第二阶段
    结对编程第一阶段
    结对编程(一)
    实验1 GIT代码版本管理
    实验五 单元测试
    实验四 代码评审
    实验三 UML建模工具的安装与使用
  • 原文地址:https://www.cnblogs.com/JinweiChang/p/14859071.html
Copyright © 2020-2023  润新知