Open for Voting

FEATURE REQUEST - Powershell component - run as administrator

Hello emoticons_happy.png

This one is (in my head at least) quite simple and straight forward, how come we can't have a powershell component run with administrator permissions on a node with an agent installed?

My request should in theory be quite simple to add, just a checkbox in the powershell component saying "Run as administrator", and then it will do just that.

You should already have code that does just that only requiring minor adjustments, while remote deploying an agent you require the installer to run with administrator elevation to install.

My specific use-case is monitoring a scheduled task that is in a custom folder that requires local admin permissions, but there are many other scenarios where administrator permissions could be required to monitor something.

This request could also be extended to the "Windows Script monitor" and "Linux/Unix Script Monitor" (SUDO instead of administrator obviously)

Edit:

Specifically I mean a powershell session elevated to full administrator permissions, a way to test this is with the script below:

$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())

if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {

write-host "Message:This powershell session does have administrator permissions"

write-host "Statistic:0"

} else {

write-host "Message:This powershell session does NOT have administrator permissions"

write-host "Statistic:100"

}

This will only return with statistic 0 if the powershell session is elevated to administrator permissions.

pastedImage_0.png

Parents Comment Children
  • Yes you can run the script with the USER administrator, but that does not mean the script have administrator ELEVATION, there is a little difference regarding what permissions you have there.

    Take a look at this little script:

    $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())

    if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {

    write-host "Message:This powershell session does have administrator permissions"

    write-host "Statistic:0"

    } else {

    write-host "Message:This powershell session does NOT have administrator permissions"

    write-host "Statistic:100"

    }

    Try running that in APM and see if you can get it to return that it has administrator permissions. (or just try it on your PC)

    This will only return with statistic 0 if the powershell session is elevated to administrator permissions.

    pastedImage_0.png