Import-module in a domain shared folder when logged on to a local system account

40 Views Asked by At

How can I import a module that is located on a domain shared folder from a local system account on any computer. The module is a custom one Ive made that I need for my script to run. Everything works fine when signed into a domain account as it can reach the folder.

Is there a way that local accounts can be prompted for credentials to get to the share but domain accounts will not?
Alternatively is there a way to setup or share or something similar that both a domain and local account could get to with needing a password. My research so far tells me the second option is not possible with a shared folder.

The two ideas I have is hosting the file on an FTP or onedrive and using wget to download the file each time. Also using try and catching when import-module fails to find the module and then using new-psdrive -credential to map to the share folder. Is there a more eloquent solution that I'm over looking.

Here is my code:

$printername = "Some ricoh printer"
$IP = "8.8.8.8"
Import-Module -Force -Name "\\path\to\the\module\Install-printer.psm1"
Install-printer $Printername $IP
0

There are 0 best solutions below