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.

Info:
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.

Thanks,
Moorish.
1 Comment   [ + ] Show Comment

Comments

  • 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?
Please log in to comment

Answers

1
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.

http://www.samlogic.net/articles/sysnative-folder-64-bit-windows.htm
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384187%28v=vs.85%29.aspx
http://scottiestech.info/2009/06/20/calling-a-32-bit-system-command-from-a-script-in-x64-windows/
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?
Please log in to comment
1
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

Please log in to comment
1
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.
http://stackoverflow.com/questions/17420474/how-to-capture-error-messages-thrown-by-a-command-in-powershell 
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.
Please log in to comment
1
Answered 11/26/2014 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity