I am trying to write a function that calls an exe. The function is as follows:
function ShowView {
param([string]$name) #Name Parameter
& E:/scripts/clientaccess.exe -sid 000000001234 show view $name
}
It is called later i the script thru this:
foreach ($i in $get_view){
ShowView "$i"
}
And I get the error:
At Z:\script_v2.ps1:21 char:2
+ & <<<< clientaccess.exe -sid 000000001234 show view $name
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
For some reason it will not interpolat $name properly if it is placed after view, however if I put $name on it's own line and comment out the exe line then it will interpolate $name properly. Also if I type a valid value in place of the $name parameter the function runs fine. I cannot understand why putting $name at the end of the exe line does not work.
Any ideas?