Link to home
Start Free TrialLog in
Avatar of malcolm29
malcolm29Flag for United States of America

asked on

PowerShell ActiveDirectory Module in Windows 8.1 without installing RSAT

I am writing a PS script which I want to run locally on a number of computers (not remotely).  One of the commands in the script is Get-ADComputer, which is found in the ActiveDirectory module.  This module is automatically installed when you install the Remote Server Administration Tools, but I don't want to have to do that on all the computers on which I want to run the script.

Is there any way to import the ActiveDirectory module on Windows 8.1 computers without installing RSAT on the computers?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of malcolm29

ASKER

For the sake of completion, what I really wanted to do was to determine whether the machine on which the script was running was part of a particular OU.  So I used the ADSISearch function to get the adspath and then searched that path to see if it contained the OU called "Public Computers".  If there's a better way to do this, I would appreciate advice as I'm a rookie in PowerShell.

$sString = ((([ADSISearcher]"(&(ObjectCategory=Computer)(name=$env:ComputerName))").FindAll()).properties).adspath
if (Select-String -Pattern "OU=Public Computers" -InputObject $sString) #Search for whether this computer is in the OU called "Public Computers"
    {
    Write-Output "Found it"
    }
else
    {
    Write-Output "NOT Found it"
    }
I think that's fine.  In fact, the query via adsi should be faster than using the AD cmdlet.

One note - although it works, using Select-String as you have isn't really correct.  Better usage is to use the -match operator.
if ($sString -match "OU=Public Computers")

Open in new window

footech, thanks so much for the -match operator!  I agree that it's a better solution!  Thanks again!!!