In my webpage I wanted to change the password of some accounts. So I got a script powershell. In this one I need to import the module Active-Directory to change the password of accounts. My server is on CentOS, so I install powershell on it. But when I do : Import-Module ActiveDirectory, the console return ‘Import-Module: The specified module ‘ActiveDirectory’ was not loaded because no valid module file was found in any module directory.’
Thanks
2
Answers
The short answer is… you can’t. The centos platform version of .net does not support the
[System.DirectoryServices]
types/classes yet, and I doubt they’ll be migrated over soon. Powershell’sActiveDirectory
module requires those to run, so this cannot currently be done in Powershell:An alternative is using ldap commands from centos packages. Here’s some examples:
Changing a password for an AD user when you don’t know the current one is more complicated and requires a much more specific configuration on your machine, but can be done with just
passwd
if:chpass_provider=ad
inetcsssdsssd.conf
Otherwise, the best option on linux is through python’s ldap module. I’m not as familiar with it, so I’m only linking working example code from a similar question: Modifying Active Directory Passwords via ldapmodify
I know the thread is very old but the alternative is to send invoke requests to your domain controller/other windows server.
Invoke-Command -ComputerName Server01 -Credential Domain01User01 -ScriptBlock { Get-Culture }