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. How to share a server connection between different powershell runspaces in c# on a web application

How to share a server connection between different powershell runspaces in c# on a web application

Scheduled Pinned Locked Moved C#
helpcsharpcomsysadminwindows-admin
3 Posts 2 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.
  • T Offline
    T Offline
    tasoss
    wrote on last edited by
    #1

    I'm working on a web project and I need to do the following. I want to run different cmdlets on a VMM server (https://technet.microsoft.com/en-us/library/dn246490.aspx). Right now when I need to run a cmdlet I open a runspace, connect to the VMM server using this cmdlet: https://technet.microsoft.com/library/jj613273(v=sc.20).aspx and then disconnect. The problem is that disconnect doesn't work as expected and so I have memory leaks. The solution is to use one connection to the server,using the previous cmdlet, and then perform all other actions via this connection (on new runspaces). So I need to share the fact that I'm connected on each new runspace I open. I suppose I should use the RunspacePool class and maybe the InitialSessionState member but I'm not sure. Thanks for your help! ps: http://stackoverflow.com/questions/28254778/how-to-share-a-server-connection-between-different-powershell-runspaces-in-c-sha[^]

    L 1 Reply Last reply
    0
    • T tasoss

      I'm working on a web project and I need to do the following. I want to run different cmdlets on a VMM server (https://technet.microsoft.com/en-us/library/dn246490.aspx). Right now when I need to run a cmdlet I open a runspace, connect to the VMM server using this cmdlet: https://technet.microsoft.com/library/jj613273(v=sc.20).aspx and then disconnect. The problem is that disconnect doesn't work as expected and so I have memory leaks. The solution is to use one connection to the server,using the previous cmdlet, and then perform all other actions via this connection (on new runspaces). So I need to share the fact that I'm connected on each new runspace I open. I suppose I should use the RunspacePool class and maybe the InitialSessionState member but I'm not sure. Thanks for your help! ps: http://stackoverflow.com/questions/28254778/how-to-share-a-server-connection-between-different-powershell-runspaces-in-c-sha[^]

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Does this have anything to do with C#?

      T 1 Reply Last reply
      0
      • L Lost User

        Does this have anything to do with C#?

        T Offline
        T Offline
        tasoss
        wrote on last edited by
        #3

        Of course.Runspaces and code is running in C# using System.Management.Automation. Thanks for replying!

        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