title: Uninstall program using get-process and uninstallstring with call operator (&)
body: <p>I'm trying create a uninstall script to uninstall any program tha I want.</p>
  <p>I was using this script:</p>
  <p>get-package -Name &quot;<em>XXXXX</em>&quot; | Uninstall-Package</p>
  <p>But I saw that when the &quot;provideName&quot; attribut is &quot;Program&quot; it not working, so I use this.</p>
  <pre><code>$packageArray = get-package &quot;*XXXX*&quot;
  foreach ($package in $packageArray){
  $a = $package.ProviderName
  if ($a -eq &quot;Programs&quot;){
  &amp; {($package.Meta.Attributes[&quot;UninstallString&quot;]  -replace '&quot;') /S}
  }
  if ($a -ne &quot;Programs&quot;){
  get-package -Name &quot;*XXXXX*&quot; | Uninstall-Package
  }
  }
  </code></pre>
  <p>This part bellow was working fine when I have not &quot;&quot;&amp;quot.&quot;&quot;, like this.</p>
  <p>&amp; {($package.Meta.Attributes[&quot;UninstallString&quot;]  -replace '&quot;') /S}</p>
  <p>Print:
  <a href="https://i.stack.imgur.com/14fPw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/14fPw.png" alt="enter image description here" /></a></p>
  <p>But now I'm getting erro when a uninstall string has &quot;&amp;quot.&quot; value, like this.</p>
  <p>UninstallString=&quot;&quot;&amp;quot&quot;;C:\Users\rsantanna\AppData\Local\GoToMeeting\19950\G2MUninstall.exe&quot; /uninstall&quot;</p>
  <p>Print.
  <a href="https://i.stack.imgur.com/hBPTr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hBPTr.png" alt="Example of &quot;&quot;&amp;quot.&quot;&quot; value" /></a></p>
  <p>When it occur I get this error.</p>
  <p>&amp; : The term 'C:\Users\rsantanna\AppData\Local\GoToMeeting\19950\G2MUninstall.exe /uninstall' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
  path is correct and try again.
  At line:6 char:7</p>
  <ul>
  <li>
  <pre><code>&amp; ($UninstallString)
  </code></pre>
  </li>
  <li>
  <pre><code>  ~~~~~~~~~~~~~~~~~~
  </code></pre>
  <ul>
  <li>CategoryInfo          : ObjectNotFound: (C:\Users\rsanta....exe /uninstall:String) [], CommandNotFoundException</li>
  <li>FullyQualifiedErrorId : CommandNotFoundException</li>
  </ul>
  </li>
  </ul>
  <p>Anyone can help me ?</p>