• Get Remote Computer Install Software


    #requires -Version 2
    
    function Get-Software
    {
        param
        (
            [string]
            $DisplayName='*',
    
            [string]
            $UninstallString='*',
    
            [string[]]
            $ComputerName
        )
    
        [scriptblock]$code =
        {
    
            param
            (
            [string]
            $DisplayName='*',
    
            [string]
            $UninstallString='*'
    
            )
          $keys = 'HKLM:SOFTWAREMicrosoftWindowsCurrentVersionUninstall*',
           'HKLM:SOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall*'
    
          $result=Get-ItemProperty -Path $keys |
          Where-Object { $_.DisplayName } |
          Select-Object -Property DisplayName, DisplayVersion, UninstallString |
          Where-Object { $_.DisplayName -like $DisplayName } |
          Where-Object { $_.UninstallString -like $UninstallString }
    
          $result
          #$f=$result -contains '*autodesk*'
        }
        if ($PSBoundParameters.ContainsKey('ComputerName'))
        {
            Invoke-Command -ScriptBlock $code -ComputerName $ComputerName -ArgumentList $DisplayName, $UninstallString
        }
        else
        {
            & $code -DisplayName $DisplayName -UninstallString $UninstallString
        }
    }
    
    #Get-Software -ComputerName "CNKLCNSHSR2001"
    
    
    Import-Csv "C:TempLogspcname.csv" |
    foreach{
        try{
            Get-Software -ComputerName $_."pcname"
            
        }
        catch{
            
        }
    }|
    export-csv  C:TempLogspcname_Result.csv -notypeinformation 
    

      

  • 相关阅读:
    18文件权限管理
    17用户身份管理
    16Shell脚本—计划任务服务程序
    15Shell脚本—流程控制
    14Shell脚本—判断语句
    13Shell脚本—编写简单脚本
    12Vim在系统配置中的应用示例
    11Vim文本编辑器
    10重要的环境变量
    09命令行通配符和转义字符
  • 原文地址:https://www.cnblogs.com/Javi/p/10001098.html
Copyright © 2020-2023  润新知