/build/static/layout/Breadcrumb_cap_w.png

Post-installation task types and limitations

Hi,
Got a couple of questions that I hope someone can answer:

  • I have a script that want to run post-installation and I want to know what is best practice when it comes to poweshell? I've tried attaching the ps1 in a "Windows Script" task, but that fails and the file is just opened in notepad during the deployment. I seems to work fine if I add the ps1 as an "application" but I would like to know what types of scripts are supported etc.? 
  • The "BAT script" type allows you simply type the commands directly into the Kace GUI, but you seem to be limited to a single line? When I use multiple commands, save the task en edit it again, all my line breaks are gone. Or is this just a GUI glitch?

Regards,
Simon




1 Comment   [ + ] Show comment
  • Hello, I am trying to create a "Run as" post install Task to install a piece of software as someone other than the local admin like a domain admin account. Can this be accomplished through a simple batch script? - totim 7 years ago

Answers (3)

Answer Summary:
Posted by: StockTrader 8 years ago
Red Belt
1
Hello,

If I recall well Windows Scripts is for VBS mainly. (and JScript [but I've never really tried])
It is correct to use the Application type for PowerShell because when you invoke a powershell script you many need to pass some parameters to set the execution policy if the script is not digitally signed.
About your second question on BAT type:
I tried to create a BAT task, save it and re-edit it and for me works fine...I'm using K2000 3.7 SP2.
 Kind regard,
Marco - StockTrader

Comments:
  • Hm, but how? I've attached the script.ps1 in an application task and I use the parameter "powershell.exe -NoProfile -ExecutionPolicy ByPass -file script.ps1" but it fails. How do you successfully call the script? - szo850 8 years ago
    • It should be fine. Do you obtain an error?
      Is this a post install task executed in Windows? (so not in the KBE)
      Regards,
      Marco - StockTrader - StockTrader 8 years ago
      • Yeah, but I seems to be rather powershell related than kace related, I have to do some more troubleshooting. Thank you - szo850 8 years ago
Posted by: SMal.tmcc 8 years ago
Red Belt
1
I run PS commands as a batch script



Start /wait net user administrator Passwordhere
Start /wait net user user2 Passwordhere
start /wait net localgroup administrators dfault /add

start /wait cscript %SystemRoot%\System32\slmgr.vbs -ATO

reg.exe DELETE HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /f

cscript "c:\program files (x86)\microsoft office\office16\ospp.vbs" /act

start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v AutoAdminLogon /d 1 /f
start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v AutoLogonCount /t REG_DWORD /d 3 /f
start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v DefaultUserName /d Administrator /f
start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v DefaultPassWord /d Passwordhere /f
start /wait reg.exe delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v DefaultDomainName /f

start /wait msiexec /qn /i "\\kbox\client\agent_provisioning\windows_platform\ampagent-6.4.180-x86.msi" HOST=kbox.tmcc.edu

start /wait Powershell "Get-AppxPackage | % {if (!($_.IsFramework -or $_.PublisherId -eq "cw5n1h2txyewy")) {$_}} | Remove-AppxPackage"

start /wait Powershell "Get-AppXProvisionedPackage -online | Remove-AppxProvisionedPackage -online"




Comments:
  • Yeah, that works pretty good actually, especially when you have a couple of ps-commands. But it tends to ge a bit messy when paste a larger script into the window. - szo850 8 years ago
Posted by: SMal.tmcc 8 years ago
Red Belt
1

Top Answer

Here is another quick way to do that.  It is not elegant it works and is quick and easy.

You use a vb script to launch the batch file and zip those up then create an app task that calls the vbs









CreateObject("Wscript.Shell").Run "copy.bat",0,True



Comments:
  • change 0 to 1 to make batch file visible. - SMal.tmcc 8 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ