Scripting Question

KScript saying that a Powershell is executed successfully, but nothing is changed.

11/25/2014 4304 views
I'm attempting to run a Powershell script across our network and I'm testing it out before I roll it out to all the computers. 

I've got the script written up and if I run it from the machine that I'm testing it on it will work fine.  If, however I run it through a KScript it will say that the script executed successfully but when I watch the machine I'm testing it on I get an extremely fast flash of a Powershell window with a red error message in it.  I can't grab a screenshot of the error and I've tried adding a sleep to the end of the script to make it slow down so that I can see the message to no avail.

Ultimately KACE thinks that the script ran successfully, but none of the work that the script is supposed to do has been performed.

The file I'm running is a .ps1 file.
Our network is set up to only allow powershell scripts to run locally (hence the KACE distribution).
I have the file uploaded to the KScript and am using the $(KACE_DEPENDENCY_DIR) line to point to it.  I believe this should allow the script to run locally.
I have the local system account running the file.
The script is set to run whether or not someone is logged in.
Our K1000 is version 6.0.101865 if that helps.  

Let me know if you need more information.

1 Comment   [ + ] Show comment


  • I am having this same issue, it seems that its running with lowered permissions regardless of what I tell KACE to do. have you found a fix for this yet?

Community Chosen Answer

What is the exact structure of your task in the kscript?

As a side note:

Bear in mind that the K1000 only knows that the kscript ran successfully, not that your Powershell script did.

Also know that the KACE agent is 32 bit.  Sometimes you have to use things like SysNative to get around that limitation.

Answered 12/01/2014 by: jknox
Red Belt

  • I've made sure that the Powershell script runs successfully on its own. The hiccup comes when I add KACE to the mix.

    As for the Kscript itself, all it is supposed to do is verify the file exists and run it.

    The exact line is pointing to powershell.exe and setting the script itself as a parameter: “c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe” with params “$(KACE_DEPENDENCY_DIR)\Script.ps1”

    If I point KACE to run the PS1 file directly then I get a 193 error. Is this the wrong way to go about running the powershell?

All Answers

Still having issues with this but it seems to be that the problem has to do with some sort of Permission that KACE is using.  I'm having it run through KACE with the same account that works when running the script on its own, but it's still crashing before anything can be done, including "-ErrorAction Inquire"

Answered 12/04/2014 by: Moorish
White Belt

Does the script itself need a user to be logged in? Sometimes using local system will not work for some scripts and you need to make it run as a logged in user or a specific user. Since it runs I'm guessing it's not so much a KACE issue as it is a script or permissions issue.

Also to view what the error is you can log the error messages to a file.
Answered 11/25/2014 by: h2opolo25
Red Belt

  • I've tried it with users and without. When I try it with the User it does the same thing.

    Also, I attempted to add that bit to the script and the script doesn't create the log file. It's like the script is being run but at the first line.

I found the issue with this, figured Id post for other people even though this is an old thread.

The issue was with Kace running as a 32 bit process on a 64 bit machine, when it called powershell it did it as a 32 bit process which has issues when dealing with windows.

use this to call the correct version of powershell

I use this bat file when I need to run something on both 64 and 32 bit

if exist "%SYSTEMDRIVE%\Program Files (x86)\" (
     %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -file Dosomething.ps1  -verb RunAs
) else (
  %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -file Dosomething.ps1  -verb RunAs
Answered 05/16/2017 by: HISDTechGuy
Senior Yellow Belt

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:


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