| J.C.'s profileJ.C.'s spaceBlogNetwork | Help |
|
|
April 20 DSQuery doesn't pipe to DSMove -- Work aroundWhile cleaning up AD for a client, I ran a DSQuery to list all the computers that had been inactive over the last 8 weeks and there were more than 100, so I had to expand the search:
"dsquery computer -inactive 8 -limit 400"
Then I wanted to disable them so I piped that into a DSMod command:
"dsquery computer -inactive 8 -limit 400| dsmod computer -disabled yes"
Wow, this is easy. Now all I have to do is move the disabled computers to a special OU using DSMove. But of course its never that simple. The dsmove command didn't accept the piped in dsquery, so I had to put the phrase in a for loop:
for /f "Tokens=*" %a in ('dsquery computer -disabled -limit 400') do dsmove %a -newparent "OU=Disabled objects,DC=mydomain,DC=com"
If you need to target a specific OU, simply place DN of the OU after the computer:
"dsquery computer "OU=Build,DC=hps,DC=com" -inactive 8 | dsmod computer -disabled yes" Comments (1)
Trackbacks (1)The trackback URL for this entry is: http://jcwarnerii.spaces.live.com/blog/cns!DAFBEF02F4CD141!174.trak Weblogs that reference this entry
|
|
|