Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - AD Changes and Looping

Reply
 
Old 07-03-2006   #1 (permalink)


 
 

AD Changes and Looping

Hey guys, love the site. Finally, there's a fine community of Powershellers that can support this developing product! Inspired in part by MOW's fine blogs about Active Directory, I have a question about scripting for AD. Is it possible to search through a specific CN in my AD, change all of the users's TerminalservicesHomeDrive and TerminalservicesHomeDirectory who reside in that CN, and then migrate those home directories to a new location using something like Robocopy? I have a script that does this in VB, but I would like to code one in MSH. Keep up the good stuff, guys.

My System SpecsSystem Spec
Old 07-03-2006   #2 (permalink)
Daren Daigle


 
 

RE: AD Changes and Looping

Yes, thanks to some help, i did NEARLY the same thing to enable my
TerminalServer bit for all users (since i use GPO to restrict terminal server
access)

(Begin Code)
$root = New-Object System.DirectoryServices.DirectoryEntry
@($root.get_children().find('ou=users,ou=org').get_children()) |
foreach-object {$_.InvokeSet("AllowLogon",1) ; $_.CommitChanges }
(End Code)

In your case, its .InvokeSet("TerminalServicesHomeDrive,"z:\Dir")

Also, you might also add another piece or two to also migrate the data from
one directory to another in the form

Object search | foreach-object {var =propertyget ; propertyset; commit ;
copy filefrom var to new location }

Or some such logical view. Notice you need to get the previous location in
order to get your to and from locations. It's not a complete answer but i
bet you can fill in the blanks from here.

Daren Daigle
Boys and Girls Clubs of America
(New convert to Power(ful)Shell

"JMacWildFan06" wrote:

>
> Hey guys, love the site. Finally, there's a fine community of
> Powershellers that can support this developing product! Inspired in
> part by MOW's fine blogs about Active Directory, I have a question
> about scripting for AD. Is it possible to search through a specific CN
> in my AD, change all of the users's TerminalservicesHomeDrive and
> TerminalservicesHomeDirectory who reside in that CN, and then migrate
> those home directories to a new location using something like Robocopy?
> I have a script that does this in VB, but I would like to code one in
> MSH. Keep up the good stuff, guys.
>
>
> --
> JMacWildFan06
> ------------------------------------------------------------------------
> JMacWildFan06's Profile: http://forums.yourdomain.com.au/member.php?userid=86
> View this thread: http://forums.yourdomain.com.au/showthread.php?t=9457
>
>

My System SpecsSystem Spec
Old 07-03-2006   #3 (permalink)
/\\/\\o\\/\\/


 
 

Re: AD Changes and Looping

@ JMacWildFan06,

Nice to here that my blog got you going,

I will post the 3th part tomorrow, (a bit later as it is Hot in the
Netherlands for a change ;-) and had a dinner tonight)it will talk about
the Terminal Services properties also, and in following part I also will
talk about the DirectorySearcher for if you need more granular control
about the Users affected as a whole OU.
I already have some samples :

http://mow001.blogspot.com/2006/03/w...-part-one.html
http://mow001.blogspot.com/2006/04/l...-in-monad.html

and here you can find a good entry using a directorysearcher

http://pcmusings.spaces.msn.com/blog/cns!42B71883C19FDDAE!263.entry?_c11_blogpart_blogpart=blogview&_c=blogpart#permalink

I will look into a example that makes also the directories
that and Darens example should get you going.

@ Daren Daigle

nice example.

Greetings /\/\o\/\/


Daren Daigle wrote:
> Yes, thanks to some help, i did NEARLY the same thing to enable my
> TerminalServer bit for all users (since i use GPO to restrict terminal server
> access)
>
> (Begin Code)
> $root = New-Object System.DirectoryServices.DirectoryEntry
> @($root.get_children().find('ou=users,ou=org').get_children()) |
> foreach-object {$_.InvokeSet("AllowLogon",1) ; $_.CommitChanges }
> (End Code)
>
> In your case, its .InvokeSet("TerminalServicesHomeDrive,"z:\Dir")
>
> Also, you might also add another piece or two to also migrate the data from
> one directory to another in the form
>
> Object search | foreach-object {var =propertyget ; propertyset; commit ;
> copy filefrom var to new location }
>
> Or some such logical view. Notice you need to get the previous location in
> order to get your to and from locations. It's not a complete answer but i
> bet you can fill in the blanks from here.
>
> Daren Daigle
> Boys and Girls Clubs of America
> (New convert to Power(ful)Shell
>
> "JMacWildFan06" wrote:
>
>> Hey guys, love the site. Finally, there's a fine community of
>> Powershellers that can support this developing product! Inspired in
>> part by MOW's fine blogs about Active Directory, I have a question
>> about scripting for AD. Is it possible to search through a specific CN
>> in my AD, change all of the users's TerminalservicesHomeDrive and
>> TerminalservicesHomeDirectory who reside in that CN, and then migrate
>> those home directories to a new location using something like Robocopy?
>> I have a script that does this in VB, but I would like to code one in
>> MSH. Keep up the good stuff, guys.
>>
>>
>> --
>> JMacWildFan06
>> ------------------------------------------------------------------------
>> JMacWildFan06's Profile: http://forums.yourdomain.com.au/member.php?userid=86
>> View this thread: http://forums.yourdomain.com.au/showthread.php?t=9457
>>
>>

My System SpecsSystem Spec
Old 07-05-2006   #4 (permalink)


 
 

Nice example there, Daren. I've had that in my MSH favorites for awhile because it was nice and detailed for what you set out to do. /\/\o\/\/, keep up the good posts on the blog. Your site is probably the best resource for MSH I've seen so far. It's given me the most information to make some real fascinating and effective scripts with MSH.

I've got a follow up question to my original post, with some more detail and procedural stuff. I have this group in AD, which is: LDAP://cn=GG_Migration_Users,ou=App_Groups,dc=subxxx,dc=xxx,dc=com

This CN group contains all of the users that need to have their TermServices profile paths and home drives changed. The old path looks like: \\server_old\program_path\[userid] and the new path would be: \\windows2k3box\[userid].

Obviously, both the old and the new path are similar in the fact that the UNC path routes to a folder with their user ID as the name. Is it possible to search through this CN group of users to determine which users still have the old path (as there is a mix of new and old paths), then change the TermServ home directory path for only those users?

Quote  Quote: Originally Posted by /\\/\\o\\/\\/
@ JMacWildFan06,

Nice to here that my blog got you going,

I will post the 3th part tomorrow, (a bit later as it is Hot in the
Netherlands for a change ;-) and had a dinner tonight)it will talk about
the Terminal Services properties also, and in following part I also will
talk about the DirectorySearcher for if you need more granular control
about the Users affected as a whole OU.
I already have some samples :

http://mow001.blogspot.com/2006/03/w...-part-one.html
http://mow001.blogspot.com/2006/04/l...-in-monad.html

and here you can find a good entry using a directorysearcher

http://pcmusings.spaces.msn.com/blog/cns!42B71883C19FDDAE!263.entry?_c11_blogpart_blogpart=blogview&_c=blogpart#permalink

I will look into a example that makes also the directories
that and Darens example should get you going.

@ Daren Daigle

nice example.

Greetings /\/\o\/\/


Daren Daigle wrote:
> Yes, thanks to some help, i did NEARLY the same thing to enable my
> TerminalServer bit for all users (since i use GPO to restrict terminal server
> access)
>
> (Begin Code)
> $root = New-Object System.DirectoryServices.DirectoryEntry
> @($root.get_children().find('ou=users,ou=org').get_children()) |
> foreach-object {$_.InvokeSet("AllowLogon",1) ; $_.CommitChanges }
> (End Code)
>
> In your case, its .InvokeSet("TerminalServicesHomeDrive,"z:\Dir")
>
> Also, you might also add another piece or two to also migrate the data from
> one directory to another in the form
>
> Object search | foreach-object {var =propertyget ; propertyset; commit ;
> copy filefrom var to new location }
>
> Or some such logical view. Notice you need to get the previous location in
> order to get your to and from locations. It's not a complete answer but i
> bet you can fill in the blanks from here.
>
> Daren Daigle
> Boys and Girls Clubs of America
> (New convert to Power(ful)Shell
>
> "JMacWildFan06" wrote:
>
>> Hey guys, love the site. Finally, there's a fine community of
>> Powershellers that can support this developing product! Inspired in
>> part by MOW's fine blogs about Active Directory, I have a question
>> about scripting for AD. Is it possible to search through a specific CN
>> in my AD, change all of the users's TerminalservicesHomeDrive and
>> TerminalservicesHomeDirectory who reside in that CN, and then migrate
>> those home directories to a new location using something like Robocopy?
>> I have a script that does this in VB, but I would like to code one in
>> MSH. Keep up the good stuff, guys.
>>
>>
>> --
>> JMacWildFan06
>> ------------------------------------------------------------------------
>> JMacWildFan06's Profile: http://forums.yourdomain.com.au/member.php?userid=86
>> View this thread: http://forums.yourdomain.com.au/showthread.php?t=9457
>>
>>
My System SpecsSystem Spec
Old 07-05-2006   #5 (permalink)
/\\/\\o\\/\\/


 
 

Re: AD Changes and Looping

Thanks,
for your question something like this ? (by head)

$OU.get_children |? {$_.invokeget('TerminalServicesHomeDrive') -eq
"z:\$($_.SamAccountname)"} |%
{$_.InvokeSet('TerminalServicesHomeDrive',"y:\$($_.SamAccountname)");$_.Commitchanges()}


Greetings /\/\o\/\/

JMacWildFan06 wrote:
> Nice example there, Daren. I've had that in my MSH favorites for awhile
> because it was nice and detailed for what you set out to do. /\/\o\/\/,
> keep up the good posts on the blog. Your site is probably the best
> resource for MSH I've seen so far. It's given me the most information
> to make some real fascinating and effective scripts with MSH.
>
> I've got a follow up question to my original post, with some more
> detail and procedural stuff. I have this group in AD, which is:
> -LDAP://cn=GG_Migration_Users,ou=App_Groups,dc=subxxx,dc=xxx,dc=com-
>
> This CN group contains all of the users that need to have their
> TermServices profile paths and home drives changed. The old path looks
> like: -\\server_old\program_path\[userid]- and the new path would be:
> -\\windows2k3box\[userid]-.
>
> Obviously, both the old and the new path are similar in the fact that
> the UNC path routes to a folder with their user ID as the name. Is it
> possible to search through this CN group of users to determine which
> users still have the old path (as there is a mix of new and old paths),
> then change the TermServ home directory path for only those users?
>
> /\\/\\o\\/\\/ Wrote:
>> @ JMacWildFan06,
>>
>> Nice to here that my blog got you going,
>>
>> I will post the 3th part tomorrow, (a bit later as it is Hot in the
>> Netherlands for a change ;-) and had a dinner tonight)it will talk
>> about
>> the Terminal Services properties also, and in following part I also
>> will
>> talk about the DirectorySearcher for if you need more granular control
>> about the Users affected as a whole OU.
>> I already have some samples :
>>
>> http://tinyurl.com/kh8o4
>> http://mow001.blogspot.com/2006/04/l...-in-monad.html
>>
>> and here you can find a good entry using a directorysearcher
>>
>> http://pcmusings.spaces.msn.com/blog/cns!42B71883C19FDDAE!263.entry?_c11_blogpart_blogpart=blogview&_c=blogpart#permalink
>>
>> I will look into a example that makes also the directories
>> that and Darens example should get you going.
>>
>> @ Daren Daigle
>>
>> nice example.
>>
>> Greetings /\/\o\/\/
>>
>>
>> Daren Daigle wrote:
>>> Yes, thanks to some help, i did NEARLY the same thing to enable my
>>> TerminalServer bit for all users (since i use GPO to restrict

>> terminal server
>>> access)
>>>
>>> (Begin Code)
>>> $root = New-Object System.DirectoryServices.DirectoryEntry
>>> @($root.get_children().find('ou=users,ou=org').get_children()) |
>>> foreach-object {$_.InvokeSet("AllowLogon",1) ; $_.CommitChanges }
>>> (End Code)
>>>
>>> In your case, its .InvokeSet("TerminalServicesHomeDrive,"z:\Dir")
>>>
>>> Also, you might also add another piece or two to also migrate the

>> data from
>>> one directory to another in the form
>>>
>>> Object search | foreach-object {var =propertyget ; propertyset;

>> commit ;
>>> copy filefrom var to new location }
>>>
>>> Or some such logical view. Notice you need to get the previous

>> location in
>>> order to get your to and from locations. It's not a complete answer

>> but i
>>> bet you can fill in the blanks from here.
>>>
>>> Daren Daigle
>>> Boys and Girls Clubs of America
>>> (New convert to Power(ful)Shell
>>>
>>> "JMacWildFan06" wrote:
>>>
>>>> Hey guys, love the site. Finally, there's a fine community of
>>>> Powershellers that can support this developing product! Inspired in
>>>> part by MOW's fine blogs about Active Directory, I have a question
>>>> about scripting for AD. Is it possible to search through a specific

>> CN
>>>> in my AD, change all of the users's TerminalservicesHomeDrive and
>>>> TerminalservicesHomeDirectory who reside in that CN, and then

>> migrate
>>>> those home directories to a new location using something like

>> Robocopy?
>>>> I have a script that does this in VB, but I would like to code one

>> in
>>>> MSH. Keep up the good stuff, guys.
>>>>
>>>>
>>>> --
>>>> JMacWildFan06
>>>>

>> ------------------------------------------------------------------------
>>>> JMacWildFan06's Profile:

>> http://forums.yourdomain.com.au/member.php?userid=86
>>>> View this thread:

>> http://forums.yourdomain.com.au/showthread.php?t=9457
>>>>

>
>

My System SpecsSystem Spec
Old 07-05-2006   #6 (permalink)
/\\/\\o\\/\\/


 
 

Re: AD Changes and Looping

Oops the group that would be :

$group.member |% { New object
directoryservices.directoryentry("LDAP://$_")} |?
{$_.invokeget('TerminalServicesHomeDrive') -eq
"z:\$($_.SamAccountname)"} |%
$_.InvokeSet('TerminalServicesHomeDrive',"y:\$($_.SamAccountname)");$_.Commitchanges()}

/\/\o\/\/ wrote:
> Thanks,
> for your question something like this ? (by head)
>
> $OU.get_children |? {$_.invokeget('TerminalServicesHomeDrive') -eq
> "z:\$($_.SamAccountname)"} |%
> {$_.InvokeSet('TerminalServicesHomeDrive',"y:\$($_.SamAccountname)");$_.Commitchanges()}
>
>
>
> Greetings /\/\o\/\/
>
> JMacWildFan06 wrote:
>> Nice example there, Daren. I've had that in my MSH favorites for awhile
>> because it was nice and detailed for what you set out to do. /\/\o\/\/,
>> keep up the good posts on the blog. Your site is probably the best
>> resource for MSH I've seen so far. It's given me the most information
>> to make some real fascinating and effective scripts with MSH.
>>
>> I've got a follow up question to my original post, with some more
>> detail and procedural stuff. I have this group in AD, which is:
>> -LDAP://cn=GG_Migration_Users,ou=App_Groups,dc=subxxx,dc=xxx,dc=com-
>>
>> This CN group contains all of the users that need to have their
>> TermServices profile paths and home drives changed. The old path looks
>> like: -\\server_old\program_path\[userid]- and the new path would be:
>> -\\windows2k3box\[userid]-.
>>
>> Obviously, both the old and the new path are similar in the fact that
>> the UNC path routes to a folder with their user ID as the name. Is it
>> possible to search through this CN group of users to determine which
>> users still have the old path (as there is a mix of new and old paths),
>> then change the TermServ home directory path for only those users?
>>
>> /\\/\\o\\/\\/ Wrote:
>>> @ JMacWildFan06,
>>>
>>> Nice to here that my blog got you going,
>>>
>>> I will post the 3th part tomorrow, (a bit later as it is Hot in the
>>> Netherlands for a change ;-) and had a dinner tonight)it will talk
>>> about
>>> the Terminal Services properties also, and in following part I also
>>> will
>>> talk about the DirectorySearcher for if you need more granular control
>>> about the Users affected as a whole OU.
>>> I already have some samples :
>>>
>>> http://tinyurl.com/kh8o4
>>> http://mow001.blogspot.com/2006/04/l...-in-monad.html
>>>
>>> and here you can find a good entry using a directorysearcher
>>>
>>> http://pcmusings.spaces.msn.com/blog/cns!42B71883C19FDDAE!263.entry?_c11_blogpart_blogpart=blogview&_c=blogpart#permalink
>>>
>>>
>>> I will look into a example that makes also the directories
>>> that and Darens example should get you going.
>>>
>>> @ Daren Daigle
>>>
>>> nice example.
>>>
>>> Greetings /\/\o\/\/
>>>
>>>
>>> Daren Daigle wrote:
>>>> Yes, thanks to some help, i did NEARLY the same thing to enable my
>>>> TerminalServer bit for all users (since i use GPO to restrict
>>> terminal server
>>>> access)
>>>>
>>>> (Begin Code)
>>>> $root = New-Object System.DirectoryServices.DirectoryEntry
>>>> @($root.get_children().find('ou=users,ou=org').get_children()) |
>>>> foreach-object {$_.InvokeSet("AllowLogon",1) ; $_.CommitChanges }
>>>> (End Code)
>>>>
>>>> In your case, its .InvokeSet("TerminalServicesHomeDrive,"z:\Dir")
>>>>
>>>> Also, you might also add another piece or two to also migrate the
>>> data from
>>>> one directory to another in the form
>>>>
>>>> Object search | foreach-object {var =propertyget ; propertyset;
>>> commit ;
>>>> copy filefrom var to new location }
>>>>
>>>> Or some such logical view. Notice you need to get the previous
>>> location in
>>>> order to get your to and from locations. It's not a complete answer
>>> but i
>>>> bet you can fill in the blanks from here.
>>>>
>>>> Daren Daigle
>>>> Boys and Girls Clubs of America
>>>> (New convert to Power(ful)Shell
>>>>
>>>> "JMacWildFan06" wrote:
>>>>
>>>>> Hey guys, love the site. Finally, there's a fine community of
>>>>> Powershellers that can support this developing product! Inspired in
>>>>> part by MOW's fine blogs about Active Directory, I have a question
>>>>> about scripting for AD. Is it possible to search through a specific
>>> CN
>>>>> in my AD, change all of the users's TerminalservicesHomeDrive and
>>>>> TerminalservicesHomeDirectory who reside in that CN, and then
>>> migrate
>>>>> those home directories to a new location using something like
>>> Robocopy?
>>>>> I have a script that does this in VB, but I would like to code one
>>> in
>>>>> MSH. Keep up the good stuff, guys.
>>>>>
>>>>>
>>>>> --
>>>>> JMacWildFan06
>>>>>
>>> ------------------------------------------------------------------------
>>>>> JMacWildFan06's Profile:
>>> http://forums.yourdomain.com.au/member.php?userid=86
>>>>> View this thread:
>>> http://forums.yourdomain.com.au/showthread.php?t=9457
>>>>>

>>
>>

My System SpecsSystem Spec
Old 07-06-2006   #7 (permalink)


 
 

/\/\o\/\/,
When I first tried the code from your second post, I got an unexpected } in the expression. I assume it was the last } you had in your code, so I removed it and ran it again. When I did it again, it said this...

cmdlet ? at command pipeline position 2
Supply values for the following parameters:
FilterScript:

I'm not sure what to do here, but I think something isn't quite right. Is that so?


Quote  Quote: Originally Posted by /\\/\\o\\/\\/
Oops the group that would be :

$group.member |% { New object
directoryservices.directoryentry("LDAP://$_")} |?
{$_.invokeget('TerminalServicesHomeDrive') -eq
"z:\$($_.SamAccountname)"} |%
$_.InvokeSet('TerminalServicesHomeDrive',"y:\$($_.SamAccountname)");$_.Commitchanges()}

/\/\o\/\/ wrote:
> Thanks,
> for your question something like this ? (by head)
>
> $OU.get_children |? {$_.invokeget('TerminalServicesHomeDrive') -eq
> "z:\$($_.SamAccountname)"} |%
> {$_.InvokeSet('TerminalServicesHomeDrive',"y:\$($_.SamAccountname)");$_.Commitchanges()}
>
>
>
> Greetings /\/\o\/\/
>
> JMacWildFan06 wrote:
>> Nice example there, Daren. I've had that in my MSH favorites for awhile
>> because it was nice and detailed for what you set out to do. /\/\o\/\/,
>> keep up the good posts on the blog. Your site is probably the best
>> resource for MSH I've seen so far. It's given me the most information
>> to make some real fascinating and effective scripts with MSH.
>>
>> I've got a follow up question to my original post, with some more
>> detail and procedural stuff. I have this group in AD, which is:
>> -LDAP://cn=GG_Migration_Users,ou=App_Groups,dc=subxxx,dc=xxx,dc=com-
>>
>> This CN group contains all of the users that need to have their
>> TermServices profile paths and home drives changed. The old path looks
>> like: -\\server_old\program_path\[userid]- and the new path would be:
>> -\\windows2k3box\[userid]-.
>>
>> Obviously, both the old and the new path are similar in the fact that
>> the UNC path routes to a folder with their user ID as the name. Is it
>> possible to search through this CN group of users to determine which
>> users still have the old path (as there is a mix of new and old paths),
>> then change the TermServ home directory path for only those users?
>>
>> /\\/\\o\\/\\/ Wrote:
>>> @ JMacWildFan06,
>>>
>>> Nice to here that my blog got you going,
>>>
>>> I will post the 3th part tomorrow, (a bit later as it is Hot in the
>>> Netherlands for a change ;-) and had a dinner tonight)it will talk
>>> about
>>> the Terminal Services properties also, and in following part I also
>>> will
>>> talk about the DirectorySearcher for if you need more granular control
>>> about the Users affected as a whole OU.
>>> I already have some samples :
>>>
>>> http://tinyurl.com/kh8o4
>>> http://mow001.blogspot.com/2006/04/l...-in-monad.html
>>>
>>> and here you can find a good entry using a directorysearcher
>>>
>>> http://pcmusings.spaces.msn.com/blog/cns!42B71883C19FDDAE!263.entry?_c11_blogpart_blogpart=blogview&_c=blogpart#permalink
>>>
>>>
>>> I will look into a example that makes also the directories
>>> that and Darens example should get you going.
>>>
>>> @ Daren Daigle
>>>
>>> nice example.
>>>
>>> Greetings /\/\o\/\/
>>>
>>>
>>> Daren Daigle wrote:
>>>> Yes, thanks to some help, i did NEARLY the same thing to enable my
>>>> TerminalServer bit for all users (since i use GPO to restrict
>>> terminal server
>>>> access)
>>>>
>>>> (Begin Code)
>>>> $root = New-Object System.DirectoryServices.DirectoryEntry
>>>> @($root.get_children().find('ou=users,ou=org').get_children()) |
>>>> foreach-object {$_.InvokeSet("AllowLogon",1) ; $_.CommitChanges }
>>>> (End Code)
>>>>
>>>> In your case, its .InvokeSet("TerminalServicesHomeDrive,"z:\Dir")
>>>>
>>>> Also, you might also add another piece or two to also migrate the
>>> data from
>>>> one directory to another in the form
>>>>
>>>> Object search | foreach-object {var =propertyget ; propertyset;
>>> commit ;
>>>> copy filefrom var to new location }
>>>>
>>>> Or some such logical view. Notice you need to get the previous
>>> location in
>>>> order to get your to and from locations. It's not a complete answer
>>> but i
>>>> bet you can fill in the blanks from here.
>>>>
>>>> Daren Daigle
>>>> Boys and Girls Clubs of America
>>>> (New convert to Power(ful)Shell
>>>>
>>>> "JMacWildFan06" wrote:
>>>>
>>>>> Hey guys, love the site. Finally, there's a fine community of
>>>>> Powershellers that can support this developing product! Inspired in
>>>>> part by MOW's fine blogs about Active Directory, I have a question
>>>>> about scripting for AD. Is it possible to search through a specific
>>> CN
>>>>> in my AD, change all of the users's TerminalservicesHomeDrive and
>>>>> TerminalservicesHomeDirectory who reside in that CN, and then
>>> migrate
>>>>> those home directories to a new location using something like
>>> Robocopy?
>>>>> I have a script that does this in VB, but I would like to code one
>>> in
>>>>> MSH. Keep up the good stuff, guys.
>>>>>
>>>>>
>>>>> --
>>>>> JMacWildFan06
>>>>>
>>> ------------------------------------------------------------------------
>>>>> JMacWildFan06's Profile:
>>> http://forums.yourdomain.com.au/member.php?userid=86
>>>>> View this thread:
>>> http://forums.yourdomain.com.au/showthread.php?t=9457
>>>>>

>>
>>
My System SpecsSystem Spec
Old 07-06-2006   #8 (permalink)
/\\/\\o\\/\\/


 
 

Re: AD Changes and Looping

Sorry I did this by head I was missing the opening { in the second
foreach (before $_.invokeSet) :

$group.member |% { New object
directoryservices.directoryentry("LDAP://$_")} |?
{$_.invokeget('TerminalServicesHomeDrive') -eq
"z:\$($_.SamAccountname)"} |%
{$_.InvokeSet('TerminalServicesHomeDrive',"y:\$($_.SamAccountname)");$_.Commitchanges()}

Greetings /\/\o\/\/

JMacWildFan06 wrote:
> /\/\o\/\/,
> When I first tried the code from your second post, I got an unexpected
> } in the expression. I assume it was the last } you had in your code,
> so I removed it and ran it again. When I did it again, it said this...
>
> cmdlet ? at command pipeline position 2
> Supply values for the following parameters:
> FilterScript:
>
> I'm not sure what to do here, but I think something isn't quite right.
> Is that so?
>
>
> /\\/\\o\\/\\/ Wrote:
>> Oops the group that would be :
>>
>> $group.member |% { New object
>> directoryservices.directoryentry("LDAP://$_")} |?
>> {$_.invokeget('TerminalServicesHomeDrive') -eq
>> "z:\$($_.SamAccountname)"} |%
>> $_.InvokeSet('TerminalServicesHomeDrive',"y:\$($_.SamAccountname)");$_.Commitchanges()}
>>
>> /\/\o\/\/ wrote:
>>> Thanks,
>>> for your question something like this ? (by head)
>>>
>>> $OU.get_children |? {$_.invokeget('TerminalServicesHomeDrive') -eq
>>> "z:\$($_.SamAccountname)"} |%
>>>

>> {$_.InvokeSet('TerminalServicesHomeDrive',"y:\$($_.SamAccountname)");$_.Commitchanges()}
>>>
>>>
>>> Greetings /\/\o\/\/
>>>
>>> JMacWildFan06 wrote:
>>>> Nice example there, Daren. I've had that in my MSH favorites for

>> awhile
>>>> because it was nice and detailed for what you set out to do.

>> /\/\o\/\/,
>>>> keep up the good posts on the blog. Your site is probably the best
>>>> resource for MSH I've seen so far. It's given me the most

>> information
>>>> to make some real fascinating and effective scripts with MSH.
>>>>
>>>> I've got a follow up question to my original post, with some more
>>>> detail and procedural stuff. I have this group in AD, which is:
>>>> -LDAP://cn=GG_Migration_Users,ou=App_Groups,dc=subxxx,dc=xxx,dc=com-
>>>>
>>>> This CN group contains all of the users that need to have their
>>>> TermServices profile paths and home drives changed. The old path

>> looks
>>>> like: -\\server_old\program_path\[userid]- and the new path would

>> be:
>>>> -\\windows2k3box\[userid]-.
>>>>
>>>> Obviously, both the old and the new path are similar in the fact

>> that
>>>> the UNC path routes to a folder with their user ID as the name. Is

>> it
>>>> possible to search through this CN group of users to determine which
>>>> users still have the old path (as there is a mix of new and old

>> paths),
>>>> then change the TermServ home directory path for only those users?
>>>>
>>>> /\\/\\o\\/\\/ Wrote:
>>>>> @ JMacWildFan06,
>>>>>
>>>>> Nice to here that my blog got you going,
>>>>>
>>>>> I will post the 3th part tomorrow, (a bit later as it is Hot in the
>>>>> Netherlands for a change ;-) and had a dinner tonight)it will talk
>>>>> about
>>>>> the Terminal Services properties also, and in following part I also
>>>>> will
>>>>> talk about the DirectorySearcher for if you need more granular

>> control
>>>>> about the Users affected as a whole OU.
>>>>> I already have some samples :
>>>>>
>>>>> http://tinyurl.com/kh8o4
>>>>> http://mow001.blogspot.com/2006/04/l...-in-monad.html
>>>>>
>>>>> and here you can find a good entry using a directorysearcher
>>>>>
>>>>>

>> http://pcmusings.spaces.msn.com/blog/cns!42B71883C19FDDAE!263.entry?_c11_blogpart_blogpart=blogview&_c=blogpart#permalink
>>>>>
>>>>> I will look into a example that makes also the directories
>>>>> that and Darens example should get you going.
>>>>>
>>>>> @ Daren Daigle
>>>>>
>>>>> nice example.
>>>>>
>>>>> Greetings /\/\o\/\/
>>>>>
>>>>>
>>>>> Daren Daigle wrote:
>>>>>> Yes, thanks to some help, i did NEARLY the same thing to enable my
>>>>>> TerminalServer bit for all users (since i use GPO to restrict
>>>>> terminal server
>>>>>> access)
>>>>>>
>>>>>> (Begin Code)
>>>>>> $root = New-Object System.DirectoryServices.DirectoryEntry
>>>>>> @($root.get_children().find('ou=users,ou=org').get_children()) |
>>>>>> foreach-object {$_.InvokeSet("AllowLogon",1) ; $_.CommitChanges }
>>>>>> (End Code)
>>>>>>
>>>>>> In your case, its .InvokeSet("TerminalServicesHomeDrive,"z:\Dir")
>>>>>>
>>>>>> Also, you might also add another piece or two to also migrate the
>>>>> data from
>>>>>> one directory to another in the form
>>>>>>
>>>>>> Object search | foreach-object {var =propertyget ; propertyset;
>>>>> commit ;
>>>>>> copy filefrom var to new location }
>>>>>>
>>>>>> Or some such logical view. Notice you need to get the previous
>>>>> location in
>>>>>> order to get your to and from locations. It's not a complete

>> answer
>>>>> but i
>>>>>> bet you can fill in the blanks from here.
>>>>>>
>>>>>> Daren Daigle
>>>>>> Boys and Girls Clubs of America
>>>>>> (New convert to Power(ful)Shell
>>>>>>
>>>>>> "JMacWildFan06" wrote:
>>>>>>
>>>>>>> Hey guys, love the site. Finally, there's a fine community of
>>>>>>> Powershellers that can support this developing product! Inspired

>> in
>>>>>>> part by MOW's fine blogs about Active Directory, I have a

>> question
>>>>>>> about scripting for AD. Is it possible to search through a

>> specific
>>>>> CN
>>>>>>> in my AD, change all of the users's TerminalservicesHomeDrive and
>>>>>>> TerminalservicesHomeDirectory who reside in that CN, and then
>>>>> migrate
>>>>>>> those home directories to a new location using something like
>>>>> Robocopy?
>>>>>>> I have a script that does this in VB, but I would like to code

>> one
>>>>> in
>>>>>>> MSH. Keep up the good stuff, guys.
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> JMacWildFan06
>>>>>>>

>> ------------------------------------------------------------------------
>>>>>>> JMacWildFan06's Profile:
>>>>> http://forums.yourdomain.com.au/member.php?userid=86
>>>>>>> View this thread:
>>>>> http://forums.yourdomain.com.au/showthread.php?t=9457
>>>>

>
>

My System SpecsSystem Spec
Old 07-06-2006   #9 (permalink)


 
 

Is this supposed to be in addition to Daren's script or a new one all together? If it is its own script, I got the same...
cmdlet ? at command pipeline position 2
Supply values for the following parameters:
FilterScript:
... problem I had before.

Quote  Quote: Originally Posted by /\\/\\o\\/\\/
Sorry I did this by head I was missing the opening { in the second
foreach (before $_.invokeSet) :

$group.member |% { New object
directoryservices.directoryentry("LDAP://$_")} |?
{$_.invokeget('TerminalServicesHomeDrive') -eq
"z:\$($_.SamAccountname)"} |%
{$_.InvokeSet('TerminalServicesHomeDrive',"y:\$($_.SamAccountname)");$_.Commitchanges()}

Greetings /\/\o\/\/

JMacWildFan06 wrote:
> /\/\o\/\/,
> When I first tried the code from your second post, I got an unexpected
> } in the expression. I assume it was the last } you had in your code,
> so I removed it and ran it again. When I did it again, it said this...
>
> cmdlet ? at command pipeline position 2
> Supply values for the following parameters:
> FilterScript:
>
> I'm not sure what to do here, but I think something isn't quite right.
> Is that so?
>
>
> /\\/\\o\\/\\/ Wrote:
>> Oops the group that would be :
>>
>> $group.member |% { New object
>> directoryservices.directoryentry("LDAP://$_")} |?
>> {$_.invokeget('TerminalServicesHomeDrive') -eq
>> "z:\$($_.SamAccountname)"} |%
>> $_.InvokeSet('TerminalServicesHomeDrive',"y:\$($_.SamAccountname)");$_.Commitchanges()}
>>
>> /\/\o\/\/ wrote:
>>> Thanks,
>>> for your question something like this ? (by head)
>>>
>>> $OU.get_children |? {$_.invokeget('TerminalServicesHomeDrive') -eq
>>> "z:\$($_.SamAccountname)"} |%
>>>

>> {$_.InvokeSet('TerminalServicesHomeDrive',"y:\$($_.SamAccountname)");$_.Commitchanges()}
>>>
>>>
>>> Greetings /\/\o\/\/
>>>
>>> JMacWildFan06 wrote:
>>>> Nice example there, Daren. I've had that in my MSH favorites for

>> awhile
>>>> because it was nice and detailed for what you set out to do.

>> /\/\o\/\/,
>>>> keep up the good posts on the blog. Your site is probably the best
>>>> resource for MSH I've seen so far. It's given me the most

>> information
>>>> to make some real fascinating and effective scripts with MSH.
>>>>
>>>> I've got a follow up question to my original post, with some more
>>>> detail and procedural stuff. I have this group in AD, which is:
>>>> -LDAP://cn=GG_Migration_Users,ou=App_Groups,dc=subxxx,dc=xxx,dc=com-
>>>>
>>>> This CN group contains all of the users that need to have their
>>>> TermServices profile paths and home drives changed. The old path

>> looks
>>>> like: -\\server_old\program_path\[userid]- and the new path would

>> be:
>>>> -\\windows2k3box\[userid]-.
>>>>
>>>> Obviously, both the old and the new path are similar in the fact

>> that
>>>> the UNC path routes to a folder with their user ID as the name. Is

>> it
>>>> possible to search through this CN group of users to determine which
>>>> users still have the old path (as there is a mix of new and old

>> paths),
>>>> then change the TermServ home directory path for only those users?
>>>>
>>>> /\\/\\o\\/\\/ Wrote:
>>>>> @ JMacWildFan06,
>>>>>
>>>>> Nice to here that my blog got you going,
>>>>>
>>>>> I will post the 3th part tomorrow, (a bit later as it is Hot in the
>>>>> Netherlands for a change ;-) and had a dinner tonight)it will talk
>>>>> about
>>>>> the Terminal Services properties also, and in following part I also
>>>>> will
>>>>> talk about the DirectorySearcher for if you need more granular

>> control
>>>>> about the Users affected as a whole OU.
>>>>> I already have some samples :
>>>>>
>>>>> http://tinyurl.com/kh8o4
>>>>> http://mow001.blogspot.com/2006/04/l...-in-monad.html
>>>>>
>>>>> and here you can find a good entry using a directorysearcher
>>>>>
>>>>>

>> http://pcmusings.spaces.msn.com/blog/cns!42B71883C19FDDAE!263.entry?_c11_blogpart_blogpart=blogview&_c=blogpart#permalink
>>>>>
>>>>> I will look into a example that makes also the directories
>>>>> that and Darens example should get you going.
>>>>>
>>>>> @ Daren Daigle
>>>>>
>>>>> nice example.
>>>>>
>>>>> Greetings /\/\o\/\/
>>>>>
>>>>>
>>>>> Daren Daigle wrote:
>>>>>> Yes, thanks to some help, i did NEARLY the same thing to enable my
>>>>>> TerminalServer bit for all users (since i use GPO to restrict
>>>>> terminal server
>>>>>> access)
>>>>>>
>>>>>> (Begin Code)
>>>>>> $root = New-Object System.DirectoryServices.DirectoryEntry
>>>>>> @($root.get_children().find('ou=users,ou=org').get_children()) |
>>>>>> foreach-object {$_.InvokeSet("AllowLogon",1) ; $_.CommitChanges }
>>>>>> (End Code)
>>>>>>
>>>>>> In your case, its .InvokeSet("TerminalServicesHomeDrive,"z:\Dir")
>>>>>>
>>>>>> Also, you might also add another piece or two to also migrate the
>>>>> data from
>>>>>> one directory to another in the form
>>>>>>
>>>>>> Object search | foreach-object {var =propertyget ; propertyset;
>>>>> commit ;
>>>>>> copy filefrom var to new location }
>>>>>>
>>>>>> Or some such logical view. Notice you need to get the previous
>>>>> location in
>>>>>> order to get your to and from locations. It's not a complete

>> answer
>>>>> but i
>>>>>> bet you can fill in the blanks from here.
>>>>>>
>>>>>> Daren Daigle
>>>>>> Boys and Girls Clubs of America
>>>>>> (New convert to Power(ful)Shell
>>>>>>
>>>>>> "JMacWildFan06" wrote:
>>>>>>
>>>>>>> Hey guys, love the site. Finally, there's a fine community of
>>>>>>> Powershellers that can support this developing product! Inspired

>> in
>>>>>>> part by MOW's fine blogs about Active Directory, I have a

>> question
>>>>>>> about scripting for AD. Is it possible to search through a

>> specific
>>>>> CN
>>>>>>> in my AD, change all of the users's TerminalservicesHomeDrive and
>>>>>>> TerminalservicesHomeDirectory who reside in that CN, and then
>>>>> migrate
>>>>>>> those home directories to a new location using something like
>>>>> Robocopy?
>>>>>>> I have a script that does this in VB, but I would like to code

>> one
>>>>> in
>>>>>>> MSH. Keep up the good stuff, guys.
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> JMacWildFan06
>>>>>>>

>> ------------------------------------------------------------------------
>>>>>>> JMacWildFan06's Profile:
>>>>> http://forums.yourdomain.com.au/member.php?userid=86
>>>>>>> View this thread:
>>>>> http://forums.yourdomain.com.au/showthread.php?t=9457
>>>>

>
>
My System SpecsSystem Spec
Old 07-06-2006   #10 (permalink)
/\\/\\o\\/\\/


 
 

Re: AD Changes and Looping

It stands on his own, but $group must be a DirectoryEntry Object filled
with the right Group.

as I see position 2 in the error I think there is a false newLine
somewhere, as I typed it over on my laptop and it did work.
try removing all linebreaks.

Greetings /\/\o\/\/


JMacWildFan06 wrote:
> Is this supposed to be in addition to Daren's script or a new one all
> together? If it is its own script, I got the same...
> cmdlet ? at command pipeline position 2
> Supply values for the following parameters:
> FilterScript:
> .. problem I had before.
>
> /\\/\\o\\/\\/ Wrote:
>> Sorry I did this by head I was missing the opening { in the second
>> foreach (before $_.invokeSet) :
>>
>> $group.member |% { New object
>> directoryservices.directoryentry("LDAP://$_")} |?
>> {$_.invokeget('TerminalServicesHomeDrive') -eq
>> "z:\$($_.SamAccountname)"} |%
>> {$_.InvokeSet('TerminalServicesHomeDrive',"y:\$($_.SamAccountname)");$_.Commitchanges()}
>>
>> Greetings /\/\o\/\/
>>
>> JMacWildFan06 wrote:
>>> /\/\o\/\/,
>>> When I first tried the code from your second post, I got an

>> unexpected
>>> } in the expression. I assume it was the last } you had in your code,
>>> so I removed it and ran it again. When I did it again, it said

>> this...
>>> cmdlet ? at command pipeline position 2
>>> Supply values for the following parameters:
>>> FilterScript:
>>>
>>> I'm not sure what to do here, but I think something isn't quite

>> right.
>>> Is that so?
>>>
>>>
>>> /\\/\\o\\/\\/ Wrote:
>>>> Oops the group that would be :
>>>>
>>>> $group.member |% { New object
>>>> directoryservices.directoryentry("LDAP://$_")} |?
>>>> {$_.invokeget('TerminalServicesHomeDrive') -eq
>>>> "z:\$($_.SamAccountname)"} |%
>>>>

>> $_.InvokeSet('TerminalServicesHomeDrive',"y:\$($_.SamAccountname)");$_.Commitchanges()}
>>>> /\/\o\/\/ wrote:
>>>>> Thanks,
>>>>> for your question something like this ? (by head)
>>>>>
>>>>> $OU.get_children |? {$_.invokeget('TerminalServicesHomeDrive') -eq
>>>>> "z:\$($_.SamAccountname)"} |%
>>>>>

>> {$_.InvokeSet('TerminalServicesHomeDrive',"y:\$($_.SamAccountname)");$_.Commitchanges()}
>>>>>
>>>>> Greetings /\/\o\/\/
>>>>>
>>>>> JMacWildFan06 wrote:
>>>>>> Nice example there, Daren. I've had that in my MSH favorites for
>>>> awhile
>>>>>> because it was nice and detailed for what you set out to do.
>>>> /\/\o\/\/,
>>>>>> keep up the good posts on the blog. Your site is probably the best
>>>>>> resource for MSH I've seen so far. It's given me the most
>>>> information
>>>>>> to make some real fascinating and effective scripts with MSH.
>>>>>>
>>>>>> I've got a follow up question to my original post, with some more
>>>>>> detail and procedural stuff. I have this group in AD, which is:
>>>>>>

>> -LDAP://cn=GG_Migration_Users,ou=App_Groups,dc=subxxx,dc=xxx,dc=com-
>>>>>> This CN group contains all of the users that need to have their
>>>>>> TermServices profile paths and home drives changed. The old path
>>>> looks
>>>>>> like: -\\server_old\program_path\[userid]- and the new path would
>>>> be:
>>>>>> -\\windows2k3box\[userid]-.
>>>>>>
>>>>>> Obviously, both the old and the new path are similar in the fact
>>>> that
>>>>>> the UNC path routes to a folder with their user ID as the name. Is
>>>> it
>>>>>> possible to search through this CN group of users to determine

>> which
>>>>>> users still have the old path (as there is a mix of new and old
>>>> paths),
>>>>>> then change the TermServ home directory path for only those users?
>>>>>>
>>>>>> /\\/\\o\\/\\/ Wrote:
>>>>>>> @ JMacWildFan06,
>>>>>>>
>>>>>>> Nice to here that my blog got you going,
>>>>>>>
>>>>>>> I will post the 3th part tomorrow, (a bit later as it is Hot in

>> the
>>>>>>> Netherlands for a change ;-) and had a dinner tonight)it will

>> talk
>>>>>>> about
>>>>>>> the Terminal Services properties also, and in following part I

>> also
>>>>>>> will
>>>>>>> talk about the DirectorySearcher for if you need more granular
>>>> control
>>>>>>> about the Users affected as a whole OU.
>>>>>>> I already have some samples :
>>>>>>>
>>>>>>> http://tinyurl.com/kh8o4
>>>>>>> http://mow001.blogspot.com/2006/04/l...-in-monad.html
>>>>>>>
>>>>>>> and here you can find a good entry using a directorysearcher
>>>>>>>
>>>>>>>

>> http://pcmusings.spaces.msn.com/blog/cns!42B71883C19FDDAE!263.entry?_c11_blogpart_blogpart=blogview&_c=blogpart#permalink
>>>>>>> I will look into a example that makes also the directories
>>>>>>> that and Darens example should get you going.
>>>>>>>
>>>>>>> @ Daren Daigle
>>>>>>>
>>>>>>> nice example.
>>>>>>>
>>>>>>> Greetings /\/\o\/\/
>>>>>>>
>>>>>>>
>>>>>>> Daren Daigle wrote:
>>>>>>>> Yes, thanks to some help, i did NEARLY the same thing to enable

>> my
>>>>>>>> TerminalServer bit for all users (since i use GPO to restrict
>>>>>>> terminal server
>>>>>>>> access)
>>>>>>>>
>>>>>>>> (Begin Code)
>>>>>>>> $root = New-Object System.DirectoryServices.DirectoryEntry
>>>>>>>> @($root.get_children().find('ou=users,ou=org').get_children()) |
>>>>>>>> foreach-object {$_.InvokeSet("AllowLogon",1) ; $_.CommitChanges

>> }
>>>>>>>> (End Code)
>>>>>>>>
>>>>>>>> In your case, its

>> .InvokeSet("TerminalServicesHomeDrive,"z:\Dir")
>>>>>>>> Also, you might also add another piece or two to also migrate

>> the
>>>>>>> data from
>>>>>>>> one directory to another in the form
>>>>>>>>
>>>>>>>> Object search | foreach-object {var =propertyget ; propertyset;
>>>>>>> commit ;
>>>>>>>> copy filefrom var to new location }
>>>>>>>>
>>>>>>>> Or some such logical view. Notice you need to get the previous
>>>>>>> location in
>>>>>>>> order to get your to and from locations. It's not a complete
>>>> answer
>>>>>>> but i
>>>>>>>> bet you can fill in the blanks from here.
>>>>>>>>
>>>>>>>> Daren Daigle
>>>>>>>> Boys and Girls Clubs of America
>>>>>>>> (New convert to Power(ful)Shell
>>>>>>>>
>>>>>>>> "JMacWildFan06" wrote:
>>>>>>>>
>>>>>>>>> Hey guys, love the site. Finally, there's a fine community of
>>>>>>>>> Powershellers that can support this developing product!

>> Inspired
>>>> in
>>>>>>>>> part by MOW's fine blogs about Active Directory, I have a
>>>> question
>>>>>>>>> about scripting for AD. Is it possible to search through a
>>>> specific
>>>>>>> CN
>>>>>>>>> in my AD, change all of the users's TerminalservicesHomeDrive

>> and
>>>>>>>>> TerminalservicesHomeDirectory who reside in that CN, and then
>>>>>>> migrate
>>>>>>>>> those home directories to a new location using something like
>>>>>>> Robocopy?
>>>>>>>>> I have a script that does this in VB, but I would like to code
>>>> one
>>>>>>> in
>>>>>>>>> MSH. Keep up the good stuff, guys.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> JMacWildFan06
>>>>>>>>>

>> ------------------------------------------------------------------------
>>>>>>>>> JMacWildFan06's Profile:
>>>>>>> http://forums.yourdomain.com.au/member.php?userid=86
>>>>>>>>> View this thread:
>>>>>>> http://forums.yourdomain.com.au/showthread.php?t=9457
>>>

>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
err object and looping VB Script
Looping through directory VB Script
Looping and If Structures Vista General
Help looping a script PowerShell
Looping at start Vista installation & setup


Vista Forums 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 Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46