Solved

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

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

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
A procedure for exporting installed hotfix details of remote computers using powershell
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…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now