Denver_IT
asked on
Adding a user with a comma in his name to a group...
I have been working on several scripts that read a CSV and create a series of objects.
I have been able to:
Create the Exchange mailbox and user account
Set the Exchange Custom Attributes
Set the User Arrributes
Create a group for that user
Create an OU based on that User
Create a GPO based on that user and link it to the OU
Add all the accounts I want to add to the group created save for one (the user account I created).
The user is listed Last, First in the OU and I am wondering if the comma is giving a problem when trying to add it to the group
Do I have to put quotes around the First, Last? If so how do I put that in my script?
Here is the actual example:
import-csv ImportUsers.csv | foreach {
($Alias = $_.Alias)
($Name = $_.Name)
$AddUser = ("CN=" + $Name + ",OU=" + $Alias + ",OU=New Users" + $Domain)
$group.Member.Add("$AddUse r")
$group.setInfo()
}
The output looks correct if I display $AddUser: CN=Last, First,OU=FLast,OU=New Users,DC=domain,DC=com
Thanks for the help
I have been able to:
Create the Exchange mailbox and user account
Set the Exchange Custom Attributes
Set the User Arrributes
Create a group for that user
Create an OU based on that User
Create a GPO based on that user and link it to the OU
Add all the accounts I want to add to the group created save for one (the user account I created).
The user is listed Last, First in the OU and I am wondering if the comma is giving a problem when trying to add it to the group
Do I have to put quotes around the First, Last? If so how do I put that in my script?
Here is the actual example:
import-csv ImportUsers.csv | foreach {
($Alias = $_.Alias)
($Name = $_.Name)
$AddUser = ("CN=" + $Name + ",OU=" + $Alias + ",OU=New Users" + $Domain)
$group.Member.Add("$AddUse
$group.setInfo()
}
The output looks correct if I display $AddUser: CN=Last, First,OU=FLast,OU=New Users,DC=domain,DC=com
Thanks for the help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.