Get-ISHPrerequisites.ISH12.ps1

<#
# Copyright (c) 2014 All Rights Reserved by the SDL Group.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#>


function Get-ISHPrerequisites
{
    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$true,ParameterSetName="From FTP")]
        [string]$FTPHost,
        [Parameter(Mandatory=$true,ParameterSetName="From FTP")]
        [pscredential]$Credential,
        [Parameter(Mandatory=$true,ParameterSetName="From FTP")]
        [string]$FTPFolder,
        [Parameter(Mandatory=$true,ParameterSetName="No Download")]
        [switch]$FileNames
    )
    
    begin 
    {
        if($PSCmdlet.ParameterSetName -ne "No Download")
        {
            . $PSScriptRoot\Test-RunningAsElevated.ps1
            Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet
        }

        . $PSScriptRoot\Get-ISHServerFolderPath.ps1
        . $PSScriptRoot\Get-ISHOSInfo.ps1
    }

    process
    {
        $filesToDownload=@(
            #Common for 12 and 13
            "jdk-8u60-windows-x64.exe"
            "jre-8u60-windows-x64.exe"
            "javahelp-2_0_05.zip"
            "htmlhelp.zip"
            "V6-2-M9-Windows_X64_64E.exe"
            "V6-2-M9-Windows_X64_64E.exe.iss"
            "V6-2-M9-Windows_X64_64E.exe.vcredist_x64.exe"
            "V6-2-M9-Windows_X64_64E.exe.vcredist_x86.exe"
            "ODTwithODAC121012.zip"
            "ODTwithODAC121012.rsp"

            #Specific for 12
            "MSXML.40SP3.msi"
            "NETFramework2013_4.5_MicrosoftVisualC++Redistributable_(vcredist_x64).exe"
        )
        $osInfo=Get-ISHOSInfo
        if($osInfo.IsCore)
        {
            $filesToDownload+="vbrun60sp6.exe"
        }

        switch ($PSCmdlet.ParameterSetName)
        {
            'From FTP' {
                Import-Module PSFTP -ErrorAction Stop
                $localPath=Get-ISHServerFolderPath
                Set-FTPConnection -Server $FTPHost -Credentials $Credential -UseBinary -KeepAlive -UsePassive | Out-Null
                $filesToDownload | ForEach-Object {
                    $ftpUrl="$FTPFolder$_"

                    Write-Debug "ftpUrl=$ftpUrl"
                    Get-FTPItem -Path $ftpUrl -LocalPath $localPath -Overwrite | Out-Null
                    Write-Verbose "Downloaded $ftpUrl"
                }
                break        
            }
            'No Download' {
                if($FileNames)
                {
                    $filesToDownload
                }
                break
            }
        }
    }

    end
    {

    }
}