Quantcast
Channel: Active questions tagged windows - Super User
Viewing all articles
Browse latest Browse all 9546

The Windows PowerShell snap-in 'System.Management-Automation' is not installed on this computer

$
0
0

I have Power shell version 4.0 under windows server 2012.. now I run the following powershell command :-

$admin = "domain\user"$pwd = "*****" | ConvertTo-SecureString -asPlainText -Force$LiveCred = New-Object System.Management-Automation.PSCredential($admin, $pwd)Invoke-Command -ComputerName **** -Credential $LiveCred {Get-VM}

but I got this error :-

New-Object : Cannot find type [System.Management-Automation.PSCredential]: verify that the assembly containing thistype is loaded.

so I updated my powershell script as follow:-

add-pssnapin System.Management-Automation;$admin = "domain\user"$pwd = "*****" | ConvertTo-SecureString -asPlainText -Force$LiveCred = New-Object System.Management-Automation.PSCredential($admin, $pwd)Invoke-Command -ComputerName **** -Credential $LiveCred {Get-VM}

But I got this error instead :-

add-pssnapin : The Windows PowerShell snap-in 'System.Management-Automation' is not installed on this computer.At line:1 char:1+ add-pssnapin System.Management-Automation;

so can anyone advice what is causing the above 2 errors ?

second question is there a more straight forward way to pass the password inside the Invoke-Command ? now I can pass the username as follow:-

Invoke-Command -ComputerName **** -Credential domain\username {Get-VM}

but not sure if I can pass the password in the same way ?

Thanks


Viewing all articles
Browse latest Browse all 9546

Trending Articles