Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently using the package dest to create a backup of a site as follows:

msdeploy.exe -source:appHostConfig="Default Web Site",computerName="https://server:8172/MSDeploy.axd?site=Default Web Site",userName="abc",password="xyz",authtype="basic" 
-dest:package="c:\backup\" -verb:sync

Here, the destination is a local file. Is it possible to make the target a location on the remote server itself? I'm running the command from my build server, but I'd like the backup to be created and stored on the remote server instead of being downloaded to the build machine.

This will be running against a public server, so shared folders are out of the question. What other options do I have?

share|improve this question
up vote 0 down vote accepted

Yes, with a -source:runCommand, but first you should put the script there (a batch for example)

from: Bellow is a simple PowerShell script that has two functions. Send-Files – Synchronizes a local folder to a remote server. Execute-RemoteCommand – Executes a batch file on a remote server. The file must already be in place on the server.

$MSDeployExe = "C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe"
$RemoteHost = "http://localhost:80/MsDeployAgentService"
$Credentials = ""
$LocalDir = "C:\temp\LocalDir"
$RemoteDir = "C:\temp\RemoteDir"

function Send-Files {
        param (

        Write-Host "Sending files to $WebDeployService`: $RemoteDir" -ForegroundColor Yellow

        if ($Credentials -ne "") {
                $Credentials = ",getCredentials=" + $Credentials

        & $MSDeployExe "-verb:sync" "-source:dirPath=$LocalDir" "-dest:dirPath=$RemoteDir,computername=$WebDeployService$Credentials" "-verbose"
        $successful = $?

        if (-not $successful) {
                throw "Failed sending files"

function Execute-RemoteCommand {
        param (
                [int]$waitInterval = 15000

        $command = Join-Path $RemoteDir $BatchFile
        Write-Host "Executing $command on $WebDeployService" -ForegroundColor Yellow

        & $MSDeployExe "-verb:sync" "-source:runCommand=’$command’,waitInterval=$waitInterval,waitAttempts=1" "-dest:auto,computername=$RemoteHost$Credentials" "-verbose"

        $successful = $?

        if (-not $successful) {
                throw "Failed executing command"

# Test
Send-Files $RemoteHost $LocalDir $RemoteDir $Credentials
Execute-RemoteCommand $RemoteHost $RemoteDir "HelloWorld.bat" $Credentials
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.