ansible-collections / microsoft.ad

Ansible collection for Active Directory management
GNU General Public License v3.0
39 stars 22 forks source link

Error: The term 'Get-ADRootDSE' is not recognized as the name of a cmdlet #112

Closed mrdevops100 closed 2 months ago

mrdevops100 commented 5 months ago

Hi Team,

When I m using any of the examples I get the following error.

I also installed the ActiveDirectory module on AD but still no luck.

The term 'Get-ADRootDSE' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

mrdevops100 commented 5 months ago

Name: microsoft.ad.group module

jborean93 commented 5 months ago

When you say you've installed the ActiveDirectory module on AD do you mean the domain controller. Is this the same host as what you are targeting in Ansible or a different host? Just to be clear the ActiveDirectory module requirement is one for the Windows host Ansible is talking to not the domain controller.

Can you do the following as a test to see if it can import the module on the same target host.

- ansible.windows.win_shell: Import-Module ActiveDirectory -ErrorAction Stop
chronicc commented 3 months ago

FYI: I saw the same error message and tried the test from @jborean93. The commandline spit out this:

skipping: [ws2022-1] => {
    "changed": false,
    "msg": "remote module does not support check mode"
}

It's when I realized that I was setting up the ad domain and trying to create the user both in check mode. Hence the ad windows feature was not present on the machine. Without check mode the error is gone.

jborean93 commented 2 months ago

Thanks for clarifying, it sounds like we could probably improve the check mode support in these modules to handle this scenario.

jborean93 commented 2 months ago

It looks like we already have a check after installing the features for a domain host. If the problem exists because we are setting up a domain and configuring a user in check mode then the error would be expected. Trying to do the same work but without the module present is not a viable and maintainable option so I don't think we have anything we can do here. If there is another problem unrelated to check mode then please open a new issue with the details and example of what was run and we can investigate it further from there.