Solved

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

Posted on 2014-10-22
6
70 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 70

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
In this video we show how to create an Address List 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 Organization >> Ad…
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…

734 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