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 4 years and 1 week 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.
I am just about to add a PowerShell module for a created GUI. The problem is that the module is located as a folder on a server in the network. As a domain admin, I have the option of my user executing a simple Import-Module -Name <path as UNC>. Unfortunately, the users who are supposed to use the GUI are not domain admin. So they run into an error.
So I tried different solution approaches without success. Maybe you can help me with that?
jvierra wrote: ↑Wed Mar 11, 2020 3:52 am
Sorry but regular users cannot remote.
Why are you using a session to import a module from a third server? Just import the module.
Yea, i tried to import the module with the regular command. But there i can not refer some credentials.
So i hoped i can create a session to get the modules.
Mybe this information could help: I use in my tool a serviceuser, which is domain admin. I thought I could load the module from the server with this service user.
Why? Why do you need to import the module into a remote session? You cannot access a third server from a remote session with any account. It is restricted by Windows security.
I already use this for installed Modules on remote server. I can get the module (like ActiveDirectory, Exchange on prem, S4B) from our server. But how i said, this module are already installed.
But i need now to import an Module, which is saved on our data storage in an folder. There are all .dll and psm1 files. But i can get this folder only with domain admin
That is correct. Only a domain admin can use remoting but, even with \remoting you cannot access a UNC path.
#1 will work with admin credentials.
#2 won't work at all.
Thank you for the information.
I found now my issue. I need write the full path till the .psd1-File. Strangely the normal Import-Module works without the full path.
But i've now a new question. Is it possible to make the import faster?
I mean, when i use Import-Module -Name ... it taks only 2,5 sec.
When I use Import-Module -Name ... -Session ... it takes 17 sec.
I use the .psd1-File with both variants
It's fixed now. Was an issue from our network. It runs now in few seconds.
But i have an other question to pssession. If i create a session with New-PSSession then i can see a new process on the remote computer called "wsmprovhost.exe". This can opend only 5 times by default of winrm (MaxShellsPerUser). Is it possible to create a new option-/configurationfile with a higher count of MaxShellsPerUser and use this with New-PSSession (SessionOption / ConfigurationOption) ?
Why would you need more than one session per user. It sounds like you are creating a new session for each command. That is not how to use remoting. create a session once and reuse it. That is what a session is for.
To increase the number of session you would need to reconfigure the remote systems and restart WinRM.
First review the design and implementation of your script to see why you are using multiple sessions and if it is necessary.
For maintaining a session we can create a remote disconnected session and multiple processes can connect to the remote session and submit scripts then disconnect. This allows one persisted session that can run across local restarts and can be reused across local user logons.
This topic is 4 years and 1 week 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.