Skip to content

Instantly share code, notes, and snippets.

@BasLijten
Created April 11, 2018 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BasLijten/3a195a0b0718db9953c905751b773b22 to your computer and use it in GitHub Desktop.
Save BasLijten/3a195a0b0718db9953c905751b773b22 to your computer and use it in GitHub Desktop.
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$PackagePath,
[Parameter(Mandatory=$True)]
[string]$ParamFile,
[Parameter(Mandatory=$False)]
[string]$PackageDestinationPath = $($PackagePath).Replace(".scwdp.zip", "-nodb.scwdp.zip")
)
$msdeploy = "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
$verb = "-verb:sync"
$source = "-source:package=`"$PackagePath`""
$destination = "-dest:package=`"$($PackageDestinationPath)`""
$declareParamFile = "-declareparamfile=`"$($ParamFile)`""
$declareParam = "-declareparam:name=`"IIS Web Application Name`",kind=ProviderPath,scope=IisApp,match=Website,defaultValue=vanilla"
$skipDbFullSQL = "-skip:objectName=dbFullSql"
$skipDbDacFx = "-skip:objectName=dbDacFx"
# read parameter file
[xml]$paramfile_content = Get-Content -Path $ParamFile
$paramfile_paramnames = $paramfile_content.parameters.parameter.name
$params = ""
foreach($paramname in $paramfile_paramnames){
$tmpvalue = "tmpvalue"
if($paramname -eq "License Xml"){ $tmpvalue = "LicenseContent"}
if($paramname -eq "IP Security Client IP"){ $tmpvalue = "0.0.0.0"}
if($paramname -eq "IP Security Client IP Mask"){ $tmpvalue = "0.0.0.0"}
$params = "$params -setParam:`"$paramname`"=`"$tmpvalue`""
}
# create new package
Invoke-Expression "& '$msdeploy' --% $verb $source $destination $declareParam $declareParamFile $skipDbFullSQL $skipDbDacFx $params"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment