Deploy-QlikServerLicensing.ps1
function Deploy-QlikServerLicensing { <# .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-QlikServerLicensing 'abc' Description of the example. #> <# Enable -Confirm and -WhatIf. #> [CmdletBinding(SupportsShouldProcess = $true)] param( [parameter(Mandatory=$true)] [string] $MachineName, [parameter(Mandatory=$true)] [string] $SerialNumber, [parameter(Mandatory=$true)] [string] $ControlNumber, [parameter(Mandatory=$false)] [System.Management.Automation.PSCredential] $mycreds , [parameter(Mandatory=$true)] [string] $OwnerName, [parameter(Mandatory=$true)] [string] $Organization, [parameter(Mandatory=$false)] [string] $Lef = (Read-Host -Prompt 'Paste LEF Content') ) begin { } process { #$secpasswd = ConvertTo-SecureString $Password -AsPlainText -Force #$mycreds = New-Object System.Management.Automation.PSCredential (($Domain + '\' + $UserName), $secpasswd) $session = New-PSSession -ComputerName $MachineName -Credential $mycreds Enter-PSSession -Session $session Invoke-Command -Session $session -ScriptBlock{ param( [string] $serialNumber, [string] $controlNumber, [string] $organization, [string] $ownerName, [string] $lef) gci 'C:\Program Files\WindowsPowerShell\Modules' -Recurse | Unblock-File #Trust All Certs add-type @' using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy { public bool CheckValidationResult( ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) { return true; } } '@ [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS12 Connect-Qlik Set-QlikLicense -control $controlNumber -name $ownerName -serial $serialNumber -organization $organization -lef $lef } -Args ($SerialNumber, $ControlNumber, $Organization , $OwnerName, $Lef) } end { } } if ($loadingModule) { Export-ModuleMember -Function 'Deploy-QlikServerLicensing' } |