如何在Powershell中修剪管道对象并在管道中进一步使用它?

时间:2019-05-22 19:32:18

标签: powershell

我试图从注册表中获取一些GUIDS,修剪空白行,然后通过卸载运行每个GUID,但是我不确定如何在运行该卸载命令之前修剪每个GUID。到目前为止,这是我无法使用的:

(Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where-Object -Property DisplayName -Match MDX | Format-Table -Property PSChildName -HideTableHeaders | Out-String).Trim() | ForEach-Object {Start-Process "msiexec" -ArgumentList "/x $_ /qn /norestart" -Wait})

1 个答案:

答案 0 :(得分:2)

get-package *mdx* | uninstall-package -whatif

get-itemproperty HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | 
  where displayname -match mdx | select -expand pschildname | 
  foreach { start msiexec -arg "/x $_ /qn /norestart" -wait }

顺便说一句,我碰巧知道,如果您安装Netbeans,则会中断列出64位卸载注册表项属性的操作。