Quantcast
Channel: Business PCs, Workstations and Point of Sale Systems topics
Viewing all articles
Browse latest Browse all 10149

Task: script to call Powershell as Admin and run powershell script- Failed to execute Script task

$
0
0

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: (Smiley Happy [], 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?


Viewing all articles
Browse latest Browse all 10149

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>