简体   繁体   中英

Powershell IF statement syntax issue

I am having some issues with getting a part of my script to work.

Say that $SEMFINAL = /O=Default/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=name1 name2@email.com

IF ($SEMFINAL -match "name1 name2@email.com") {Set-variable -name SEMIFINAL -value "name1.name2@email.com"}

I have tried using set-variable and just $A = B but it isnt working.

You need to wrap your string in single quotes:

$SEMFINAL = '/O=Default/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=name1 name2@email.com'

then:

IF ($SEMFINAL -match "name1 name2@email.com") {$SEMFINAL = "name1..name2@email.com"}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM