Use PSEXEC as system account to run a powershell script RRS feed

  • Question

  • Hi, I hope you can help!

    I'm trying to write a script which calls psexec as a system account, then, starts powershell as the system account, which is then supposed to run a PS script to install a VPN profile for always on VPN. I can run type in the command manually, and it works, but when I run the bat file, the script returns an error code of 0, but when checking if the the profile is install... it hasn't?

    The script I've written is below, how can I get this to pass the PS commands into the psexec posershell window??

    @echo off
    .\psexec.exe -i -s PowerShell.exe -command {'.\Add VPN.ps1 -xmlFilePath .\Device Tunnel VPN Profile_RemovedTrafficFilter.xml -ProfileName Test_Device_VPN'}

    Thanks in advance

    • Moved by Bill_Stewart Monday, January 7, 2019 8:13 PM This is not PsExec support forum
    Monday, November 12, 2018 2:01 PM

All replies