This script uses a local installation of WAP Websites to create an Offline installation package. This can be particularly useful if you need to re-install WAP Websites or add it to an installation at a later date.You will need to run this as the same user that has WAP Websites in



[Parameter(Mandatory=$false,HelpMessage="Must end with .zip")]
[string]$FilePath = "$env:userprofile\Downloads\"

#Find the latest Websites.exe in the local app data

#Get the latest folder by installation date
$websitesFile = Get-ChildItem -Path "$env:LOCALAPPDATA\Microsoft\Web Platform Installer\installers" | ?{$_.Name -match "websites"} | Sort-Object LastWriteTime -Descending | Select -First 1
if((Get-ChildItem -Path $websitesFolder.FullName).Length -gt 1){
#More than one installation, find the latest
$websitesFile = Get-ChildItem -Path $websitesFolder.FullName | Sort-Object LastWriteTime -Descending | Select -First 1
} else {
$websitesFile = Get-ChildItem -Path $websitesFolder.FullName | Select -First 1
Write-Verbose "Using the `"$($websitesFile.FullName)`" file to download Azure Pack Websites"

#Build Process
$OfflineDownloadArgs = "/quiet /log `"$("$env:TEMP\AzurePackWebsitesDownload.log")`" CreateOfflineInstallationPackage OfflineInstallationPackeFile=`"$FilePath`""
Write-Verbose "Using the following arguements: $OfflineDownloadArgs"

Write-Verbose "Staring download to `"$FilePath`""
$DownloadProc = Start-Process -FilePath $websitesFile -ArgumentList $OfflineDownloadArgs -Wait -PassThru
Write-Error $_
Exit $DownloadProc.ExitCode
Write-Verbose "Process complete"