Skip to content

Instantly share code, notes, and snippets.

@colinbowern
Created July 5, 2013 18:59
Show Gist options
  • Save colinbowern/5936533 to your computer and use it in GitHub Desktop.
Save colinbowern/5936533 to your computer and use it in GitHub Desktop.
Trying to call MSDeploy from PowerShell but it keeps quoting my source/dest parameters. https://connect.microsoft.com/PowerShell/feedback/details/792571/native-application-command-line-parameters-parsing
function Set-WebSiteOffline {
param(
[Parameter(Mandatory=$true)][string]$ServerName,
[Parameter(Mandatory=$true)][string]$SiteName,
[string]$UserName,
[string]$Password
)
$EncodedSiteName = [System.Web.HttpUtility]::UrlEncode($SiteName);
$SiteManagementEndpoint = "https://$ServerName.contoso.com:8172/MSDeploy.axd?Site=$EncodedSiteName";
$Verb = "-verb:sync";
$Source = "-source:contentPath='`"$SiteName/App_Offline.htm.deploy`"',computername='$SiteManagementEndPoint'"
$Destination = "-dest:contentPath='`"$SiteName/App_Offline.htm`"',computername='$SiteManagementEndPoint'"
$Verbose = "-verbose";
$DoNotDeleteRule = "-enableRule:DoNotDeleteRule";
if($UserName -ne "")
{
$Source = $Source + ",username='$ENV:UserDomain\$UserName',password='$Password'";
$Destination = $Destination + ",username='$ENV:UserDomain\$UserName',password='$Password'";
}
$MSDeployArguments = $Verb, $Source, $Destination, $Verbose, $DoNotDeleteRule;
& $MSDeploy $MSDeployArguments
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment