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?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Take a look at this post.

Although a lot of it talks about Win7, the methods it describes for using the AD cmdlets on a remote machine are can be used on Win8.1.  You could use either the Import-Session or Import-Module commands.

Another option is to not use Get-ADComputer at all, and instead use the [adsisearcher] type accelerator.  Here's a very basic example of its usage.

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
malcolm29Author Commented:
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"
    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

malcolm29Author Commented:
footech, thanks so much for the -match operator!  I agree that it's a better solution!  Thanks again!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.