Solved

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

Posted on 2014-10-22
6
68 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this video we show how to create a mailbox database 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 Servers >> Data…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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