exchange-server


Powershell- search array for element and return value, wildcard value and defined criteria


I'm looking for some help selecting an array element based on criteria in PowerShell 2.0.
My example is an array containing some but not all of the below values:
EX-LON1-01
EX-LON1-02
EX-MAN1-01
EX-MAN1-02
EX-NYC1-01
EX-NYC2-02
I want to return either EX-LON1 value if present, if not return either EX-MAN1 value if present, if neither are present return any of the other values.
I have been using the below which seems to work but I'm sure there must be an easier way to achieve the same?
$ReplicaServer=""
$ReplicaServer=$ReplicaArray -like "EX-LON1*"
If ($ReplicaServer.length -lt 1){$ReplicaServer=$ReplicaArray -like "EX-MAN1*"}
If ($ReplicaServer.length -lt 1){$ReplicaServer=$ReplicaArray -like "EX-NYC1*"}
$ReplicaServer=$ReplicaServer | Select -First 1
Any help is greatly appreciated.
(The specific task I'm working on is removal of empty public folders across a number of Exchange Organisations, the array values are replica servers and folders could be on any, some or all of them. I'm using the code block to identify a local replica for the query/delete steps.)

Related Links

Login to OWA using other domain that portal.microsoftonline.com
What can be the cause that STORE_HTML_OK is not set in PR_STORE_SUPPORT_MASK on exchange 2010 on SBS 2011?
EWS - Calendar auto archive
Dynamics CRM 2011 E-Mail Router & Exchange 2010 Cluster Error “Incoming Status: Failure - No results were found”
ICS Email Attachment Not Working for Exchange Users
Reading Exchange Policies
FindItems() and BindToItems() give inconsistent results for EmailMessage.Sender.Address
Exchange 2007 EWSMA - Occasionally Item.Bind(Service,ItemId) fails, even when the item exists
Create Folders and rules in exchange server 2003
How can I determine the “deleted on” date of an item in Exchange using EWS?
What is exchange web services better suited to do than office interop?
Creating usage log report from exchange server
javaMail send email over MSExchange
Query Exchange server using DirectoryServices
PowerShell script to get UTF8?
EWS-manged: Fetch required and optional attendees of appointments

Categories

HOME
cocoapods
office365
nam
apache-nifi
macos-sierra
apple-push-notifications
adfs3.0
selenium-builder
plaid
dependencies
azure-data-lake
firebase-dynamic-links
graphql-js
sympy
selection
driver
parsley.js
multi-step
squirrel-sql
dhcp
sonata
jaspersoft-studio
data-type-conversion
android-permissions
maven-surefire-plugin
channel
ini
firemonkey-style
ipa
uri
jackrabbit-oak
amazon-iam
docx4j
envoy
google-play-developer-api
mongodb-3.4
delayed-job
riotjs
polyml
bluemixtools
optionaldataexception
spooler
httphandler
ssi
return-type
tinyioc
visual-format-language
spring.net
kendo-editor
hmmlearn
prefetch
fitbit
email-injection
nitrousio
qtextedit
jsonix
bilinear-interpolation
django-testing
system.net.mail
raw-sockets
cdo.message
node.js-connect
maximize
mathnet
variable-length-array
arbre
asp.net-web-api-helppages
sqlbase
compositetype
web-api
nssortdescriptor
dc
adwords-apiv201402
webautomation
network-printers
preorder
acceptance-testing
mongo-jackson-mapper
spiral
cyrillic
zend-pdf
popup-blocker
taskkill
image-scanner
photo-management
airprint
raw-data
cleartype
powergui
3270
tso
index.dat
community-server
service-factory

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App