Powershell cant read a command with spaces despite the use of " an '

Nowtside 1 Reputation point

I have a script that imports a application bundle and adds an application as a dependency. The command is capable of reading "Application bundle" in quotation marks but is unable to read the program when i use spaces. For instance i have a program called "French bundle". If i change the name of the program to Frenchbundle then the command works, But if i use spacebar the command doesn't work for some reason.

This also seems to apply when i use files with - in the name while files with _ in the name works perfectly fine.

Is there any solution for this?.

Update: i solved the issue by specifying both parent directories before French bundle. It turns out my issue had nothing to do with spacebars.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,431 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. MotoX80 32,441 Reputation points

    If you want to launch wordpad from powershell and account for the space in Program Files, you would do it like this.

    &'C:\Program Files\Windows NT\Accessories\wordpad.exe'
    0 comments No comments

  2. Nowtside 1 Reputation point

    For the record im not looking for a general solution on how to write file names with spaces in. "Application bundle" works just fine and every other command in my script works with spaces, Even when im targeting a specific file.

    The same file that didn't work in this script "French bundle" worked perfectly fine with spaces in another command where i imported it.

    It's just files after -dependency that cant be read with spaces for some reason, Like i mentioned i can import these files with -dependency if i change the files name to French_bundle or Frenchbundle.

    The command understands the quotation marks too since "Frenchbundle" works.