Search code examples
powershellbatch-filecmdadministratornexthink

Nexthink remote action powershell as admin


I work as IT in a company and from to time we get a list of a bunch of computers that we need to run a bat or cmd file inside as admin to fix few things. The list is huge and remote connecting takes long time and disturbs the user.

We have nexthink software that allow us to run powershell command on target computer. The issue is I need the bat or cmd to run as admin.

I have tried doing -v runAs but this shows a pop up and asks the user to fill the admin credentials which he doesnt know.

2nd thing I tried is

$passwd = Convert-SecureString -String "adminpassword" -AsPlainText -Force
$cred = new-object System.Management.Automation.PSCredential './adminusername',$passwd

Start-Process cmd -Cred $cred

This one actually checks if the cred is wrong or not and opens cmd but when i run net session to verify if its running elavated I am getting access is denied.


Solution

  • Nexthink itself should have an option to run the script as System, the script will be hidden in the background when it runs, because its running as system, but it should work all the same, so long as the script doesn't require user interaction.

    Its always best to avoid having a password in a script at all costs.