Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Server 2012 remote powershell with C#

Server 2012 remote powershell with C#

Scheduled Pinned Locked Moved C#
csharpcomsysadminwindows-adminhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JD86
    wrote on last edited by
    #1

    I'm having the toughest time finding / figuring out how to get remote powershell working with 2012. Currently this is my code:

    private void OpenRunspace(string username, string password, ref Runspace remoteRunspace)
    {
    // Convert plain text password to secure string
    SecureString pass = new SecureString();
    foreach (char c in password.ToCharArray())
    {
    pass.AppendChar(c);
    }

            PSCredential psc = new PSCredential(username, pass);
            WSManConnectionInfo wmci = new WSManConnectionInfo(new Uri("http://" + ConfigurationManager.AppSettings\["ExchangeServer"\] + "/powershell"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", psc);
            wmci.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
            wmci.ProxyAuthentication = AuthenticationMechanism.Negotiate;
    
            wmci.SkipCACheck = true;
            wmci.SkipCNCheck = true;
            remoteRunspace = RunspaceFactory.CreateRunspace(wmci);
        }
    

    The error I keep getting is "Access is denied". I've verified the credentials I am passign to it is part of the REmote Management Users group on that local server, ran the Set-User "Administrator" powershell enabled command in Exchange 2013 What else am I missing here?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups