Powershell 7 Kscript doesn't want to run
Hi there everyone. First time long time...
I've installed Powershell v7.1.3 to a windows server 2012 R2 box and can successfully run the command: Clear-RecycleBin -Force from the local desktop.
I've attempted to implement a daily script to automate this task. Efforts so far have been unsuccessful. Im stumped as to why.
NOTE! pwsh.exe is the Powershell7 executable that can be run from anywhere as its added to the PATH system variable.
I've tried two methods, both run as 'local system':
Using a dependency file (the file is simply a one liner Clear-RecycleBin -Force)
Debug Log
Running kbot: runkbot 119 1622608041 KBotScript::LogScriptInfo - Start id=119 name=Empty Recycle Bin version=1622608041 type=policy execute disconnected=false logged_off=true execute events KBotScript::LogScriptInfo - Finish KBotScript::LogScriptInfo - Start id=119 name=Empty Recycle Bin version=1622608041 type=policy execute disconnected=false logged_off=true execute events KBotScript::LogScriptInfo - Finish KBotScriptManager::CleanupDependencies - clean up dependencies in kbot directory C:\ProgramData\Quest\KACE\kbots_cache\\packages\kbots\119\ CleanupDependencies: file Clear-RecycleBin.ps1 is part of the dependency list, keep the file runkbot ----- launching [path='C:\ProgramData\Quest\KACE\kbots_cache\packages\kbots\119' program='pwsh.exe' parms='-nologo -executionpolicy bypass -WindowStyle hidden -noprofile -file "Clear-RecycleBin.ps1"' wait='true'] ----- runkbot ----- completed [exitCode=0] -----Or calling the command as part of the parameters:
Debug Log
Running kbot: runkbot 119 1622610064 KBotScript::LogScriptInfo - Start id=119 name=Empty Recycle Bin version=1622610064 type=policy execute disconnected=false logged_off=true execute events KBotScript::LogScriptInfo - Finish KBotScript::LogScriptInfo - Start id=119 name=Empty Recycle Bin version=1622610064 type=policy execute disconnected=false logged_off=true execute events runkbot ----- launching [path='' program='pwsh.exe' parms='-executionpolicy bypass -WindowStyle hidden -noprofile -Command "Clear-RecycleBin -Force"' wait='true'] ----- runkbot ----- completed [exitCode=0] -----Can anyone spot where I'm going wrong? I'll add more information if its required.
0 Comments
[ + ] Show comments
Answers (1)
Please log in to answer
Posted by:
JasonEgg
3 years ago