PowerShell Session

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
bhnuser
Posts: 48
Last visit: Tue Nov 21, 2023 10:33 pm

PowerShell Session

Post by bhnuser »

Hello everybody,

i have a qustion to the PowerShell Sessions and can not find any answere to my problem.
I want to write a script that opens a PSSession to our exchange server to get the cmdlts from the exchange shell.
Unfortunately the pssession opens so slowly that i want to know how i can get it faster or how i can save the session on my computer to start it faster in a next scriptrun?
Is it possible? Or is there an other way?

Best regards
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: PowerShell Session

Post by jvierra »

Not really a scripting issue. The speed is dependent on the server. If it is very busy or low on resources it can be very slow.

There is no way to persist a session.

How long does Enter-PsSession take? 10 seconds is not abnormal.
User avatar
bhnuser
Posts: 48
Last visit: Tue Nov 21, 2023 10:33 pm

Re: PowerShell Session

Post by bhnuser »

Okay, thats sounds not so good. But asking costs nothing.
I've tried it now and it takes about 5 seconds to load the session and commands. Its not so long but how i can manage it, when i put this script in a task schedule and run this all 5 minutes? The script would opens all 5 minutes a new session or is there a way to save it?
I also think about this problem because I have a script that builds up three sessions in a row (Exchange, AD, Skype). With all three sessions the scripts starts 45-60 seconds.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: PowerShell Session

Post by jvierra »

I cannot really understand what you are asking. Your English is a bit unclear.
User avatar
bhnuser
Posts: 48
Last visit: Tue Nov 21, 2023 10:33 pm

Re: PowerShell Session

Post by bhnuser »

What I want to say is that i will implement my script into a task scheduler that run every 5 minutes. This script will open each run a new session to the exchange. The question is whether i can save with the first run the session that my script doesnt open every time a new session to save time at the startup.

(This would help me also when I start my next script where i need to open three different sessions [AD, Exchange, Skype])
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: PowerShell Session

Post by jvierra »

And the answer is no.
This topic is 5 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked