Solved

Excel / Powershell  If statement with 3 variables

Posted on 2014-09-11
2
192 Views
Last Modified: 2014-09-11
Dear experts,

could anybody help me with this formula below?

If GAL =  -CustomAttribute4 'T' -CustomAttribute8 'LS' -CustomAttribute10 'LS' -CustomAttribute14 'HAD'
and SMTP =  '"&I2&"','"&J2&"','"&K2&"','SMTP:"&F2&"','smtp:"&G2&"','smtp:"&H2&

if GUL = -CustomAttribute4 'T' -CustomAttribute10 'LTS' -CustomAttribute14 'HAD'
and SMTP =  '"&I2&"','"&J2&"','"&K2&"','SMTP:"&F2&"','smtp:"&G2&"

all other not GUL or GAL = -CustomAttribute4 '"&P2&"  -CustomAttribute10 'LT' -CustomAttribute14 'HAD'
and SMTP =  '"&I2&"','"&J2&"','"&K2&"','SMTP:"&F2&"','smtp:"&G2&"  (same as "GUL")

I tried this behind but failed ;)  Thanks in advance!


="Start-Sleep -s 10;Set-Mailbox "&IF(ISERROR(SEARCH("GAL",L2)),IF(ISERROR(SEARCH("GUL",L2)),&" -CustomAttribute4 'T' -CustomAttribute8 'LS' -CustomAttribute10 'LS' -CustomAttribute14 'HAD' -EmailAddressPolicyEnabled $false -SingleItemRecoveryEnabled $true -EmailAddresses '"&I2&"','"&J2&"','"&K2&"','SMTP:"&F2&"','smtp:"&G2&"','smtp:"&H2&"' -Identity "&A2&"",A2&" -CustomAttribute4 'T' -CustomAttribute10 'LTS' -CustomAttribute14 'HAD' -EmailAddressPolicyEnabled $false -SingleItemRecoveryEnabled $true -EmailAddresses '"&I2&"','"&J2&"','"&K2&"','SMTP:"&F2&"','smtp:"&G2&"'-Identity "&A2&"))"

="Start-Sleep -s 10;Set-Mailbox "&IF(ISERROR(SEARCH("GAL",L2)),IF(ISERROR(SEARCH("GUL",L2)),&" -CustomAttribute4 'T' -CustomAttribute8 'LS' -CustomAttribute10 'LS' -CustomAttribute14 'HAD' -EmailAddressPolicyEnabled $false -SingleItemRecoveryEnabled $true -EmailAddresses '"&I2&"','"&J2&"','"&K2&"','SMTP:"&F2&"','smtp:"&G2&"','smtp:"&H2&"' -Identity "&A2&"",A2&" -CustomAttribute4 'T' -CustomAttribute10 'LTS' -CustomAttribute14 'HAD' -EmailAddressPolicyEnabled $false -SingleItemRecoveryEnabled $true -EmailAddresses '"&I2&"','"&J2&"','"&K2&"','SMTP:"&F2&"','smtp:"&G2&"'-Identity "&A2&"))"

Open in new window

0
Comment
Question by:Mandy_
2 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40316712
pls try

="Start-Sleep -s 10;Set-Mailbox  -CustomAttribute4 '"&IF(ISERROR(SEARCH("GAL",L2)),IF(ISERROR(SEARCH("GUL",L2)),P2&"' -CustomAttribute10 'LT' -CustomAttribute14 'HAD' -EmailAddressPolicyEnabled $false -SingleItemRecoveryEnabled $true -EmailAddresses '"&I2&"';'"&J2&"';'"&K2&"';'SMTP:"&F2&"';'smtp:"&G2,"T' -CustomAttribute10 'LTS' -CustomAttribute14 'HAD' -EmailAddressPolicyEnabled $false -SingleItemRecoveryEnabled $true -EmailAddresses '"&I2&"';'"&J2&"';'"&K2&"';'SMTP:"&F2&"';'smtp:"&G2),"T' -CustomAttribute8 'LS' -CustomAttribute10 'LS' -CustomAttribute14 'HAD' -EmailAddressPolicyEnabled $false -SingleItemRecoveryEnabled $true -EmailAddresses '"&I2&"';'"&J2&"';'"&K2&"';'SMTP:"&F2&"';'smtp:"&G2&"';'smtp:"&G2)&"' -Identity "&A2
0
 
LVL 2

Author Closing Comment

by:Mandy_
ID: 40316886
perfect as usual. Great work!
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Set OWA language and time zone in Exchange for individuals, all users or per database.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

910 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

24 Experts available now in Live!

Get 1:1 Help Now