Exchange Server Forums
Forums |
Register |
Login |
My Profile |
Inbox |
RSS
|
My Subscription |
My Forums |
Address Book |
Member List |
Search |
FAQ |
Ticket List |
Log Out
NewCompany.ps1 script broken?
Users viewing this topic:
none
|
Logged in as: Guest
|
Login | |
|
NewCompany.ps1 script broken? - 18.Apr.2010 1:31:30 AM
|
|
|
kcjones76
Posts: 2
Joined: 18.Apr.2010
Status: offline
|
I'm having problems working with the whitepaper scripts posted on technet regarding the creation of a new company: http://technet.microsoft.com/en-us/exchange/bb936719(EXCHG.80).aspx I've made the various revisions that are specific to my company info, but I'm getting the following message: Expressions are only permitted as the first element of a pipeline. At C:\Program Files\Microsoft\Exchange Server\Scripts\NewCompany.ps1:132 char:4 + " " <<<< It's referencing the line containing the single set of quotes: " " ".............................................." "9 of 15, Granting permissions for users of $CompanyName to view the Address List for $CompanyName" The script is below: " " "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" "!!!!!!! THIS IS NOT A MICROSOFT SUPPORTED SCRIPT. !!!!!!!!" "!!!!!!! TEST IN A LAB FOR DESIRED OUTCOME !!!!!!!!" "!!!!!!! !!!!!!!!!!" "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" " " "1. Change the server names." "A. OABGeneration server in Step 9" "B. OAB website in Step 9" "C. Public folder server" "2. Modify the domain and OU structure in Step 1" "3. Change the domain controller name in Step 3" " " #"When the above steps have been taken, comment out this line and all those above it using # #at the beginning of the line." #" " # #" " #!!!! Change DC below !!!! #This step gets a domain controller name ## $DC = "MBUSERVER1.mbu.local" "Using Domain Controller - $DC" #checks for the "Company" OU #---------------------------- #---------------------------- $eaSave = $ErrorActionPreference $ErrorActionPreference = "Inquire" $context = new-object System.DirectoryServices.ActiveDirectory.DirectoryContext([System.DirectoryServices.ActiveDirectory.DirectoryContextType]::DirectoryServer, $dc) $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetDomain($context) $root = $domain.psbase.GetDirectoryEntry() # check if the 'companies' ou exists $orgs = $null $orgs = $root.psbase.Children.psbase.Find("OU=companies") if ($orgs -eq $null) { write-host "Cannot find an OU named 'companies'"; exit } #----------------------------- #----------------------------- " " " " ## Gets the company name ## "Enter the company name:" $CompanyName = [Console]::ReadLine() $CompanyName = $CompanyName.Trim() ## Gets the company Email Domain Name ## "Enter the company email domain name - e.g. mbu.ca:" $CompanyEmailDomainName = [Console]::ReadLine() $CompanyEmailDomainName = $CompanyEmailDomainName.Trim() ## Create the OU for New Company ## ##!!!!! Change DC to a valid DC for your environment !!!!!! "1 of 15, Creating an Organizational Unit for $CompanyName" $NewOU = $CompanyName $objDomain = [ADSI]"LDAP://MBUSERVER1:389/ou=companies,dc=mbu,dc=local" $objOU = $objDomain.Create("organizationalUnit","ou="+$NewOU) $objOU.SetInfo() "An OU has been created for $CompanyName" " " "Wait 10 seconds for the OU to be visible on the Domain Controller" [System.Threading.Thread]::Sleep(10000) #check for this companies OU #-------------------------------- #-------------------------------- # Find the org itself $newOrg = $null $newOrg = $orgs.psbase.Children.psbase.Find("ou="+$CompanyName) if ($newOrg -eq $null) { " " write-host "Cannot find an OU named" $CompanyName " " exit } #--------------------------------- #--------------------------------- " " ".............................................." "2 of 15, Creating a Security Group for $CompanyName" ".............................................." #!!!OU structure must be created first!!!! new-distributiongroup -name "$CompanyName SG" -Type "security" -OrganizationalUnit "mbu.local/companies/$CompanyName" -SamAccountName "$CompanyName" -Alias "$CompanyName" -domaincontroller $DC " " ".............................................." "3 of 15, Add a Security Group for $CompanyName to the All Hosted Groups SG" ".............................................." Get-distributiongroup -name "All Hosted Groups SG" | Add-DistributionGroupMember -Member "$CompanyName SG" -domaincontroller $DC " " ".............................................." "4 of 15, Set customattribute1 on the USG for $CompanyName" ".............................................." set-distributiongroup "$CompanyName SG" -customattribute1 "$CompanyName" -domaincontroller $DC " " ".............................................." "5 of 15, Creating an Address List for $CompanyName" ".............................................." new-AddressList -Name "$CompanyName AL" -Container '\' -IncludedRecipients 'AllRecipients' -conditionalcustomattribute1 $CompanyName -domaincontroller $DC #" " #".............................................." "6 of 15, Add an Accepted Domain for $CompanyName" ".............................................." New-AcceptedDomain -Name "$CompanyName" -DomainName "$CompanyEmailDomainName" -DomainType Authoritative -domaincontroller $DC " " ".............................................." "7 of 15,Adding Email Address Policy for $CompanyName" ".............................................." New-EmailAddressPolicy -Name "$CompanyName" -Priority "1" -EnabledEmailAddressTemplates "SMTP:%m@$CompanyEmailDomainName" -domaincontroller $DC " " ".............................................." "8 of 15, Remove Authenticated Users from the $CompanyName address list" Get-AddressList "$companyName AL" -domaincontroller $DC | #Remove-ADPermission -User "Authenticated Users" -accessrights GenericRead -extendedrights "open address list" -deny:$false -domaincontroller $DC " " ".............................................." "9 of 15, Granting permissions for users of $CompanyName to view the Address List for $CompanyName" ".............................................." get-addresslist "$companyname AL" -domaincontroller $DC | add-adpermission -USER "$CompanyName SG" -extendedrights "Open Address list" -deny:$false -domaincontroller $DC " " ".............................................." "10 of 15, Creating a Global Address List for $CompanyName" ".............................................." new-globaladdresslist -name "$CompanyName GAL" -recipientFilter {(alias -ne $null -and customattribute1 -eq $CompanyName)} -domaincontroller $DC " " ".............................................." "11 of 15, Updating the Address List for $CompanyName" ".............................................." update-AddressList "$CompanyName AL" -domaincontroller $DC " " ".............................................." "12 of 15, Updating the Global Address List for $CompanyName" ".............................................." update-GlobalAddressList -Identity "$CompanyName GAL" -domaincontroller $DC " " ".............................................." "13 of 15, Updating the Email Address Policy for $CompanyName" ".............................................." update-EmailAddressPolicy -Identity "$CompanyName" -domaincontroller $DC " " ".............................................." "14 of 15,Creating an Offline Address List for $CompanyName" ".............................................." # !!!! Will need to change the server name here !!!! # !!!! Specify the OAB Generation Server and the OAB Distribution Location !!!! new-offlineAddressBook -Name "$CompanyName OAB" -Server EXCHANGE1.mbu.local -AddressLists "$CompanyName AL" -PublicFolderDistributionEnabled $true -VirtualDirectories "EXCHANGE1\OAB (Default Web Site)" -domaincontroller $DC ".............................................." "15 of 15, Granting permissions for users of $CompanyName to view the Offline Address Book for $CompanyName" ".............................................." Get-OfflineAddressBook "$CompanyName OAB" -domaincontroller $DC | Add-ADPermission -User "$CompanyName SG" -ExtendedRights 'ms-Exch-Download-OAB' -Deny:$false -domaincontroller $DC $OAB = (get-offlineaddressbook "$CompanyName OAB" -domaincontroller $DC).distinguishedname $OU = (get-distributiongroup "$CompanyName SG" -domaincontroller $DC).organizationalunit $USG = (get-distributiongroup "$CompanyName SG" -domaincontroller $DC).name " " "==============================================" "Script for setup of $companyname complete" "==============================================" " " "For each user created in $Companyname, set the following attributes to the specified values:" "customattribute1 = $CompanyName" "msExchUseOAB = $OAB" "msExchQueryBaseDN = $OU" "groupmembership = $USG" " " " " " " #==================================================== #=====confirmation Section - Output to HTML file===== #==================================================== $b3 = get-addresslist "$companyName AL"-domaincontroller $DC $b3a = $b3.recipientfilter $b4 = get-globaladdresslist "$companyName GAL"-domaincontroller $DC $b4a = $b4.recipientfilter $b5 = get-offlineaddressbook "$companyName OAB"-domaincontroller $DC $b5a = $b5.addresslists $b5b = $b5.distinguishedname $b6 = get-distributiongroup "$companyName SG" -domaincontroller $DC $b6a = $b6.grouptype $date = date set-content -path c:\$CompanyName.htm -value "<html> <title>Company Confirmation: $companyName</title> <head></head> <body> <h1>Company Confirmation: <font color=green>$Companyname</font></h1> <table> <tr><td><font size=2>The script will query each item listed and return the value in <font color=green>GREEN</font>. If the value is not found, it will not be listed. </td></tr> </table> <br> <table> <tr><td>Creation Date:</td><td><font color=green>$date</font></td></tr> <tr><td>AddressList:</td><td><font color=green>$b3 - $b3a</font></td></tr> <tr><td>GlobalAddressList:</td><td><font color=green>$b4 - $b4a</font></td></tr> <tr><td>OfflineAddressBook:</td><td><font color=green>$b5 - $b5a</font></td></tr> <tr><td>DistributionGroup:</td><td><font color=green>$b6 - $b6a</font></td></tr> </table> <table> <br> <tr><td> </td></tr> <tr><td><font size=2>For each user created in $CompanyName, you will set the following attributes to the underlined values:</td></tr> <tr><td><font size=2>customattribute1 - <u>$companyName</u> (In ADSIEdit its extensionattribute1)</td></tr> <tr><td><font size=2>msExchUseOAB - <u>$OAB</u> (IN EMS its -offlineaddressbook)</td></tr> <tr><td><font size=2>msExchQueryBaseDN - <u>$OU</u></td></tr> <tr><td><font size=2>groupmembership - <u>$USG</u></td></tr> <tr><td> </td></tr> </font> </table> </body> </html>" invoke-item c:\$companyname.htm
< Message edited by kcjones76 -- 18.Apr.2010 1:33:44 AM >
|
|
|
RE: NewCompany.ps1 script broken? - 4.May2010 3:30:09 PM
|
|
|
kcjones76
Posts: 2
Joined: 18.Apr.2010
Status: offline
|
Has anyone been able to get this to work for them?
|
|
|
RE: NewCompany.ps1 script broken? - 30.May2010 5:34:46 PM
|
|
|
KevinKCCS
Posts: 1
Joined: 30.May2010
Status: offline
|
I just solved this problem myself. Maybe a typo on their part. On part 8 of 15 theres a # where there shouldn't be. "8 of 15, Remove Authenticated Users from the $CompanyName address list" Get-AddressList "$companyName AL" -domaincontroller $DC | #Remove-ADPermission -User "Authenticated Users" -accessrights GenericRead -extendedrights "open address list" -deny:$false -domaincontroller $DC Take it out from the Remove-ADpermission part.
|
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts |
|