Using Powershell to create an offline Web Platform Installer Feed
Hi All,
Thanks to Nitasha we learned that it is possible to create a custom WebPlatformInstaller feed she describes it in her post:
Is there a way to get WebPI to install Products in an offline way?
This is not really a supported scenario but when you are about to go to a convention and have to demo WebPI and you only have convention WIFI you better be prepped for the worsed.
So now we know how to be prepped for the worsed and I started to look at the WebPI feed but it is a HUGE file and I had to download all the packages manual and then set the installerURL etc etc.
To speed up this process I've created the following Powershell file to do this for you.
#Get the WebPL feed (this could be improved by downloading it[xml]$xd = Get-Content "D:\OfflineWebPI\WebProductList.xml"
foreach($entry in $xd.feed.entry)
{
Write-Host $entry.productid
foreach($installer in $entry.installers.installer)
{
if($installer.installerFile.installerURL)
{
if($installer.languageId -eq "en")
{
[string]$url = $installer.installerFile.installerURL
$lastslash = $url.LastIndexOf("/")+1
$filenamelen = $url.Length-$lastslash
$filename = $url.Substring($lastslash,$filenamelen)
$filename = "D:\OfflineWebPI\$filename"
Write-Host "Downloading $filename"
$clnt = New-Object System.Net.WebClient
$clnt.DownloadFile($url,$filename)
$installer.installerFile.installerURL = $filename
}
}
}
}
$xd.Save("D:\OfflineWebPI\WebProductListNew.xml")
I'm blogging this now mainly for my own reference. Will comment the code later.
If you are a hoster you "could" use this to create an in network cache of the web platform packages.
Thanks
Bram