EdTrud
EdTrud

Reputation: 15

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 [email protected]

IF ($SEMFINAL -match "name1 [email protected]") {Set-variable -name SEMIFINAL -value "[email protected]"}

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

Upvotes: 0

Views: 166

Answers (1)

Jimbo
Jimbo

Reputation: 2537

You need to wrap your string in single quotes:

$SEMFINAL = '/O=Default/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=name1 [email protected]'

then:

IF ($SEMFINAL -match "name1 [email protected]") {$SEMFINAL = "[email protected]"}

Upvotes: 1

Related Questions