RUnning Powershell file in kace script



We are upgrading over 200 PCs to windows 10 X86 & X64, I want to run a powershell file to change app packages 

I can't seem to get it to work, can anyone come up with a way to run the .PS1 file.


Is there a better way to run a powershell file/program some of the commands:

      Get-AppxPackage *3dbuilder* | Remove-AppxPackage

       Get-AppxPackage *windowsalarms* | Remove-AppxPackage

      Get-AppxPackage *Appconnector* | Remove-AppxPackage

Thank you

6 Comments   [ + ] Show comments
  • Try putting "& " in the front of "$(KACE_DEPENDENCY_DIR)/windows10.ps1"

    Also you should be using \ not / in windows. - Drave 3 years ago
  • Running as SYSTEM
    & : File C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\929\windows10.ps1
    cannot be loaded because running scripts is disabled on this system. For more
    information, see about_Execution_Policies at
    At line:1 char:2
    + &C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\929\windows10.ps ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
    Creating process returned non-zero: C:\Windows\System32\powershell.exe &C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\929\windows10.ps1: (0) The operation completed successfully.
    Error Code: 0
    Status Code: 1

    Error - Kdebiasse 3 years ago
  • You have to change the settings on each machine to enable running scripts then.

    "Set-ExecutionPolicy RemoteSigned"

    Or you could just run it through powershell without using a script as a dependency

    change your parameter to the following

    Get-AppxPackage *3dbuilder* | Remove-AppxPackage; Get-AppxPackage *windowsalarms* | Remove-AppxPackage; Get-AppxPackage *Appconnector* | Remove-AppxPackage

    the semicolon ; is like an && in linux. It runs each command one after the other, regardless of success of the others.

    Another option you have is to have KACE run each of those one at a time as different steps in a KScript. - Drave 3 years ago
  • 2017-06-15 12:16:57: Sending alert to client....
    2017-06-15 12:17:21: User selected OK
    2017-06-15 12:17:21: Sending script script.sh to client....
    2017-06-15 12:17:43: Script sent
    2017-06-15 12:17:43: Executing script....
    2017-06-15 12:18:08: Error 6002 received while executing script
    2017-06-15 12:18:08: Run As Console Logged in user failed: No User logged in to console
    Get this error when run script text

    Text :
    Get-AppxPackage *3dbuilder* | Remove-AppxPackage;
    Get-AppxPackage *windowsalarms* | Remove-AppxPackage;
    Get-AppxPackage *Appconnector* | Remove-AppxPackage; - Kdebiasse 3 years ago
    • Set it to not run while no user is logged in, and run it as the logged in user. The intended user needs to be logged in for them to be effected.

      When removing or installing modernui apps like that it's done on a "by user" basis, as in you can remove them from one user and they will still be installed on all other users on that system. So again, you must run it as that user. - Drave 3 years ago
  • How are you upgrading? If you are deploying the Windows 10 Setup, then you should modify the Install.wim and take out all of the app packages you do not want to deploy first.

    If you still want to handle it via script then do something like this:

    Run as system
    Make sure that run while no user logged in is checked
    In the parameters of the Launch a program you should put:
    -executionpolicy bypass -file "$(KACE_DEPENDENCY_DIR)\windows10.ps1"

    If this does not work then it is because you need to run this from a 64 bit standpoint :
    DIR: %SystemRoot%\sysnative\WindowsPowerShell\v1.0
    FILE: Powershell.exe
    PARAMS: -executionpolicy bypass -file "$(KACE_DEPENDENCY_DIR)\windows10.ps1" - Desktop Jockey 3 years ago
  • I ran it again with the settings. It place it in the Kbot folder a small dos windows pops up for a sec then disappears and script status states it ran success.
    Launching program: '%SystemRoot%\sysnative\WindowsPowerShell\v1.0\Powershell.exe' ' -executionpolicy bypass -file "C:\ProgramData\Dell\KACE\\kbots_cache\packages\kbots\929\windows10.ps1"' wait='true'
    But items are still there. Ran one selection on the PC in powershell and removed item.

    Its not running the powershell program. - Kdebiasse 3 years ago

Answers (1)

Answer Summary:
Posted by: JasonEgg 3 years ago
Red Belt

Top Answer

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