I am trying to install a certificate through a PowerShell script. I am using the Import-Certificate method, as suggested in the Microsoft PowerShell documentation.
Here's my 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
I get the following error:
UI is not allowed in this operation
+ CategoryInfo : InvalidArgument: (:) [Import-Certificate], ArgumentException
I'm not sure where is this going wrong - it would be really helpful if someone could point me in the right direction.
