pramod1
asked on
exchange 2007, scripts
I am attaching script which I use to create bulk mailbox in resource forest setup.
the only thing I am missing AD groups , I need to make them manually member of some groups like active sync, tablets group,
is there any way I can edit my script so that users created are also having members of AD groups so I don't need to manually add for each user.
mailbox-script-main-1.txt
the only thing I am missing AD groups , I need to make them manually member of some groups like active sync, tablets group,
is there any way I can edit my script so that users created are also having members of AD groups so I don't need to manually add for each user.
mailbox-script-main-1.txt
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Hi akhater,
I will set up like this tomorrow and let you know , just to confirm whether user is a member of security or distribution group the command will follow the same ?
thanks
I will set up like this tomorrow and let you know , just to confirm whether user is a member of security or distribution group the command will follow the same ?
thanks
This is for distribution groups it can be a security group but it has to be email enabled in exchange
This is for distribution groups it can be a security group but it has to be email enabled in exchange
ASKER
it is a universal distribution group mail enabled I just cheked now
but when I execute the script in exchange shell do I need to type like colon or semi colon after disable-AD account or add the line which you mentioned
Get-ADUser -Filter {userprincipalname -like $_.upn} | Disable-ADAccount
Add-DistributionGroupMembe r -Identity "ActiveSync" -Member $_.upn
Add-DistributionGroupMembe r -Identity "OWA" -Member $_.upn
}
but when I execute the script in exchange shell do I need to type like colon or semi colon after disable-AD account or add the line which you mentioned
Get-ADUser -Filter {userprincipalname -like $_.upn} | Disable-ADAccount
Add-DistributionGroupMembe
Add-DistributionGroupMembe
}
You do not need to add the ; it can be replaced by an "enter" at the end of each line
If you want to run it as one line then you need to add the semicolon
ASKER
thanks I will let you know tomorrow
ASKER
where we have exchange and disabled AD accounts on the same exchange server, I tried adding last 2 lines(distribution group) in the script but it didn't add the user in the group but the script as a whole ran successfully
first question
1) have I missed anything, I am running all in one line
2) we have enabled AD accounts in domain.com, I am right now manually creating those accounts and then running the script
which creates Disabled AD accounts and exchange account in resource forest, can I run separately a script so it creats enabled AD ACCOUNTS in the account forest domain.com
3) when the script runs on the exchange side I want user@domain-retail.com also added in the email address as primary
Import-CSV CreateMailboxes-tt.csv | ForEach {
New-Mailbox -Alias $_.alias -Name $_.name -FirstName $_.Givenname -LastName $_.Surname -userPrincipalName $_.UPN -Database “Field Mailbox Database” -OrganizationalUnit ' Email accounts' -Password $Password -LinkedDomainController "domain..COM" -LinkedMasterAccount "domain\$($_.Name)";
Get-ADUser -Filter {userprincipalname -like $_.upn} | Disable-ADAccount
Add-DistributionGroupMembe r -Identity "ActiveSync" -Member $_.upn;
Add-DistributionGroupMembe r -Identity "OWA" -Member $_.upn;
}
I am running this as one whole line , script runs but never makes the user member of those groups
first question
1) have I missed anything, I am running all in one line
2) we have enabled AD accounts in domain.com, I am right now manually creating those accounts and then running the script
which creates Disabled AD accounts and exchange account in resource forest, can I run separately a script so it creats enabled AD ACCOUNTS in the account forest domain.com
3) when the script runs on the exchange side I want user@domain-retail.com also added in the email address as primary
Import-CSV CreateMailboxes-tt.csv | ForEach {
New-Mailbox -Alias $_.alias -Name $_.name -FirstName $_.Givenname -LastName $_.Surname -userPrincipalName $_.UPN -Database “Field Mailbox Database” -OrganizationalUnit ' Email accounts' -Password $Password -LinkedDomainController "domain..COM" -LinkedMasterAccount "domain\$($_.Name)";
Get-ADUser -Filter {userprincipalname -like $_.upn} | Disable-ADAccount
Add-DistributionGroupMembe
Add-DistributionGroupMembe
}
I am running this as one whole line , script runs but never makes the user member of those groups
If you are not the manager of those specific distributions groups, you will need to add the "-BypassSecurityGroupManag erCheck" parameter to the end of each of those commands...
That parameter will allow the user to be added to the DG without manager permission.
Add-DistributionGroupMember -Identity "ActiveSync" -Member $_.upn -BypassSecurityGroupManagerCheck
Add-DistributionGroupMember -Identity "OWA" -Member $_.upn -BypassSecurityGroupManagerCheck
That parameter will allow the user to be added to the DG without manager permission.
ASKER
I am the admin and I need to add the users in those group, right now after script runs then I need to go to user propertie sin AD and then add them to those groups
can you put in the script
can you put in the script
Disregard what I recommended about using the "-BypassSecurityGroupManag erCheck" parameter. That parameter is not available in and does not apply to Exchange 2007.
ASKER
so what am I missing here I am running all in one line and that email distribution group is not adding to user properties.
Import-CSV CreateMailboxes-tt.csv | ForEach {
New-Mailbox -Alias $_.alias -Name $_.name -FirstName $_.Givenname -LastName $_.Surname -userPrincipalName $_.UPN -Database “Field Mailbox Database” -OrganizationalUnit ' Email accounts' -Password $Password -LinkedDomainController "domain..COM" -LinkedMasterAccount "domain\$($_.Name)";
Get-ADUser -Filter {userprincipalname -like $_.upn} | Disable-ADAccount
Add-DistributionGroupMembe r -Identity "ActiveSync" -Member $_.upn;
Add-DistributionGroupMembe r -Identity "OWA" -Member $_.upn;
}
also I posted another question where I am running script bulk add user account creation and I am getting this error
Capture1.JPG
Import-CSV CreateMailboxes-tt.csv | ForEach {
New-Mailbox -Alias $_.alias -Name $_.name -FirstName $_.Givenname -LastName $_.Surname -userPrincipalName $_.UPN -Database “Field Mailbox Database” -OrganizationalUnit ' Email accounts' -Password $Password -LinkedDomainController "domain..COM" -LinkedMasterAccount "domain\$($_.Name)";
Get-ADUser -Filter {userprincipalname -like $_.upn} | Disable-ADAccount
Add-DistributionGroupMembe
Add-DistributionGroupMembe
}
also I posted another question where I am running script bulk add user account creation and I am getting this error
Capture1.JPG
I suggest opening a new request since you already awarded points to this question.
Try using Add-DistributionGroupMembe
When I've scripted adding users to distros, I've had to add users one by one to the distro because I could not add multiple users at once to a group. Therefore the CSV would look like this...
Open in new window
Hope thise helps.