Managed Code and PowerShell remotely

Proposed Answer Managed Code and PowerShell remotely

  • Monday, January 23, 2012 2:11 PM
     
     

    Hi there,

    I'll try to reach my Lync servers remotely from my web application. And it is working quite nice... But I have problems with the enable-csuser and disable-csuser. I'll try to use:

                remotePS.Runspace = remoteRunspace;
                remotePS.AddCommand("enable-csuser");
                remotePS.AddParameter("Identity","domain\\userA");

    When I run "invoke"it is working just fine.

    But when I do the following:

                remotePS.Runspace = remoteRunspace;
                remotePS.AddCommand("disable-csuser");
                remotePS.AddParameter("Identity","domain\\userA");

    I get the error:

    Processing data from remote server failed with the following error message: Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.

    Why on earth they have to work differently, basically the same code :-/


    Petri

All Replies

  • Wednesday, February 01, 2012 12:14 PM
    Moderator
     
     Proposed Answer

    Hi Petri,

    To create a PSSession or run commands on a remote computer, by default, the current user must be a member of the Administrators group on the remote computer. Credentials are sometimes required even when the current user is logged on to an account that is a member of the Administrators group. If the current user is a member of the Administrators group on the remote computer, or can provide the credentials of a member of the Administrators group, use the Credential parameter of the New-PSSession, Enter-PSSession or Invoke-Command cmdlets to connect remotely.

    Please refer to this document. Hope helps.


    Noya Liu

    TechNet Community Support