|
| |||||||||
| Tags: dsmove, dsquery, pipe |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| dsquery pipe to dsmove dsquery computer cn=computers,dc=na,dc=zzz,dc=com -name xxxtest*|dsmove -newparent "ou=usa,ou=il,ou=southside,ou=computers,dc=na,dc=z zz,dc=com" As you can see i am trying to pipe the results of the dsquery to a dsmove command. It's not working. The dsquery command works fine on its own. It finds and returns the expected results. But when I try to pipe the dsquery to a dsmove, it says that the computer object cannot be found. What am I doing wrong here. Thanks in advance for any help. dfl: WS2003 ffl: W2000 |
|
#2
| |||
| |||
| Re: dsquery pipe to dsmove
The proper context for dsmove is dsmove.exe "CN=%1,OU=aaa,DC=AA,DC=BB,DC=com" -newparent OU=bbb,DC=AA,dc=BB,dc=com |
|
#3
| |||
| |||
| Re: dsquery pipe to dsmove
On Tue, 6 Sep 2005 07:58:35 -0700, "dpav" <dpav@discussions.microsoft.com> wrote: >i am running the following dsquery on a DC in my domain. > >dsquery computer cn=computers,dc=na,dc=zzz,dc=com -name xxxtest*|dsmove >-newparent "ou=usa,ou=il,ou=southside,ou=computers,dc=na,dc=z zz,dc=com" > >As you can see i am trying to pipe the results of the dsquery to a dsmove >command. >It's not working. The dsquery command works fine on its own. It finds and >returns the expected results. But when I try to pipe the dsquery to a >dsmove, it says that the computer object cannot be found. > >What am I doing wrong here. Thanks in advance for any help. > >dfl: WS2003 >ffl: W2000 Add a space before the redirection: dsquery computer cn=computers,dc=na,dc=zzz,dc=com -name xxxtest* |dsmove -newparent "ou=usa,ou=il,ou=southside,ou=computers,dc=na,dc=z zz,dc=com" Jerold Schulman Windows Server MVP JSI, Inc. http://www.jsiinc.com http://www.jsifaq.com |
|
#4
| |||
| |||
| Re: dsquery pipe to dsmove
in the cmd string you posted, you are stating the current location of the object you want to move and then stating the new location. i thought the purpose of the pipe function was to take the results from a dsquery and automatically apply them to the dsmove. i thought with the pipe function you don't need to state the current location of the object. "rwh@rodharrison.com" wrote: > The proper context for dsmove is > > dsmove.exe "CN=%1,OU=aaa,DC=AA,DC=BB,DC=com" -newparent > OU=bbb,DC=AA,dc=BB,dc=com > > |
|
#5
| |||
| |||
| Re: dsquery pipe to dsmove
thanks for your help folks. i finally figured out the problem. my listing of the OU tree was backwards in the dsmove -newparent switch. i guess i was confused because this is the first time i've done a pipe between DSxxx commands. i thought something was wrong with the pipe function, but that was not the case. it's quite awesome when it works! A very powerful set of tools that I am sure that I will use a lot. here's where i was going wrong: #original cmd dsquery computer cn=computers,dc=na,dc=zzz,dc=com -name xxxtest*|dsmove -newparent "ou=usa,ou=il,ou=southside,ou=computers,dc=na,dc=z zz,dc=com" #corrected cmd dsquery computer cn=computers,dc=na,dc=zzz,dc=com -name xxxtest*|dsmove -newparent ou=computers,ou=soutside,ou=il,ou=usa,dc=na,dc=zzz ,dc=com notice the reversal of the OU structure after the -newparent switch in the corrected cmd. In order to not make this same mistake again in the future I need to remember that the OU structure in a cmd starts at the lowest level and works it's way up to the domain name (DC=...) in other words: OU=grandchild,OU=child,OU=parent,DC=zzz,DC=com So with this command I'm able to tailor a specific query of the directory for objects (via dsquery) and then move the results of the query to a location i specify (via dsmove). In this instance all of our computers are in the computers container. i want to move those computer objects from the computers container to an OU based on physical locations. Thus all of the computer objects named *STL* should go to the computers OU in the St. Louis OU. Rather than do it by hand, I can automate it with this cmd. Hope this helps someone. -dave |
|
#6
| |||
| |||
| re:dsquery pipe to dsmove
I'm a bit confused, hope you can clarify. If the aforementioned script is run, it will move a single machine matching the specified query. But if there are several machines in the container, my findings are, that the script chokes, returns an error, and moves nothing. you say, that you would use the command to move scores of machines into specific OU's (which coincidentally is what i'm looking for) using the command. But would it then be contained in a script with a looping structure, or how would it be done?? Regards |
|
#7
| |||
| |||
| re:dsquery pipe to dsmove
fwe: you are exactly right. i am searching for the same answer that you are. i was able to make the script run for only one machine. i need it to run for scores of machines. i have been reading how to loop this sort of script and if/when i figure it out, i will post the instructions. please do the same on your end. |
|
#8
| |||
| |||
| re:dsquery pipe to dsmove
OK, i went with a different approach. scripted the thing to death. i'm pasting the script below, then you can modify to fit your needs. Then you can either run the script at need, or set up a scheduled task. On Error Resume Next Const ADS_SCOPE_SUBTREE = 2 Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConnection objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCommand.CommandText = _ "SELECT ADsPath FROM 'LDAP://cn=computers,dc=undervisning,dc=local' WHERE objectCategory='computer' " & _ "AND name = 'hg*'" Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Do Until objRecordSet.EOF strADsPath = objRecordSet.Fields("ADsPath").Value Set objOU = GetObject("LDAP://OU=computere,OU=HG,OU=skoler,dc=undervisning,dc=lo cal") intReturn = objOU.MoveHere(strADsPath, vbNullString) objRecordSet.MoveNext Loop --- the rest of you can have at it all you want.... scriptning VB is not even a fourth language.. ;-) |
|
#9
| |||
| |||
| re:dsquery pipe to dsmove
your scripting chops are solid. nice job. this whole process has made me realize that i need to focus on learning VBScript for the next few months. I'll be spending lots of time in the script center on technet. i ended up doing a cut and paste job in excel so that each line in excel was a dsmove command. It worked for me and got the job done but i felt like a technological wimp. Must learn scripting. |
|
#10
| |||
| |||
| Another aproach
I know almost nothing about vbscript but I love my .bat files. Here's what I came up with: --start-- @echo off :again dsquery computer -limit 1 cn=computers,DC=vprodemo | dsmove -new parent ou=validation,dc=vprodemo if errorlevel 0 goto again --end-- this moves the computer accounts one at a time. Once they are all moved dsmove fails and the .bat ends. |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "dsquery pipe to dsmove" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to use pipe between programs in C? | Harpreet Gaur | Software Development | 5 | 4 Weeks Ago 10:13 AM |
| USB:Pipe not Opening! | sunwins | Software Development | 2 | 27-05-2009 08:33 AM |
| dsmove failed | JC | Active Directory | 9 | 20-01-2009 01:48 AM |
| Named Pipe lsass.exe | Marbles | Windows Security | 7 | 28-05-2007 04:31 AM |
| MSI P35 Platinum - Circus Pipe | dr.nil | Motherboard Processor & RAM | 0 | 04-05-2007 01:59 AM |