$ServerAddress = "XXXXXX"; $ServerPort = "14000"; $ServerSSLPort = "13000"; $KSWSLocalFile = "C:\Distributive\ksws.zip"; $KSWSRemoteFile = "http://" + "$ServerAddress" + ":8060/Public/KSWS.zip"; New-Item -ItemType directory -Path "C:\Distributive\"; $WC = New-Object System.Net.WebClient; $FTPURI = New-Object System.Uri($KSWSRemoteFile); $WC.Credentials = New-Object System.Net.NetworkCredential($Username, $Password); $WC.DownloadFile($FTPURI, $KSWSLocalFile); $ShellApp = new-object -com shell.application; $Zip = $ShellApp.NameSpace($KSWSLocalFile); foreach($item in $Zip.items()) { $ShellApp.Namespace("C:\Distributive\").copyhere($item); } $KnagentArgs = "/norestart", "/i", "C:\Distributive\agent\klnagent.msi", "/l*xv", "C:\Distributive\klnagent.log", "/qn", "EULA=1", "PRIVACYPOLICY=1", "SERVERADDRESS=$ServerAddress", "SERVERPORT=$ServerPort", "SERVERSSLPORT=$ServerSSLPort", "UDPPORT=15000", "USESSL=1", "OPENUDPPORT=1", "GATEWAYMODE=0", "CERTSELECTION=GetOnFirstConnection", "LAUNCHPROGRAM=1", "DONT_USE_ANSWER_FILE=1"; Start-Process msiexec -ArgumentList $KnagentArgs -PassThru -Wait; Start-Sleep -s 10; $KNAService = Get-Service klnagent -ErrorAction Continue; Start-Service -Name $KNAService.Name -ErrorAction SilentlyContinue; $KSWSArgs = "/norestart", "/i", "C:\Distributive\server\ks4ws_x64.msi", "/l*xv", "C:\Distributive\ksws.log", "/qn", "EULA=1", "PRIVACYPOLICY=1"; Start-Process msiexec -ArgumentList $KSWSArgs -PassThru -Wait; $ConsoleArgs = "/norestart", "/i", "C:\Distributive\server\ks4wstools_x64.msi", "/l*xv", "C:\Distributive\kswsconsole.log", "/qn", "EULA=1", "PRIVACYPOLICY=1"; Start-Process msiexec -ArgumentList $ConsoleArgs -PassThru -Wait;