zoukankan      html  css  js  c++  java
  • powershell:卸载计算机软件

    $ComputerName = hostname
    Function Get-NonMSIApplication($productDisplayname) 
    {
        $Msg="无软件"+$productDisplayname
        $regPathX86 = 'HKLM:SoftwareMicrosoftWindowsCurrentVersionUninstall'
        $regPathX64 = 'HKLM:SOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall'
        $regPath = ($regPathX64,$regPathX86)
        Get-ChildItem ( foreach { $regPath})| foreach { 
            $product =  Get-ItemProperty $_.PSPath
             if($product.DisplayName -like ('*'+$productDisplayname+'*') )
                {
                 $Msg=""
                 $product.UninstallString = $product.UninstallString + " /quiet /norestart"
                Start-Process  (cmd /c $product.UninstallString ) -Wait
                 if((Test-Path $_.PSPath ))
                    { 
                       $Msg = $Msg + '卸载'+ $product.DisplayName +'软件失败'+"|"
                     }
                 else
                    {
                      $Msg = $Msg + '卸载'+ $product.DisplayName +'软件成功'+"|"
                     }
                }
      }
        $Path="\V12CNDCZ01DCSP2	mpSoftwareList"+ $ComputerName +".txt"  
        #Write-Output $Msg|Out-File -filepath $Path
        $Msg >>$Path
    }
    import-csv -path .Blacklist.csv -UseCulture |ForEach-Object { Get-NonMSIApplication $_.blacklist}
    

      

  • 相关阅读:
    zabbix+grafana使用
    其它工具网址
    IntelliJ IDEA 进行多线程调试
    mac外接显示器 双屏同时滑动问题
    wacher和acl
    zookeeper介绍
    iterm2用法与技巧
    linux下ssh公钥验证的设置和远程登录
    不变模式
    单例模式创建的三种方式
  • 原文地址:https://www.cnblogs.com/vmsky/p/13698719.html
Copyright © 2011-2022 走看看