Issue with If Elseif Else based on xml node value

I’m still very new to Powershell and having trouble finding a solution for this. I’ve had to divert from reading a regkey to xml file.
The xml below is altered and stores the new value when a tech changes the default from a utility interface.
When I run the italic portion below… I get the changed value. My If / Elseif/ Else statement following doesn’t seem to be working based on the returned value. Can someone point me in the right direction? I need a second pair of eyes to point out what I’m missing here. Also, I only want the Else message to occur if the option is anything other than the two models used.
Huge Thanks!

$src_dir1 = ‘C:\Program Files (x86)\Kofax Scan Development\Kofax Set Default Scanner\Fujitsu 7160’
$src_dir2 = ‘C:\Program Files (x86)\Kofax Scan Development\Kofax Set Default Scanner\Fujitsu 7260’
$dst_dir1 = ‘C:\ProgramData\Kofax\Vrs’
$dst_dir2 = ‘C:\Program Files (x86)\Kofax\Capture\ImgCtls\bin\Profiles’

If (Test-Path -Path ‘C:\Program Files (x86)\Kofax\Capture\ImgCtls\Bin\ScannerConfigUtil.exe’) {
Start-Process -FilePath ‘C:\Program Files (x86)\Kofax\Capture\ImgCtls\Bin\ScannerConfigUtil.exe’ -Wait
}

If (Test-Path -Path ‘C:\Program Files (x86)\Kofax\ImgCtls\Bin\ScannerConfigUtil.exe’) {
Start-Process -FilePath ‘C:\Program Files (x86)\Kofax\ImgCtls\Bin\ScannerConfigUtil.exe’ -Wait
}

$Path = ‘C:\ProgramData\Kofax\Vrs\kofaxReg.xml’
$XPath = ‘//KOFAX/CONDOR/V1.0/KFXSCAN.PXW/DEFAULT_SOURCE’
Select-xml -Path $Path -XPath $XPath| Select-Object -ExpandProperty node

if ($value -like ‘Fujitsu fi-7160*’){
Copy-Item ‘$src_dir1*.cps’ -Destination ‘$dst_dir2’
Copy-Item ‘$src_dir1\Default traps.cts’ -Destination ‘$dst_dir1’
}
elseif ($value -like ‘Fujitsu fi-7260*’){
Copy-Item ‘$src_dir2*.cps’ -Destination ‘$dst_dir2’
Copy-Item ‘$src_dir2\Default traps.cts’ -Destination ‘$dst_dir1’
}
Else
{
[System.Windows.MessageBox]::Show(‘Please make sure to select Fujitsu fi-7160 or Fujitsu fi-7260’)
}

In the code that you posted you don’t assign the returned value from the select-xml cmdlet to $value. $value isn’t initialised anywhere before the conditional test in you if/ elseif/else.

 

Good catch! Thank you, Robert. It was an exhausting Friday at work and I was starting to slip. lol