Deploy-QlikServerBaseSetup.ps1
function Deploy-QlikServerBaseSetup { <# .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-QlikServerBaseSetup 'abc' Description of the example. #> <# Enable -Confirm and -WhatIf. #> [CmdletBinding(SupportsShouldProcess = $true)] param( [parameter(Mandatory=$true)] [string] $MachineName, [parameter(Mandatory=$false)] [string] $SpcConfigPath = 'C:\Migrate\spc.cfg', [parameter(Mandatory=$false)] [string] $InstallerPath = 'C:\QlikSenseInstall\Qlik_Sense_setup.exe', [parameter(Mandatory=$false)] [System.Management.Automation.PSCredential] $mycreds, [parameter(Mandatory=$false)] [string] $InstallerUser = 'qlikuser', [parameter(Mandatory=$false)] [string] $InstallerDomain = '.', [parameter(Mandatory=$false)] [string] $InstallerUserPassword = 'P@ssword123', [parameter(Mandatory=$false)] [string] $DBPassword = 'Qlikt0g$' ) begin { } process { #$secpasswd = ConvertTo-SecureString “P@ssword123” -AsPlainText -Force #$mycreds = New-Object System.Management.Automation.PSCredential (“.\qlikuser”, $secpasswd) [xml] $spccfg = get-content -Path $SpcConfigPath $session = New-PSSession -ComputerName $MachineName -Credential $mycreds Invoke-Command -Session $session -ScriptBlock{ param([xml] $spccfg, [string] $InstallerPath, [string] $installerUser, [string] $installerDomain, [string] $installerUserPassword, [string]$dBPassword) gci 'C:\Program Files\WindowsPowerShell\Modules' -Recurse | Unblock-File #Enable NFS File Share and Map Windows ID in Registry #Adds two new registry DWORD entries to Map Windows ID to be read by Linux Kernel Install-WindowsFeature -Name NFS-Client $ClientNFSpath = "HKLM:\Software\Microsoft\ClientForNFS\CurrentVersion\Default" $AnonymousUID = "AnonymousUid" $AnonymousGID = "AnonymousGid" $UIDValue = "75000" $GIDVAlue = "7500" New-ItemProperty -Path $ClientNFSpath -Name $AnonymousUID -Value $UIDValue -PropertyType DWORD -Force | Out-Null New-ItemProperty -Path $ClientNFSpath -Name $AnonymousGID -Value $GIDValue -PropertyType DWORD -Force | Out-Null #Disable Strict Name Checking #Adds two new registry DWORD entries # $LanManregpath = "HKLM:\system\CurrentControlSet\Services\Lanmanserver\Parameters" $Name = "DisableStrictNameChecking" $Value = "1" New-ItemProperty -Path $LanManregpath -Name $Name -Value $Value -PropertyType DWORD -Force | Out-Null $LSAregpath = "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" $LSAName = "DisableLoopbackCheck" $LSAValue = "1" New-ItemProperty -Path $LSAregpath -Name $LSAName -Value $LSAValue -PropertyType DWORD -Force | Out-Null #Create Service Cluster Share #Root Share required to be available prior to installation of Qlik Sense New-Item C:\QlikShare -ItemType directory $FullAccess = ("Qlikuser" , "Administrators") New-SmbShare -Name "QlikShare" -Path "C:\QlikShare" -FullAccess $FullAccess $path = 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config' $xml = [xml](get-content($path)) $xml.Save($path+ ".old") $runtime = $xml.configuration["runtime"] if($runtime.generatePublisherEvidence -eq $null) { $gc = $xml.CreateElement("generatePublisherEvidence") $gc.SetAttribute("enabled", "false") $runtime.AppendChild($gc) } $runtime.generatePublisherEvidence.enabled = "false"; $xml.Save($path) #Extend ServicesPipeTimeout to correct Services Failed to start in a timely manner error #Adds new registry DWORD entry to extend the default timeout from 30 seconds to 120 seconds $SPTpath = "HKLM:\SYSTEM\CurrentControlSet\Control" $SPTName = "ServicesPipeTimeout" $SPTVAlue = "120000" New-ItemProperty -Path $SPTpath -Name $SPTName -Value $SPTVAlue -PropertyType DWORD -Force | Out-Null ([string] $spccfg.InnerXml).Replace('PSDeploy', $env:COMPUTERNAME) | Out-File ('C:\Migrate\spc.cfg') $arguments = '-s -log "C:\Migrate\spc\installlog1.txt"' $arguments += (' userwithdomain=' + ( $installerDomain + '\'+ $installerUser ) ) $arguments += (' userpassword=' +($installerUserPassword) ) $arguments += (' dbpassword=' + ($dBPassword) ) $arguments += ' sharedpersistenceconfig="C:\Migrate\spc.cfg" ' #$arguments = [String[]] $arguments Start-Process $installerPath $arguments -Wait -Verbose #TODO: Run with debug on Cisco machine } -ArgumentList ($spccfg,$InstallerPath, $InstallerUser, $InstallerDomain, $InstallerUserPassword, $DBPassword) #Get-Content "C:\Migrate\spc\installlog1.txt" -Tail -Wait 1 } end { } } if ($loadingModule) { Export-ModuleMember -Function 'Deploy-QlikServerBaseSetup' } |