Deploy-QlikServerUpgrade.ps1

function Deploy-QlikServerUpgrade {
    <#
    .SYNOPSIS
    This function ...
 
    .DESCRIPTION
    A bit more description
 
    .PARAMETER FromPipeline
    Shows how to process input from the pipeline, remaining parameters or by named parameter.
 
    .EXAMPLE
    Deploy-QlikServerUpgrade 'abc'
 
    Description of the example.
 
    #>


    <# Enable -Confirm and -WhatIf. #>
    [CmdletBinding(SupportsShouldProcess = $true)]
    param(
        [parameter(Mandatory=$true)]
    [string] $MachineName,
    [parameter(Mandatory=$false)]
    [string] $InstallerPath = 'C:\QlikSenseInstall\Qlik_Sense_setup.exe',
    [parameter(Mandatory=$false)]
    [System.Management.Automation.PSCredential] $mycreds,
    [parameter(Mandatory=$false)]
    [string] $InstallerUserPassword = 'P@ssword123',
    [parameter(Mandatory=$false)]
    [string] $DBPassword = 'Qlikt0g$'
    )

    begin {
    }

    process {

$session = New-PSSession -ComputerName $MachineName -Credential $mycreds

Invoke-Command -Session $session -ScriptBlock{
param([string] $InstallerPath, [string] $installerUserPassword, [string]$dBPassword)
gci 'C:\Program Files\WindowsPowerShell\Modules'  -Recurse | Unblock-File

$arguments = '-s -log "C:\Migrate\spc\upgradelog1.txt" skipvalidation=1'
$arguments += (' userpassword=' +($installerUserPassword) ) 
$arguments += (' dbpassword=' + ($dBPassword)  ) 

Start-Process $installerPath $arguments  -Wait -Verbose #TODO: Run with debug on Cisco machine

}  -ArgumentList ($InstallerPath, $InstallerUserPassword, $DBPassword)

}

    end {
    }
}

if ($loadingModule) {
    Export-ModuleMember -Function 'Deploy-QlikServerUpgrade'
}