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

Can't retrieve Appointment.StartTimeZone through EWS Managed API on Exchange 2007 SP1
Why is Microsoft Exchange so popular? [closed]
Is it Possible to develop an App to lock a users exchange calendar?
How can I retrieve the last IP address of a user in Microsoft Exchange
How can I access/move handles of a dijit.slider or Dojox.RangeSlider on external input
How do I discover all mailboxes for an Exchange Server using Exchange Web Services?
Test Exchange EWS on public server
IMAP protocol support in different email servers
Using EWS Managed API to create appointments for other users?
Detect if Exchange MAPI is installed
How do I retrieve global contacts with Exchange Web Services (EWS)?
How can I monitor the Exchange 2003 Event Service from my application?
Exchange server - Save copy of outgoing email message in a public folder
Downloading attachments from Exchange with WebDAV
Are extra installs needed to access Managed EWS on an Exchange 2010 server?
Exchange: Is it possible to search for a custom Extended Property across all mailboxes?

Categories

HOME
xpath
user-interface
knockout.js
keyboard
verification
yii
ant
histogram
websocket
jersey-2.0
mathematical-optimization
u-boot
static-analysis
wine
watch-os-3
cname
spring-jpa
complexity-theory
asp.net-core-1.0
wsf
bsd
ratio
react-dnd
environment
fusetools
hdmi
points
basex
annotation-processing
tsung
dnsmasq
premake
epplus
shapeless
rails-postgresql
formsauthenticationticket
redgate
jade4j
stat
netapp
vb.net-to-c#
raytracing
contactless-smartcard
liteide
spongycastle
realstudio
icecast
sequence-diagram
htmlspecialchars
asp.net-web-api-routing
lvalue
case-when
mechanicalturk
nclam
openquery
noclassdeffounderror
exists
gwt-syncproxy
cortana
ora-04091
featuretoggle
css-paged-media
karma-coverage
innerhtml
fiware-bosun
configurable-product
xhprof
communicate
android-2.3-gingerbread
accessory
windows-messages
incognito-mode
spring-social-linkedin
django-sites
armv6
xsd2code
grails-2.3
unrealscript
insertonsubmit
ax
examine
django-filebrowser
image-formats
memory-pool
mmc3
servercontrol
haiku
play2-mini
multiple-users
j2mepolish
spring-modules
isapi-redirect

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