-
×InformationNeed Windows 11 help?Check documents on compatibility, FAQs, upgrade information and available fixes.
Windows 11 Support Center. -
-
×InformationNeed Windows 11 help?Check documents on compatibility, FAQs, upgrade information and available fixes.
Windows 11 Support Center. -
- HP Community
- Desktops
- Business PCs, Workstations and Point of Sale Systems
- Task: script to call Powershell as Admin and run powershell ...

Create an account on the HP Community to personalize your profile and ask a question
04-24-2017 09:45 AM
2017-04-20 10:35:38
Successfully sent task to the Device Management Gateway 2017-04-20 10:35:44 Task has been retrieved by the Agent. 2017-04-20 10:36:18 Successfully configured BootCommand to "disable". 2017-04-20 10:36:18 Successfully configured WFType to "". 2017-04-20 10:36:18 Successfully executed ConfigWriteFilter task. 2017-04-20 10:36:18 Successfully executed common task. 2017-04-20 10:36:18 Map repository to: Master Repository 2017-04-20 10:36:18 Successfully sent task to the Device Management Gateway 2017-04-20 10:37:45 Task has been retrieved by the Agent. 2017-04-20 10:37:50 Deploy files using repository Master Repository. 2017-04-20 10:37:50 Successfully downloaded RenameTC.ps1 to C:\Windows\ from /Repository/Files/ToDeploy/Make a Change Template. 2017-04-20 10:37:50 Successfully executed DeployFiles task. 2017-04-20 10:37:50 Successfully executed common task. 2017-04-20 10:37:50 Successfully sent task to the Device Management Gateway 2017-04-20 10:37:56 Task has been retrieved by the Agent. 2017-04-20 10:38:06 Execution result (below): 2017-04-20 10:38:06 C:\Windows>powershell C:\Windows\RenameTC.ps1 2017-04-20 10:38:06 C:\Windows\RenameTC.ps1 : File C:\Windows\RenameTC.ps1 cannot be loaded 2017-04-20 10:38:06 because running scripts is disabled on this system. For more information, see 2017-04-20 10:38:06 about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170. 2017-04-20 10:38:06 At line:1 char:1 2017-04-20 10:38:06 + C:\Windows\RenameTC.ps1 2017-04-20 10:38:06 + ~~~~~~~~~~~~~~~~~~~~~~~ 2017-04-20 10:38:06 + CategoryInfo : SecurityError: (:) [], PSSecurityException 2017-04-20 10:38:06 + FullyQualifiedErrorId : UnauthorizedAccess 2017-04-20 10:38:06 Failed to execute Script task. 2017-04-20 10:38:06 ErrorCode: 14004022, Error Detail: Command line error. 2017-04-20 10:38:06 Failed to execute common task. 2017-04-20 10:38:06
ErrorCode: 14004022, Error Detail: Command line error.
I Can Successfully run this .Ps1 logged on as the Admin and User accounts locally. the script is not the issue. the issue is with the coding inside the Task -the code is:
powershell -noprofile -command "&{start-process Powershell -ArgumentList ' -noprofile -file c:\Windows\RenameTC.ps1' -verb RunAs}"
this failes to allow the script to run being denied access. i have told this script to run as Admin (built in Admin account) and also (SYSTEM) as well. both fail out trying to run this task with the info i posted from the Task View Sequence. I need to be able to run this as part of my imaging task sequence. doing this manually is not really an option.
How can i get the Script to Open up powershell as admin and run a powershell script without failing?
Solved! Go to Solution.
Accepted Solutions
04-25-2017 08:57 AM
After Further troubleshooting I started the script from scratch. this was a case of making thing harder than i should have. I was attempting to run powershell as Admin and that was cauing the issue. I changed the script to just :
powershell.exe -noprofile -executionpolicy bypass -file C:\Windows\renameTC.ps1
this ran powershell from the batch window and set the -execution policy to bypass prompts and allow the file to run without issue.
So my Make a Change Template sequence goes like this:
1. disable write filter
2. copy file from repository to the "C:\Windows" Dir (place it anywhere you want.)
3. run the script: powershell.exe -noprofile -executionpolicy bypass -file C:\Windows\renameTC.ps1
4. Delete the RenameTC.ps1 file
5. reboot
6. enable Write filter
This completes without error. have a great day and hope this helps someone with using the script to call powershell and run a powershell script on a T630 Thin Client Windows 10 IoT 64bit using HPDM 4.7 SP6
04-24-2017 12:26 PM
this is the script im sending from HPDM. this fials out using both the "Run AS:" with both Admin and System
my .ps1 will run fin if i login as Admin open Poweshell as Admin and run the file.
It will also run using the ablove content inside of CMD. while this is failing using it from HPDM Script is confusing me.
04-25-2017 08:57 AM
After Further troubleshooting I started the script from scratch. this was a case of making thing harder than i should have. I was attempting to run powershell as Admin and that was cauing the issue. I changed the script to just :
powershell.exe -noprofile -executionpolicy bypass -file C:\Windows\renameTC.ps1
this ran powershell from the batch window and set the -execution policy to bypass prompts and allow the file to run without issue.
So my Make a Change Template sequence goes like this:
1. disable write filter
2. copy file from repository to the "C:\Windows" Dir (place it anywhere you want.)
3. run the script: powershell.exe -noprofile -executionpolicy bypass -file C:\Windows\renameTC.ps1
4. Delete the RenameTC.ps1 file
5. reboot
6. enable Write filter
This completes without error. have a great day and hope this helps someone with using the script to call powershell and run a powershell script on a T630 Thin Client Windows 10 IoT 64bit using HPDM 4.7 SP6