Search code examples
windowsperlpowershellactive-directorycommand-prompt

Active Directory commands work under PowerShell but not with command prompt


Active Directory commands issued by my Perl script are working from PowerShell but not when I run it from the command prompt.

Is there any way to run these commands from the command prompt?

The commands that I am using are dsadd, dsrm, dsmod etc.


Solution

  • The problem is almost certainly that the PATH environment variable doesn't include the directory where the Active Directory tools are stored

    To find where they are on your system, under PowerShell enter

    where.exe dsadd
    

    This will show the full path to dsadd

    If you just use where, as normal, then PowerShell will use the where cmdlet which is an entirely different thing.

    If you then modify the PATH variable on the command prompt to include the path revealed above, Active Directory commands will work just as they do on PowerShell