Remote agent + Powershell + ActiveDirectory module
Hello.
We try to run ActiveDirectory Powershell commandlets using a remote agent installed on a windows server.
Locally, commandlets works fine.
From Windmill Powershell script, set up to use the windows remote agent , active directory commandlet not works, as ActiveDirectory module is not imported (Try to import it explicitly in the script).
Do you know if there is a tips ?
Best regards.
29 Replies
@rubenf do you have an idea for this "issue" ?
I do not know. @Hugo C. any thoughts?
Let me check
when you say remote agent, are you saying you have a windmill worker on a windows server?
because ActiveDirectory is not supported on linux powershell
yes, it's a windows server with ActiveDirectory module
it's an agent mode worker
can you try with "Import-Module ActiveDirectory -UseWindowsPowershell"? you might see an error when windmill tries to install it but the script should still run
Good morning @Hugo C.
Seems a little bit better

the module seems to be loaded but no results is display
it's like the pwsh runspace created don't return the result to windmill
Hi
it's probably not a windmill issue but might be related to the warning
this warning is normal, it's because the ActiveDirectory module is written for PS v5 but compatible with PS v7
we got the same when running the same script locally on the same server
a Get-Module -All -ListAvailable from windmill display ActiveDirectory Module

With Verbose, we see that the module is well loaded

so there is an issue between Powershell output and Windmill
if you run the script in powershell 7 on the server do you see a different output?
yes, i see all users list

does exist a Debug settings for windmill agent that will permit to see what happens (I/O for example)
another clue : When i force the result format as list or table, we can see the result

so there is 2 issue : 1- Windmill agent try to install the ActiveDirectory module because he don't see it (red error) 2- the default output of the commandlet is not return correctly + we see RunspaceId table header from invoke-command mixed with Get-ADUser default output table format

for point 1 : maybe you can add step Check if module exist locally
"ActiveDirectory" -in (Get-Module -All -ListAvailable).Name
after cache check in order to avoid the installation attempt ? Generally, people will not used a module not already install in Powershell)
$ModuleName -in (Get-Module -All -ListAvailable).Name
i tested with one of our custom module, we got the same attempt to install the module, but as it's not available on PSGallery, installation failed but we can use the module commandlet. But fyi, we don't have display issue as with ActiveDirectoryyes there is a display issue, haven't found a fix yet
no problem, now we know how to do, but yes, will be great if you can fix at least point 1
yes will fix point 1 as well but it's just a cosmetic error right? it shouldn't be blocking
not blocking but it took time (5-10 sec) to attempt to install a PS module that is not published to public repository like PSGallery + yes cometic error message. Globally, there is no sense to attempt to install a module that is already installed 😉 I'm quite sure you will find the fix 🙂 if you need someone to test, you can contact me, i will help with pleasure.
Hi @Grégory LASSERRE fix for the first issue should be merged and released soon
for the second issue, we don't have the bandwidth right now to setup AD to reproduce so will delay the fix for now
however, if you can reproduce with another cmdlet that doesn't require any setup, let me know!
Hi @Hugo C. Many thanks, will try the fix as soon as possible
i check for point 2
Basic commandlets seems ok, i think it is only with ActiveDirectory module
Hi @Grégory LASSERRE, we've fixed an issue as of v1.513.0 which prevented ActiveDirectory to load natively in Powershell 7. You won't have to use the -useWindowsPowershell option anymore and it might also solve the display issue you had.
Hello Hugo, many thanks, will test that this week and will send you a feedback.