Created
December 17, 2013 11:57
-
-
Save serbrech/8003858 to your computer and use it in GitHub Desktop.
Powershell wrapper around msdeploy.exe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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