|
Powershell: Error HRESULT: 0x8007200B when adding a member to a group in AD (SOLVED)
|
|
17-12-2010, 02:07 PM
(This post was last modified: 17-12-2010 02:08 PM by Fail Whale.)
Post: #1
|
|||
|
|||
|
Powershell: Error HRESULT: 0x8007200B when adding a member to a group in AD (SOLVED)
Hi
I am having a very weird problem with a script I am writing to create new users. Currently the user selects a group name from a drop-down list which is populated from AD. The cn of the group and the Distinguished Name of the newly created user are passed to a function to add the group membership. This works perfectly for most groups unless the name contains a hypen or underscore without spaces ie. GroupName = Works Group - Name = works Group-Name = Fails Group _ Name = Works Group_Name = Fails Group Name_2 = Fails Group Name-2 = Fails The code for the function in question is: Code: FUNCTION AddGroups ($UserDN, $Group)The problem seems to be is when one of the problem group names is selected it stops the $UserDN variable being passed correctly so If I insert a couple of write-hosts for trouble shooting I am able to retrieve $GroupAD.distinguishedName but not $UserAD.distinguishedName. Anyone got any Ideas what might cause this as I am completely stumped now. Follow me on Twitter My Blog Follow me on mFlow Gamertag - Davotronic 5000 |
|||
|
17-12-2010, 02:17 PM
Post: #2
|
|||
|
|||
|
Powershell: Error HRESULT: 0x8007200B when adding a member to a group in AD (SOLVED)
Any use to you?
Quote:To create a variable name that includes a hyphen, enclose the http://www.colorconsole.de/PS_Windows/en...iables.htm - Techmonkey ================ Enterprise Business IT Support | SME IT Support | Home Support Available |
|||
|
17-12-2010, 02:37 PM
(This post was last modified: 17-12-2010 02:41 PM by Fail Whale.)
Post: #3
|
|||
|
|||
Powershell: Error HRESULT: 0x8007200B when adding a member to a group in AD (SOLVED)
(17-12-2010 02:17 PM)Techmonkey Wrote: Any use to you? Unfortunately not, it is only the content of the variable which contain hyphens not the variable names. I have tried the same code outside of the function on the problem groups and it does work. The issue seems to be with passing the variables to the function. If it helps this is the code which loads the Function, but there is not much to it Code: #add the new user to each group selected on the formFollow me on Twitter My Blog Follow me on mFlow Gamertag - Davotronic 5000 |
|||
|
17-12-2010, 02:57 PM
Post: #4
|
|||
|
|||
|
Powershell: Error HRESULT: 0x8007200B when adding a member to a group in AD (SOLVED)
I think this time we may have a winner
or at least a step in the right direction:Quote:There is one small caveat when using query variables to provide tab completion: http://blogs.msdn.com/b/adpowershell/arc...lters.aspx - Techmonkey ================ Enterprise Business IT Support | SME IT Support | Home Support Available |
|||
|
17-12-2010, 03:13 PM
Post: #5
|
|||
|
|||
|
Powershell: Error HRESULT: 0x8007200B when adding a member to a group in AD (SOLVED)
Unfortunately again no luck. In the problem I am having underscores are causing the same problem as hyphens and only when they are not enclosed by spaces.
I think I need to wrap the variable content in some sort of brace or quote marks but cant find anything especially as hyphens and quotes should not be escape characters. Follow me on Twitter My Blog Follow me on mFlow Gamertag - Davotronic 5000 |
|||
|
17-12-2010, 05:48 PM
Post: #6
|
|||
|
|||
|
Powershell: Error HRESULT: 0x8007200B when adding a member to a group in AD (SOLVED)
Finally got this solved. The Function the data was originally coming from was returning too much data to the variable, which I have cleaned up now. Was just manifesting in a very strange way.
Follow me on Twitter My Blog Follow me on mFlow Gamertag - Davotronic 5000 |
|||
|
17-12-2010, 07:29 PM
Post: #7
|
|||
|
|||
|
RE: Powershell: Error HRESULT: 0x8007200B when adding a member to a group in AD (SOLVED)
hmmm that explains why I could find no mention of the _ underscore issue lol nice find
- Techmonkey ================ Enterprise Business IT Support | SME IT Support | Home Support Available |
|||
|
« Next Oldest | Next Newest »
|

Search
Member List
Calendar
Help




or at least a step in the right direction: