Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

Spaces Cause Split in Path With PowerShell

July 11, 2024
in A, Blog, Powershell
0
ADVERTISEMENT

Table of Contents

Spaces Cause Split in Path With PowerShell

In some cases, you want to invoke an executable file with the path containing spaces in PowerShell.

Invoke-Expression "C:\Program Files\PuTTY\putty.exe"

But you got the below error. The space is special character, PowerShell will break the command after it.

UseLfKMhdRYP55TSNeROF6EbirfTUnQZytmMn5OvmvhUyapjDJuSk7MxUBqD

Using the dot notation

To bypass this, you can round the path with single quote instead of double quote and use the dot (.) notation to call the program.

Invoke-Expression ". 'C:\Program Files\PuTTY\putty.exe'"

As you can see, the error message was gone, and the app launches as expected.

cDkozFazOOqKwSZogthnuRs46HjC9xh4swzVVhsv3d80WsydzqBkrCWaB2JV

Use the call operator

The second way, we can use the call operator (&), to invoke commands whose names or paths are stored in quoted strings and/or are referenced via variables.

Invoke-Expression "& 'C:\Program Files\PuTTY\putty.exe'"
YbUfWOTCsqYBGDeMik8gkTtZ8ch91czatTvJQhwRXiAW3YqkYnqYzRFOBTdn

Use the backtick

The third way, you can escape the space by using single quotations and a backtick before the space. You also need to round the path with a single quote.

Invoke-Expression 'C:\Program` Files\PuTTY\putty.exe'
BPdr7nrxTQ8wFUbXyNVqbmqtUWklOWhob8JdFSqXbADjqEm7n2TLlLkrgDYi

Use the Start-Process cmdlet

And the last way, you can use the Start-Process to call a program that has path or file name contain spaces.

Start-Process -PSPath "C:\Program Files\PuTTY\putty.exe"
ADVERTISEMENT

Not a reader? Watch this related video tutorial:

5/5 - (1 vote)
Previous Post

Read-Host Path With Space in PowerShell

Next Post

How to Fix The Disk Structure Is Corrupted and Unreadable USB Drive

Related Posts

Images Hidden Due To Mature Content Settings In CivitAI

August 31, 2024

Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

August 20, 2024

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024

How to Remove The Test Mode Watermark Without Disabling Test Mode

July 28, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory