RUnning Powershell file in kace script
Hello,
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.
Or
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
Answers (1)
Answer Summary:
Please log in to answer
Posted by:
JasonEgg
7 years ago
Top Answer
Here are Quest's KB articles for running powershell through the scripting module:
Also you should be using \ not / in windows. - Drave 7 years ago
& : 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
http://go.microsoft.com/fwlink/?LinkID=135170.
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 7 years ago
"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 7 years ago
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 7 years ago
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 7 years ago
https://gallery.technet.microsoft.com/Removing-Built-in-apps-65dc387b
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 7 years ago
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 7 years ago