This topic contains 4 replies, has 3 voices, and was last updated by
June 28, 2018 at 6:54 pm #103547
Just wondering as to how I can get the following accomplished.
I have a $profile that consist of functions.
The functions are that of PSSessions to our messaging environments
What I would like is to be able to type in the pre-loaded function say for PSSession to Exchange and have it launch in a Powershell window so that I can have separate windows.
Currently I am having to open individual PS instances and running the function depending on what I want to establish connection to.
Any help would be appreciated. Thanks in advance
June 28, 2018 at 7:07 pm #103550KeymasterTopics: 13Replies: 4872Points: 1,811Rank: Community Hero
That will be tricky.
You'll need to have your script run PowerShell.exe to start a new process, and pass a command line switch to have the new process run whatever it is you want running in the new window.
PowerShell isn't a multi-window application like Word; each window is a fresh standalone process.
June 28, 2018 at 8:11 pm #103558
Wow, Wasn't expecting an answer from the Powershell Legend himself.
I will research further but I'm guessing the command line switch will be some sort of bat file to execute the commands? Possibly not in the form of a function but instead a .ps1 file.
June 29, 2018 at 1:39 pm #103585ParticipantTopics: 23Replies: 139Points: 260Rank: Contributor
here is a snippet that i use (i need this script to be called from a parent script to execute a process that needs to run as a seperate user instance)
#script must contain fqdn path to ps1 file $script = "" $commandLine = "-noexit & $script" $credential = Get-Credential Start-Process powershell.exe -Credential $credential -ArgumentList $commandline
July 4, 2018 at 8:43 am #103876
The topic ‘Launch function in new Powershell window’ is closed to new replies.