Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Read File then Search OU's

$
0
0

I'm using the Quest PowerShell tools.  But this code works perfect.

 

$Inactive_computer_OU = 'OU=InactiveComputers,DC=Acme,DC=com'

$sourceOU = 'Acme.com/FirmComputers'

Set-QADPSSnapinSettings -DefaultSizeLimit 0

$old = (Get-Date).AddDays(-45).ToFileTime()

$ldapFilter = '(pwdLastSet<={0})' -f $old

Get-QADComputer -LdapFilter $ldapFilter -SearchRoot $sourceOU -IncludedProperties pwdLastSet -SizeLimit 9000 | Move-QADObject -NewParentContainer $Inactive_computer_OU

 

I ran this for workstations and it worked.  But now I need to read a .TXT file of Server names and for each server in that list search AD and move the machine.

 

So ......

$ServerList = Get-Content C:\Temp\Servers.txt

 

But in the Get-QADComputer command how do I force -SearchRoot $sourceOU to search a new OU container(s) searching for the $ServerList information?

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles