Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1011917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:51:56+00:00 2026-05-16T09:51:56+00:00

I’m running into a problem with spaces in my parameters that I try to

  • 0

I’m running into a problem with spaces in my parameters that I try to send into msdeploy from a powershell script.

There are a number of other related articles but none of them solve the problem.

Problems Using Power Shell And MSDeploy.

Similar SO issue that doesn’t work: How to run exe in powershell with parameters with spaces and quotes

PowerShell BUG: Executing commands which require quotes and variables is practically impossible

Another SO issue that doesn’t work:Passing parameters in PowerShell 2.0

The simplest example that succeeds and then fails when I make it more complicated is just dumping the default web site.

$msdeploy = “C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe”

&$msdeploy -verb:dump -source:appHostConfig=`’default web site`’ -verbose

==SUCCESS

This one?

$sitename=”default web site”

&$msdeploy -verb:dump -source:appHostConfig=$sitename -verbose

==FAIL with the following error

msdeploy.exe : Error: Unrecognized argument ‘”-source:”appHostConfig=default’. All arguments must begin with “-“.

At C:\xxx\test.ps1:122 char:6

+ &

+ CategoryInfo : NotSpecified: (Error: Unrecogn…begin with “-“.:String) [], RemoteException

+ FullyQualifiedErrorId : NativeCommandError

Error count: 1.

The following variations have also failed

#FAIL

$sitename=`’default web site`’

$sitename=`'”default web site”`’

$sitename=”`’default web site`'”

$sitename=”default web site”

$sitename=”‘default web site'”

&$msdeploy -verb:dump “-source:appHostConfig=$sitename” -verbose

&$msdeploy -verb:dump -source:appHostConfig=”$sitename” -verbose

&$msdeploy -verb:dump -source:appHostConfig=’$sitename’ -verbose

&$msdeploy -verb:dump -source:appHostConfig=`’$sitename`’ -verbose

&$msdeploy -verb:dump -source:appHostConfig=`”$sitename`” -verbose

I’m at a loss. Everyone I work with is at a loss. Seriously this sucks. I loved Powershell. I loved msdeploy. I can’t say that I love putting them together. It looks like it may have been easier to focus on the API instead of the cli.

EDIT:

The parameters in the string array suggested by Emperor XLII works well. An alternative solution is presented in the following article: The trials and tribulations of using MSDeploy with PowerShell

function PushToTarget([string]$server, [string]$remotePath, [string]$localPath) {
    cmd.exe /C $("msdeploy.exe -verb:sync -source:contentPath=`"{0}`" -dest:computerName=`"{1}`",contentPath=`"{2}`" -whatif" -f $localPath, $server, $remotePath )
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T09:51:56+00:00Added an answer on May 16, 2026 at 9:51 am

    Using the technique from Keith’s answer to How to run exe in powershell with parameters with spaces and quotes question you linked to, running echoargs -verb:dump -source:appHostConfig=$sitename -verbose gave me this output:

    Arg 0 is <-verb:dump>
    Arg 1 is <-source:appHostConfig=default>
    Arg 2 is <web>
    Arg 3 is <site>
    Arg 4 is <-verbose>
    

    This would explain the invalid argument of appHostConfig=default that msdeploy was seeing.

    Running echoargs -verb:dump "-source:appHostConfig=$sitename" -verbose, with $sitename = "default web site", appears to result in the desired arguments:

    Arg 0 is <-verb:dump>
    Arg 1 is <-source:appHostConfig=default web site>
    Arg 2 is <-verbose> 
    

    Though from your list, it appears that this did not work for you.

    Another method you might try is building up the list of arguments in an array, which powershell can automatically escape. For example, this gives the same output as above:

    [string[]]$msdeployArgs = @(
      "-verb:dump",
      "-source:appHostConfig=$sitename",
      "-verbose"
    )
    echoargs $msdeployArgs
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.