Pssession 'persistant'

This topic contains 7 replies, has 2 voices, and was last updated by  Dan Potter 1 year, 10 months ago.

  • Author
  • #51607

    Vincent Nunnari

    Hi Guys,

    Into one "command prompt" :
    I'am connecting my local computer to a MICROSOFT EXCHANGE SERVER by doing a "New-pssession"
    Then, iam getting all the COMMANDS on the local machine by doing a "Import-pssession".
    So, i can use all the CMDLET to interact with MICROSOFT EXCHANGE.
    Also, if iam doing a "get-pssession" i can the PSSESSION is returned with few informations.

    The problem is the following !
    i open a new "command prompt" :
    I try to catch the existing PSSESSION by doing a "get-pssession".
    (but nothing is retured)

    Why? Is there any possibility to catch an existing PSSESSION by opening a new powershell process?
    hope you can help

  • #51612

    Dan Potter

    If you're talking on-prem exchange than just install the module.

    For cloud use export-pssession to save the cmdlets locally. I would get in the habit of updating the module regularly though, Microsoft isn't going to let you know when they change.

  • #51615

    Dan Potter

    Export-PSSession $Session -OutputModule ExchangeOnline -Force -AllowClobber

  • #51626

    Vincent Nunnari

    This is how i'am connecting :
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://xxxxxxxxxxx.domain/powershell/ -Authentication Kerberos -Credential $mycreds -Name $sessionName

    Let me explain my project :
    – A PHP WEB application running on a WINDOWS APACHE webserver is executing a local powershell script each time you click on a button. This script is connecting to EXCHANGE and can also create/delete/modify a mailbox into exchange.
    So, each time a button is clicked, a new POWERSHELL process is launched, and a new connexion between the local server and the Exchange server is done. This is bad, and too slow... i want the script to catch an existant connexion so we do not have to connect again and to load all the CMDLET..

    How can i do?

  • #51632

    Vincent Nunnari

    Also, this is "on premise" exchange.
    What is the module you're talking about?

  • #51662

    Dan Potter

    Get the exchange installation files and install the management tools only.

  • #51708

    Vincent Nunnari

    I did it.
    I still cannot retrieve a PSSESSION from another prompt.
    But thanks to you, i don't not need anymore to import all the MSEXCH CMDLET, it's a powerfull gain of time.
    Thanks a lot! 🙂

  • #51745

    Dan Potter

    Yep, it's called implicit remoting.

    Very helpful to know what the difference is especially if you start working in the cloud.

You must be logged in to reply to this topic.