Function Get - SPLanguagePacks {
param($Path, $DownloadId)
if (!(Test - Path $Path)) {
New - Item $Path - ItemType "Directory"
}
cd $Path
$request = Invoke - WebRequest http: //www.microsoft.com/en-gb/download/details.aspx?id=$DownloadId
[xml] $options = $request.AllElements | where - object {
$_.name - eq "newlocale"
} | select - object - ExpandProperty OuterHtml
$options.select.option | Foreach - object {
$path = $filePath
$text = $_.innerText
$code = $_.value
write - host "Downloading language pack $text "
$fileRequest = Invoke - WebRequest "http://www.microsoft.com/$value/download/confirmation.aspx?id=$DownloadId"
$fileLink = $fileRequest.Links | where - object {
$_.href - like "*.exe" - or $_.href - like "*.img"
} | Select - Object - First 1 - ExpandProperty href
New - Item - ItemType "Directory" - Name $text | out - null
Start - BitsTransfer $fileLink - Destination.\$($text) - Asynchronous - DisplayName "$text Transfer" | Out - Null
}
$transfers = Get - BitsTransfer
write - host "Downloading..." - NoNewline
while (($transfers | where - object {
$_.JobState - eq "Connecting" - or $_.JobState - eq "Transferring"
}).Count - gt 0) {
write - host "." - NoNewline
sleep 5
}
$transfers | Where - Object {
$_.JobState - eq "Transferred"
} | Complete - BitsTransfer
}This code for how to use PowerShell in SharePoint.
