Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

How go generate a pipeline from a script?

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 07-02-2008   #1 (permalink)
RobertZ
Guest


 

How go generate a pipeline from a script?

Hello,

I've been trying to generate a list of AD accounts from a script and export
that to a pipeline so I can create a set of script-lets to manage data from
AD. I haven't been able to figure out how to take the list of accounts
generated from the script and push them out to the pipleline to I can pipe
them into another script.

Here's the code from my test script. Anyone have any ideas how move the
data to the pipe line?

Thanks,
Bob


# Connect to AD
$strNewco = "LDAP://DC=newco;DC=local"
$objNewco = New-Object DirectoryServices.DirectoryEntry $strNewco

# Create a selector for AD
$objSelect = New-Object DirectoryServices.DirectorySearcher
$objSelect.SearchRoot = $objNewco

# Collect all the matching objects
$objHosts = $objSelect.findall() |
Where-Object {$_.properties.objectcategory -match "CN=Person"}




My System SpecsSystem Spec
Old 07-03-2008   #2 (permalink)
sapienscripter's Avatar
Scripting Guru


Join Date: Jun 2008
Vista Ultimate 32bit
Syracuse, NY
 
Rep Power: 8
sapienscripter has a spectacular aura aboutsapienscripter has a spectacular aura aboutsapienscripter has a spectacular aura about
  sapienscripter is offline

Re: How go generate a pipeline from a script?

I think the issue is that your searcher object is failing. You should use a filter for the searcher object. It will be more efficient than getting all objects and then piping to Where. Here's an example:

$searcher=New-object DirectoryServices.DirectorySearcher
$searcher.SearchRoot="LDAP://OU=Testing,DC=jdhitsolutions,DC=local"
$searcher.Filter="(&(objectcategory=person)(objectclass=user))"
$users=$searcher.FindAll()
#display the number of users
Write-Host "There are "$users.count"users in this domain."
#display each user's distinguishedname
foreach ($user in $users) {
Write-Host $user.properties.distinguishedname
write-host $user.Properties.description
}
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Generate script oyvind VB Script 1 05-20-2008 09:05 AM
Using WPF to Generate an Image Tem Avalon 5 11-15-2007 11:22 AM
Generate an Image with WPF Tem Avalon 0 10-31-2007 04:50 PM
Bug spreading pipeline commands across multiple lines in a script Keith Hill [MVP] PowerShell 8 05-03-2007 10:17 PM
Script to generate help for all cmdlets George Davis PowerShell 0 03-02-2007 07:43 AM


Update your Vista Drivers Update Your Drivers Now!!

Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008