Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On executing a PowerShell Remote Script I am getting an error like following

Invoke-Command : Exception calling "ToXmlString" with "1" argument(s): "The requested operation cannot be completed. The computer must be trusted for delegation and the current user account must be configured to allow delegation.

The exact line of code the execution is breaking is as follows:

$rsa = New-Object System.Security.Cryptography.RSACryptoServiceProvider
$key = $rsa.ToXmlString($true)

Can anybody help me to resolve this?

share|improve this question
This is a question I already asked in StackExchange and I got the following links as answer * How do I configure accounts so that they are trusted for delegation in a Windows Server 2003 Enterprise Edition environment? -… * Kerberos authentication and troubleshooting delegation issues - Unfortunately this doesn't work and please suggest if any other options more to be done – RinoTom Jun 30 '11 at 9:53

You need to enable credential delegation, so that PowerShell can pass your username/password to the remote computer, so that it can use them to perform the operation which is failing. See this answer on StackOverflow for instructions/details.

share|improve this answer

You mentioned that this was a remote script. I have a couple questions to try narrowing down the issue:

  • Can you run these two commands locally on the computer?
  • Is the remote computer in the same domain as the computer you're trying to run this?
  • Is this error specific to a user and/or computer (local and remote)?
  • Are you able to run any PowerShell commands on the remote computer? (Get-Process, Get-Host, etc.)

If you are able to run the commands locally, or are unable to test running the commands directly on the remote machine try running the following command from an elevated Command Prompt (CMD, not PowerShell) to have PowerShell explicitly trust the remote computer:

winrm s winrm/config/client '@{TrustedHosts="RemoteComputer"}'

I'll try to edit this answer toward being a real true "answer" rather than a comment, since I'm not able to comment on your question directly.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.