title: How to install a Certificates using powershell script
body: <p>I am trying to install a certificate through a PowerShell script. I am using the <code>Import-Certificate</code> method, as suggested in the Microsoft PowerShell documentation.</p>
  <p>Here's my code:</p>
  <pre><code>$script = {
      $file = ( Get-ChildItem -Path  C:\Users\Administrator\Desktop\newCert.cer )
      $file | Import-Certificate -CertStoreLocation cert:\CurrentUser\Root
      echo $file
      }
  
  invoke-command -Credential $clientCred -ComputerName $ClientIP -ScriptBlock $script
  </code></pre>
  <p>I get the following error:</p>
  <pre><code>UI is not allowed in this operation
      + CategoryInfo          : InvalidArgument: (:) [Import-Certificate], ArgumentException 
  </code></pre>
  <p>I'm not sure where is this going wrong - it would be really helpful if someone could point me in the right direction.</p>