1

I want to run following command in Powershell: AFImport.exe

[https://docs.osisoft.com/bundle/pi-server/page/afimport-utility.html][1]

Syntax Example #1

AFImport "\\AFServer\database" /File:"C:\Filename.xml" /P

Now I made following code:

Set-Location -Path "$Env:pihome64\AF"
$xml = "C:\Temp\test.xml"
$AF = "\\AFtest\AF-test"
$log = "C:\Temp\log.txt"
Start-Process AFImport.exe -ArgumentList '$AF','File:$xml','/P' -Wait -RedirectStandardOutput $log

When executting the script the CMD window an runs AFImport.exe but nothing is shown and closes after a few seconds.

What syntac error do I have?

Jonas
  • 67
  • 1
  • 9
  • 1
    use double quotes for *interpolation* of your variables to occur. – Abraham Zinala Jul 13 '22 at 14:30
  • 1
    If you want string interpolation, you need to use double-quotes. e.g. `'File:$xml'` => `"File:$xml"`. Also, it looks like you are missing a `/` from that parameter: `"/File:$xml"` – boxdog Jul 13 '22 at 14:30
  • 1
    so correct command would be: Start-Process AFImport.exe -ArgumentList '$AF',"/File:$xml",'/P' -Wait no results, same windows opens but closes after seconds – Jonas Jul 13 '22 at 14:49

0 Answers0