SGS16 Trusted Contributor.
Trusted Contributor.
927 views

Run Powershell as Admin Privilege

I want to run Powershell console  with admin privilege..How to do that.?If i run the command in server with admin privilege it is working fine.if i run it via studio.it is showing below error.If i use deprecated operation Powershell 2 it is working fine.What we need to do to run powershell console as admin?

 

 

exception=dotNETWebActions_PowerShell.PowerShellExceptions.CommandException: Could not execute powershell command. ---> System.Management.Automation.Remoting.PSRemotingTransportException: The method or operation is not implemented. ---> System.Management.Automation.PSNotImplementedException: The method or operation is not implemented.
at System.Management.Automation.Internal.Host.InternalHost.GetIHostSupportsInteractiveSession()
at System.Management.Automation.Internal.Host.InternalHost.get_IsRunspacePushed()
at System.Management.Automation.Remoting.RemoteHostCall.GetRemoteRunspaceToClose(PSHost clientHost)
at System.Management.Automation.Remoting.RemoteHostCall.ExecuteVoidMethod(PSHost clientHost)
at System.Management.Automation.Runspaces.Internal.ClientRemotePowerShell.HandleHostCallReceived(Object sender, RemoteDataEventArgs`1 eventArgs)
at System.Management.Automation.ExtensionMethods.SafeInvoke[T](EventHandler`1 eventHandler, Object sender, T eventArgs)
at System.Management.Automation.Internal.ClientPowerShellDataStructureHandler.ProcessReceivedData(RemoteDataObject`1 receivedData)
at System.Management.Automation.Internal.ClientRunspacePoolDataStructureHandler.DispatchMessageToPowerShell(RemoteDataObject`1 rcvdData)
at System.Management.Automation.Remoting.ClientRemoteSessionDSHandlerImpl.ProcessNonSessionMessages(RemoteDataObject`1 rcvdData)
at System.Management.Automation.ExtensionMethods.SafeInvoke[T](EventHandler`1 eventHandler, Object sender, T eventArgs)
at System.Management.Automation.Remoting.BaseTransportManager.OnDataAvailableCallback(RemoteDataObject`1 remoteObject)
at System.Management.Automation.Remoting.Client.BaseClientTransportManager.ServicePendingCallbacks(Object objectToProcess)
--- End of inner exception stack trace ---
at System.Management.Automation.Runspaces.AsyncResult.EndInvoke()
at System.Management.Automation.PowerShell.CoreInvokeRemoteHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke[T]()
at PowerShellV2.PSRunspaceV2.RunCommand[T](PSCommand command)
--- End of inner exception stack trace ---
at PowerShellV2.PSRunspaceV2.RunCommand[T](PSCommand command)
at PowerShellV2.PSRunspaceV2.RunCommand(PSCommand command)
at PowerShellV2.PSRunspaceV2.RunScript(String scriptText)
at dotNETWebActions_PowerShell.IActions.PowerShellBaseAction.ExecutePowerShell(ActionRequest req, ISession s, IActionRegistry reg

0 Likes
2 Replies
Micro Focus Expert
Micro Focus Expert

Re: Run Powershell as Admin Privilege

Hi,

For studio in order to run PowerShell commands as administrator expressly start studio with right click Run As Administrator option. In central/RAS make sure that the Central/RAS service runs as a user that is member of the administrators group.

Regards,

Vlad

0 Likes
scuda20 Super Contributor.
Super Contributor.

Re: Run Powershell as Admin Privilege

Based on the output of your command there, I am going to make the assumption you want to run a command on a remote machine as an elevated user.  If that is correct, then you will need to run something like this where ${dataIP} is the ip of the computer you want to run the command on.

$user="administrator"
$pass=ConvertTo-SecureString -String "${domainPassword}" -AsPlainText -Force
$cred=New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $user, $pass
$server="${dataIP}"
$r=new-pssession -computername $server -Authentication Credssp -credential $cred
invoke-command -session $r -scriptblock {C:\patch\exchange\setup.com /mode:install  /roles:et}

In addtion, if your OO Central/RAS is a standalone and your remote system is inside an AD domain, then you have a doublehop problem. You will need to create the script on your OO, transfer it to the remote system, then as admin on the remote system, launch the script which essentially opens an evlevated powershell command "locally" (remote machine) and launches the command as a domain admin. This all assumes you have wmi setup correctly, authorized and you have allowed credentials delegation in your local gpo.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.