Solved

Powershell Script for creating Exchange 2013 Address books I have bad syntax

Posted on 2014-10-22
6
69 Views
Last Modified: 2015-06-18
Hey Gurus I have a simple script i am trying to create via powershell to create some address books in exchange it seems that my variables are not getting passed through:

here is it:
$ssdomainname="Costco Adb"
$ssdomain="costco.com"

"New-AddressList -Name '$ssgroupname' -RecipientFilter {((Alias -ne $null) -and (UserPrincipalName -like '*@$ssdomain'))}"


the acctual command should be : New-AddressList -Name 'Costco Adb' -RecipientFilter {((Alias -ne $null) -and (UserPrincipalName -like '*@costco.com'))}

but the output is :
Name                      DisplayName               RecipientFilter
----                      -----------               ---------------
"$ssgroupname"            "$ssgroupname"            ((Alias -ne $null) -and (UserPrincipalName -like '*@"$ssdomain"'))

the variables are not passing to the commad?

what is the correct syntax?

Thanks Guys!
0
Comment
Question by:sanehpal
  • 2
6 Comments
 
LVL 31

Expert Comment

by:Gareth Gudger
ID: 40398527
What happens if you drop the quotation marks from -Name

So...

"New-AddressList -Name $ssgroupname -RecipientFilter {((Alias -ne $null) -and (UserPrincipalName -like *@$ssdomain))}"
0
 

Author Comment

by:sanehpal
ID: 40398607
i get a At line:1 char:70
+ "New-AddressList -Name '$ssgroupname' -RecipientFilter {((Alias -ne "$null") -an ...
+                                                                      ~~~~~~~~~~~
Unexpected token '$null") -and (UserPrincipalName -like '*@$ssdomain'))}"' in expression or statement.
At line:1 char:75
+ "New-AddressList -Name '$ssgroupname' -RecipientFilter {((Alias -ne "$null") -an ...
+                                                                           ~~~~~~
Unexpected token '") -and (UserPrincipalName -like '*@$ssdomain'))}"' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 40837542
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
0
 

Accepted Solution

by:
sanehpal earned 0 total points
ID: 40837461
Figured it out here is the solution:

Step 1: New-AddressList -Name 'Softaire' -RecipientFilter {((Alias -ne $null) -and (UserPrincipalName -like '*@constco.net'))}

Creates new address list with all users in constco.net


Step 2: New-GlobalAddressList -Name "constcoDomain" -RecipientFilter {((Alias -ne $null) -and (UserPrincipalName -like '*@constco.net'))}

New-OfflineAddressBook -Name "constco-All-OAB" -AddressLists "\constco"

\constco is from New-AddressList created in step 1

Step 3: New-AddressBookPolicy -Name "constcoDomain ABP" -AddressLists "\constco" -OfflineAddressBook \constco-All-OAB -GlobalAddressList "\constcoDomain" -RoomList "\constco"

This combines all the created lists to create a policy
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question