2016-06-30 6 views
1

これまでのところ、私はすべてのバージョンのSAPを削除していますが、特定のバージョンを削除したいだけです。私は私が探してるものを変更しようとしましたが、それでもこれはNetweaverのすべてのバージョンを削除します削除するNetweaverのバージョンを選択してください

SAP

$y = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | 
      Get-ItemProperty | 
       Where-Object {$_.DisplayName -match 'SAP Netweaver Business Client 3.5' } | 
        Select-Object -Property DisplayName, UninstallString, PSPath 

     foreach ($x in $y) 
     { 
      if ($x.UninstallString) 
      { 
       $uninst = "C:\Program Files (x86)\SAP\SapSetup\Setup\nwsapsetup.exe" 
       Start-Process $uninst -ArgumentList "/uninstall /nodlg /force" 
      } 
     } 
+0

おそらく、レジストリキーの 'DisplayVersion'プロパティをチェックしますか? – sodawillow

答えて

0

最終スクリプトのすべてのバージョンを削除します。私の同僚はこれを作成して以来、私は信用を取ることができません。

$y = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | 
    Get-ItemProperty | 
     Where-Object {$_.DisplayName -match "SAP Netweaver Business Client" -and $_.Publisher -match "SAP AG" } | 
      Select-Object -Property DisplayName, UninstallString, PSPath 

foreach ($x in $y) { 
if ($x.UninstallString -like "MsiExec.exe*") { 
    $x.UninstallString = $x.UninstallString -replace "/i","/x" #replace /i with /x to ensure uninstall command is executed 
    $x.UninstallString = $x.UninstallString -replace "MsiExec.exe ","" #remove MsiExec.exe so that only arguements are left 
    $x.UninstallString = "$($x.UninstallString) /qn" #append the /qn for silent uninstall 
    Start-Process -filepath "MsiExec.exe" -ArgumentList "$($x.UninstallString)" -Wait -WindowStyle Hidden 
} else { 
    #check to see if the UninstallString contains quotes 
    $x.UninstallString = "$($x.UninstallString) /nodlg" 
    Start-Process cmd.exe -ArgumentList "/c `"$($x.UninstallString)`"" -WindowStyle Hidden -Wait 
    write-host "$($x.displayname) uninstalled" 
} 
} 
関連する問題