Friday, February 24, 2012

Download SharePoint 2010 Pre-Requisites with PowerShell and preparing for installation

With the following PowerShell script you can download the SharePoint 2010 pre-requisite files from internet to a client PC. Copy and past the script code to a new tekst file and save it as a .ps1 file. After that you can run the script from any client with PowerShell 2.0 because the script don't use any SharePoint PowerShell commands.

Import-Module BitsTransfer 
## Prompt for the destination path 
$DestPath = Read-Host -Prompt "- Enter the destination path for downloaded files" 
## Check that the path entered is valid 
If (Test-Path "$DestPath" -Verbose) 
    ## If destination path is valid, create folder if it doesn't already exist 
    $DestFolder = "$DestPath\PrerequisiteInstallerFiles" 
    New-Item -ItemType Directory $DestFolder -ErrorAction SilentlyContinue 
    Write-Warning " - Destination path appears to be invalid." 
    ## Pause 
    Write-Host " - Please check the path, and try running the script again." 
    Write-Host "- Press any key to exit..." 
    $null = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") 
## We use the hard-coded URL below, so that we can extract the filename (and use it to get destination filename $DestFileName) 
## Note: These URLs are subject to change at Microsoft's discretion - check the permalink next to each if you have trouble downloading. 
$UrlList = (""# - Microsoft Sync Framework Runtime v1.0 (x64)  
            ""# "" - Microsoft Chart Controls for the Microsoft .NET Framework 3.5 
            ""# - Microsoft .NET Framework 3.5 Service Pack 1 
            ""# "" - Windows PowerShell 2.0     
            ""# "" - Windows Identity Framework (Win2008 R2) 
            ""# - WCF fix for Win2008 SP2 
            ""# - WCF fix for Win2008 R2 
            ""# "" - Windows Identity Framework (Win2008 SP2) 
            ""# "" - SQL Server 2008 Native Client 
            ""# "" - Microsoft SQL Server 2008 Analysis Services ADOMD.NET 
            ""# "" - ADO.NET Data Services v1.5 CTP2 (Win2008 SP2) 
            ""# - IIS management cmdlets 
            ""# - SQL 2008 R2 Reporting Services SharePoint 2010 Add-in 
            ""# - Microsoft Server Speech Platform Runtime 
            "" # - Microsoft Server Speech Recognition Language - TELE(en-US) 
ForEach ($Url in $UrlList) 
    ## Get the file name based on the portion of the URL after the last slash 
    $DestFileName = $Url.Split('/')[-1] 
        ## Check if destination file already exists 
        If (!(Test-Path "$DestFolder\$DestFileName")) 
            ## Begin download 
            Start-BitsTransfer -Source $Url -Destination $DestFolder\$DestFileName -DisplayName "Downloading `'$DestFileName`' to $DestFolder" -Priority High -Description "From $Url..." -ErrorVariable err 
            If ($err) {Throw ""} 
            Write-Host " - File $DestFileName already exists, skipping..." 
        Write-Warning " - An error occurred downloading `'$DestFileName`'" 
## View the downloaded files in Windows Explorer 
Invoke-Item $DestFolder 
## Pause 
Write-Host "- Downloads completed, press any key to exit..." 
$null = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
After the script is executed and the prerequisite files are downloaded, place them in the 
PrerequisiteInstallerFiles of the extracted SharePoint install folder structure.
The next step is to create a tekst file with the name PrerequisiteInstaller.Arguments.txt
Copy and paste the code below to the PrerequisteInstaller.Arguments.txt file and save it.
Place the PrerequisteInstaller.Arguments.txt file in the root of the extracted SharePoint folder structure.

/SQLNCli:PrerequisiteInstallerFiles\sqlncli.msi /ChartControl:PrerequisiteInstallerFiles\MSChart.exe /NETFX35SP1:PrerequisiteInstallerFiles\dotnetfx35.exe /PowerShell:PrerequisiteInstallerFiles\Windows6.0-KB968930-x64.msu /KB976394:PrerequisiteInstallerFiles\Windows6.0-KB976394-x64.msu /KB976462:PrerequisiteInstallerFiles\Windows6.1-KB976462-v2-x64.msu /IDFXR2:PrerequisiteInstallerFiles\Windows6.1-KB974405-x64.msu /Sync:PrerequisiteInstallerFiles\Synchronization-v2.0-x64-ENU.msi /Sync:PrerequisiteInstallerFiles\Synchronization.msi /FilterPack:PrerequisiteInstallerFiles\FilterPack64bit.exe /ADOMD:PrerequisiteInstallerFiles\SQLSERVER2008_ASADOMD10.msi /ReportingServices:PrerequisiteInstallerFiles\rsSharePoint.msi /Speech:PrerequisiteInstallerFiles\SpeechPlatformRuntime.msi /SpeechLPK:PrerequisiteInstallerFiles\MSSpeech_SR_en-US_TELE.msi

Note: The code above is one line with one space before each / character.

After this you can run the PrerequisteInstaller.exe and the Prerequiste for SharePoint 2010 will be installed on the server.

No comments: