In my script, I extract a word in 3rd position, from a path.
I then need to insert this word in a text, such as
Add-Content -Path $sFullPath -Value "NFSettingFile=C:\NG_auto_project\config\$word.ini"
BUT if that word matches certain characters/words it should write 'default'. I worked it out with an IF statement but saw that Microsoft says that with lots of conditions it's better to use the switch parameter. In either way, the following script doesn't work as I expect:
switch($Word)
{
{$_ -eq "ODDX"} {"default"}
{$_ -eq "ODCL"} {"default"}
{$_ -eq "CRC"} {"default"}
{$_ -eq "CPKRAS"} {"default"}
{$_ -eq "OTDX"} {"default"}
{$_ -eq "ODTRC"} {"default"}
}
The problems is that it changes everything unto 'default' and that's not what I want. I only need to have the words change to default IF they do not match one of these characters.
Do you see what I'm doing wrong?