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
Grégory LASSERRE
Grégory LASSERREOP3mo ago
@rubenf do you have an idea for this "issue" ?
rubenf
rubenf3mo ago
I do not know. @Hugo C. any thoughts?
Hugo
Hugo3mo ago
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
Grégory LASSERRE
Grégory LASSERREOP3mo ago
yes, it's a windows server with ActiveDirectory module it's an agent mode worker
Hugo
Hugo3mo ago
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
Grégory LASSERRE
Grégory LASSERREOP2mo ago
Good morning @Hugo C. Seems a little bit better
Grégory LASSERRE
Grégory LASSERREOP2mo ago
No description
Grégory LASSERRE
Grégory LASSERREOP2mo ago
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
Hugo
Hugo2mo ago
Hi it's probably not a windmill issue but might be related to the warning
Grégory LASSERRE
Grégory LASSERREOP2mo ago
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
Grégory LASSERRE
Grégory LASSERREOP2mo ago
No description
Grégory LASSERRE
Grégory LASSERREOP2mo ago
With Verbose, we see that the module is well loaded
No description
Grégory LASSERRE
Grégory LASSERREOP2mo ago
so there is an issue between Powershell output and Windmill
Hugo
Hugo2mo ago
if you run the script in powershell 7 on the server do you see a different output?
Grégory LASSERRE
Grégory LASSERREOP2mo ago
yes, i see all users list
Grégory LASSERRE
Grégory LASSERREOP2mo ago
No description
Grégory LASSERRE
Grégory LASSERREOP2mo ago
does exist a Debug settings for windmill agent that will permit to see what happens (I/O for example)
Grégory LASSERRE
Grégory LASSERREOP2mo ago
another clue : When i force the result format as list or table, we can see the result
No description
Grégory LASSERRE
Grégory LASSERREOP2mo ago
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
No description
Grégory LASSERRE
Grégory LASSERREOP2mo ago
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)
No description
Grégory LASSERRE
Grégory LASSERREOP2mo ago
$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 ActiveDirectory
Hugo
Hugo2mo ago
yes there is a display issue, haven't found a fix yet
Grégory LASSERRE
Grégory LASSERREOP2mo ago
no problem, now we know how to do, but yes, will be great if you can fix at least point 1
Hugo
Hugo2mo ago
yes will fix point 1 as well but it's just a cosmetic error right? it shouldn't be blocking
Grégory LASSERRE
Grégory LASSERREOP2mo ago
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.
Hugo
Hugo2mo ago
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!
Grégory LASSERRE
Grégory LASSERREOP2mo ago
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
Hugo
Hugo4w ago
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.
Grégory LASSERRE
Hello Hugo, many thanks, will test that this week and will send you a feedback.

Did you find this page helpful?