Spaces in Start-Process -filepath issue

Welcome Forums General PowerShell Q&A Spaces in Start-Process -filepath issue

Viewing 2 reply threads
  • Author
    Posts
    • #192661
      Participant
      Topics: 60
      Replies: 90
      Points: 33
      Rank: Member

      I am using start-process to start a RVtools (as that is what my company are using to report on...i know i can use Power-Cli, and I would but for now would like like to embrace existing processes using RVtools and then seek to improve it...).

       

      I am using a method that was shown to me before by passing an argument list.

      I have the relevant sections below:

       

      $vcentre = 'vcentreserver'
      $arglist = '-s {0} ' -f $vcentre
      $path = 'C:\Program Files (x86)\Robware\RVTools'
      $tskParams = @{
      FilePath ="$path\RVTools.exe"
      ArgumentList = $argList
      Wait = $true
      NoNewWindow = $true
      }

      Start-Process $tskParams 

       

      Yet when I run this I get the error :

      Start-Process : This command cannot be run due to the error: The system cannot find the file specified.
      At line:1 char:9
      + Start-Process $tskParams -ErrorVariable test
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
      + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

       

      However when I use

       

      Start-Process -FilePath "C:\Program Files (x86)\Robware\RVTools\RVTools.exe"

      it works. I am not quite sure what is going on....any help appreciated

    • #192664
      Participant
      Topics: 60
      Replies: 90
      Points: 33
      Rank: Member

      Troubleshooted my own error

      When I splatted I used $taskparams instead of @tskparams. Go figure ... 😀

    • #192721
      Participant
      Topics: 10
      Replies: 1375
      Points: 1,481
      Helping Hand
      Rank: Community Hero

      I do it all the time too. I've tried to use editor shortcuts like this:

      Easily Splatting PowerShell with VS Code

      Unfortunately, I'm usually RDP'd to a customer server, so I don't install tools on those devices. If you are fortunate to be using a single editor, they have options for VSCode and Powershell ISE to create a hotkey for auto-formmatting a splat.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.