Dannly
Dannly5mo ago

Sourcing PowerShell scripts from other PowerShell scripts

There's a PowerShell script A, created using Windmill's web IDE, and another PowerShell script B, both in the same folder. There are some functions defined in A that I wish to use in B. However, I can't seem to properly source them (PowerShell can't find the module file). I've tried Import-Module ./A.ps1, Import-Module /f/folder/A, ./A.ps1, Import-Module /f/folder/A.ps1, to no avail. Using a similar notation in Python, however, seems to work perfectly fine, suggesting that it's some issue particular to PowerShell. Any ideas? Thank you in advance!
7 Replies
rubenf
rubenf5mo ago
We did a lot of engineering for Python that we didn't for Powershell so it's expected that it doesn't work
Dannly
Dannly5mo ago
thank you for the response! would you know any way around this?
rubenf
rubenf5mo ago
Unfortunately not
Dannly
Dannly5mo ago
I see! tysm for your time :)
thomas-sh4u
thomas-sh4u5w ago
hi, import-module is not running? or can i use this cmd? your template suggest this. >> Import-Module MyModule Import-Module WindmillClient Connect-Windmill Get-WindmillVariable -Path 'u/user/foo' the last line of the stdout is the return value << is it possible to register an own PowerShell Repo, like: Register-PSRepository -Name "PrivatesRepo" -SourceLocation "https://IhrNuGetServer/nuget" -InstallationPolicy Trusted And then use: Install-Module -Name IhrModul -Repository PrivatesRepo ?
rubenf
rubenf5w ago
Not sure, maybe not
thomas-sh4u
thomas-sh4u5w ago
I hav just tested it with an external Repository other than PSGallery and it works so far.