Powershell script launched from Kace Scripting crashes
I have a PowerShell script that copies select folders from a user's profile (Desktop, Documents, Chrome default user data folder, etc) from their computer to a new/replacement computer. The script functions perfectly running on its own but when I have it run out of Kace it fails. THe script does require input and it runs fine through that part, launching PowerShell on the computer I set it to run on in kace but as soon as it hits the point to begin the copy PowerShell either crashes (when running as local system) or throws access denied errors (when running as current user). I have tried adding credentials to the script in multiple ways with no improvement. I have run out of ideas, I really need this to be able to run out of the kace scripting so it is available to my whole Dept continuously. Any help would be greatly appreciated.
Answers (2)
It would be helpful if you provided your script. I found that with kace you must start the 64bit version of powershell manually for some scripts. This has worked for me:
set-executionpolicy bypass -force
Set-Alias Start-PowerShell64 "$env:windir\sysnative\WindowsPowerShell\v1.0\powershell.exe"
Start-PowerShell64
(powershell script starts here)
Comments:
-
What was the solution? - barchetta 2 years ago
-
added set-execcutionpolicy -scope currentuser unrestricted to the $profile and ran as current user from Kace. This has allowed it to work for me on my machines but still working on making it usable to my team on machines they have access to. I am the only one on my team with a VM and a Physical so I am trying to find a way to have it work in a VM. If you have any thoughts on that I would appreciate it - jbrower@sanmarcostx.gov 2 years ago
-
Sorry I do not.. just going to depend on your situation. I still would advise you to run the 64bit version of powershell and that should cover any script you might run. I got some very unexpected results without this. - barchetta 2 years ago