none
Powershell Script Help Email address field RRS feed

  • Question

  • Hello All,



    I am creating a script that will create a project mailbox account and security group using the Exchange Powershell console.  The problem I am running into is the following part of the script

    mail="$ProjectMailboxname + email@abc.com"}



    What my goal is, let's say the name of the project mailbox is "test", I want the email address field in the Security Group object to read "testemail@abc.com"

    I have posted the script below:


    write-host "Run this Script In Exchange Powershell!  This script will create a project mailbox and security group account in AD." -ForegroundColor Red -BackgroundColor Black

    get-mailbox
    Import-Module ActiveDirectory

    $ProjectMailboxName = (Read-Host  "Project Mailbox Name")
    $Justification = (Read-Host "Enter Justification")
    $SamAccountName = Get-ADUser -LDAPFilter "(sAMAccountName=$ProjectMailboxName)"
    $Date = Get-Date
    If ($SamAccountName -eq $Null) {write-host "User does not exist in AD" -ForegroundColor Green -BackgroundColor Black} 
    Else  {write-host "Security Group found in AD" -ForegroundColor Red -BackgroundColor Black

    $ProjectMailboxName = (Read-Host  "Project Mailbox Name")

    }



    New-Mailbox -Name $ProjectMailboxName -Alias $ProjectMailboxName -OrganizationalUnit "abc.com/Mailbox accounts/Project Mailboxes" -Database “Mailbox Database LANDON” -UserPrincipalName $ProjectMailboxName@abc.com –Shared
    Set-ADUser $ProjectMailboxName -Description $Justification

    New-ADGroup -Name "$ProjectMailboxName email" -SamAccountName "$ProjectMailboxName email" -GroupCategory Security -GroupScope Universal -DisplayName "$ProjectMailboxName email" -Path "OU=Project Mailbox Groups,OU=Mailbox accounts,DC=abc,DC=com"  -OtherAttributes @{info="Created by Kenneth Bryant on $Date."; mail="$ProjectMailboxname + email@abc.com"}

    Set-ADGroup "$ProjectMailboxName email" -Description "Members of this group have access to the $ProjectMailboxName mailbox"

    • Moved by Bill_Stewart Friday, January 26, 2018 2:51 PM Unanswerable drive-by question
    Wednesday, November 29, 2017 9:15 PM

All replies