Skip to content

Instantly share code, notes, and snippets.

@serbrech
Created December 17, 2013 11:57
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serbrech/8003858 to your computer and use it in GitHub Desktop.
Save serbrech/8003858 to your computer and use it in GitHub Desktop.
Powershell wrapper around msdeploy.exe
function DeployWebsite($Package, $Server, $IISSite, $App, $Username, $Password) {
$MSDeployKey = 'HKLM:\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\3'
if(!(Test-Path $MSDeployKey)) {
throw "Could not find MSDeploy. Use Web Platform Installer to install the 'Web Deployment Tool' and re-run this command"
}
$InstallPath = (Get-ItemProperty $MSDeployKey).InstallPath
if(!$InstallPath -or !(Test-Path $InstallPath)) {
throw "Could not find MSDeploy. Use Web Platform Installer to install the 'Web Deployment Tool' and re-run this command"
}
$msdeploy = Join-Path $InstallPath "msdeploy.exe"
if(!(Test-Path $MSDeploy)) {
throw "Could not find MSDeploy. Use Web Platform Installer to install the 'Web Deployment Tool' and re-run this command"
}
$PublishUrl = "https://$($Server):8172/MSDeploy.axd?site=$($IISSite)"
$WebApp = "$IISSite/$App"
# DEPLOY!
Write-Host "Deploying package to $PublishUrl for $($App)"
$arguments = [string[]]@(
"-verb:sync",
"-source:package='$Package'",
"-dest:auto,computerName='$PublishUrl',userName='$UserName',password='$Password',authtype='Basic'",
"-setParam:name='IIS Web Application Name',value='$($WebApp)'",
"-allowUntrusted")
Start-Process $msdeploy -ArgumentList $arguments -NoNewWindow -Wait
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment