This post is an attempt to demystify some of the ‘action override’ parameters and to provide some useful examples.
General Considerations
-
When running a script as a user, the normal user account generally does not have access to the
__BESData
directory or subdirectories. After creating a script with ‘createfile’ or ‘appendfile’, or after downloading a file through ‘download’ or ‘prefetch’ commands, the content needs to be copied to a directory the user can access.
Avoid using the ‘move’ command, as when 'move’ing files on Windows, the files keep their original permissions - which still block standard user access. Instead use either ‘copy’ ActionScript commands or ‘copy’ OS commands to copy the content. -
When using the ActionScript override ‘runas=currentuser’, the BigFix Client determines which logged-on user account to use. If there is a user logged in directly to the Console, that is preferred; if not, then any Remote Desktop user or ‘Fast-User Switched’ user session may be used.
-
There is no direct inspector to return the same user account that ‘runas=currentuser’ chooses. The
current user
inspector returns only the Console user, whilelogged on users
gives a plural result of all logged-on users. To retrieve an approximation of what I believe is the same user, in the ‘DOMAIN\username’ or plain ‘username’ (for local users) format that can be used for theuser=
ortargetuser=
parameters, I sometimes employ this relevance with good result; but I’d welcome any improvements from the community if you know of other methods.
parameter "preferred_user"="{(preceding text of first "|" of it | it) of concatenation "|" of ((if exists domain of it then domain of it & "\" else "") of user of it & name of it) of logged on users whose (active of it)}"
- To determine a folder I know the user can access, to copy scripts or binaries to them, I have used this statement to locate their profile folder and create a temporary working directory beneath it. In this form it creates a unique folder based on the action ID, that can be removed if you want to reuse the same temporary path for multiple actions/fixlets. Be sure to use ‘folder create’ to create the resulting folder since it should not exist already, before trying to copy scripts or files into it:
parameter "UserFolder"="{(preceding text of first "|" of it | it) of concatenation "|" of profile folders of users of logged on users whose (active of it)}\MyBESContent\{id of action as string}"
-
Even when executing a script or file that is located in a user-readable area, the “Current Working Directory” defaults to the
__BESData\<sitename>
folder. Depending on what your script or tool is doing, that may be important. For example in my test “c:\temp\temp.cmd”, I found I could not execute the ‘ping’ command, instead getting a message about ‘Invalid working directory’. To work around that, I spawn off a cmd.exe that first changes the working directory and then executes the batch file below. -
When using the ‘password=required’ parameter, the Console prompts for the user’s password when sending the action. This is encoded in a Secure Parameter named
"action override password"
. This may be useful from custom Parameterized Fixlets or REST API, to send the password via a Secure Parameter with the correct parameter name.
With that said, on to the Action Override settings and some example usages. Assume the following conditions:
- The user D\TestUser1 is logged on to the endpoint
- There is a batch file “C:\temp\test.cmd” to be executed.
Case | Syntax | Description |
---|---|---|
1 | waithidden cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
The batch file executes, using the LocalSystem context, and provides no visible window. This is default actionscript behavior. |
2 | override wait runas=currentuser wait cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
The script executes in the context of D\TestUser1. A visible window is presented for the script. The script does not run in Elevated context, even if D\TestUser1 is an administrator on the machine. If no account is logged on, the command fails to execute. |
3 | override wait runas=localuser user=D\TestUser1 password=impersonate wait cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
Executes as D\TestUser1, provides a visible window, and runs without Administrator privileges. < If D\TestUser1 is not logged on at the time, the command fails to execute. |
4 | override wait runas=localuser user=D\TestUser1 password="users-password" asadmin=interactive wait cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
The command executes as D\TestUser1 and provides a visible window. The process runs elevated, even if D\TestUser1 is not a member of the Administrators group. If D\TestUser1 is not logged on, the command fails to execute. |
5 | override wait runas=localuser user=D\TestUser2 password="users-password" asadmin=interactive targetuser=D\TestUser1 wait cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
Executes the script, running as ‘D\TestUser2’ (who does not need to be logged on at the time). The user interface is displayed to D\TestUser1 (who must be logged on at the time). The script is run with Elevated privileges, even if neither D\TestUser1 nor D\TestUser2 are members of the Administrators group. |
6 | override wait runas=localuser user=D\TestUser1 password=system wait cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
The script executes in the LocalSystem account, and provides a user interface to D\TestUser1 (who must be logged on at the time). The script runs with the Elevated privileges of LocalSystem. |
7 | override wait runas=localuser user=D\TestUser1 password=required asadmin=interactive wait cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
The Console prompts for the password for the D\TestUser1 account when sending the Action.The password is sent as a Secure Parameter named "action override password" .The script executes in the context of D\TestUser1 . The script runs with Elevated Privileges, even if D\TestUser1 is not a member of the Administrators group, and runs with a visible window. |
8 | override wait runas=localuser user=Administrator password=required asadmin=interactive targetuser=D\TestUser1 wait cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
The Console prompts for the password which must match the local Administrator account. The script executes as Administrator, and runs with elevated permission, and runs with an interface visible to D\TestUser1 , who must be logged on at the time. |
9 | override wait runas=localuser user=D\TestUser1 password=required wait cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
The Console prompts for the password for D\TestUser1 . The script executes in the context of D\TestUser1 even if the user is not logged on. The script does not executed with elevated privileges. |
10 | override wait runas=localuser user=D\TestUser1 password=required asadmin=true wait cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
The console prompts for the password for D\TestUser1. The script executes in the context of D\TestUser1, and runs Elevated even if D\TestUser1 is not a member of the Administrators group. D\TestUser1 does not need to be logged on for the script to execute. |
Things that do NOT work
- I have not found any syntax that allows executing a command in the user’s context, while elevating that command to Administrator privileges, without knowing the password of the user account.
Case | Syntax | Description |
---|---|---|
11 | override wait runas=currentuser asadmin=interactive wait cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
Command failed (The keyword 'AsAdmin=interactive' can be used when both RunAs=localuser, and Password=required or Password=empty or Password="value" are specified.) wait cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
12 | override wait runas=localuser user=D\TestUser1 password=impersonate asadmin=interactive wait cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
Command failed (The keyword 'AsAdmin=interactive' can be used when both RunAs=localuser, and Password=required or Password=empty or Password="value" are specified.) |
13 | override wait runas=localuser user=MyTempUser1 password="MyTempPassword" asadmin=interactive wait cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
Command failed (RunAsLocalUser : No local session found for user 'MyTempUser1') The documentation at developer.bigfix.com makes mention of using password="string" when using a temporary account. BigFix does not create a temporary account for you. This usage is, I believe, intended when the action creates a local user account for this usage somewhere earlier in the script, and thus knows the users password (which might be randomized) |
14 | override wait runas=localuser user=MyTempUser1 password="MyTempPassword" asadmin=true wait cmd.exe /c "cd C:\temp & c:\temp\test.cmd" |
Command failed (The keyword 'AsAdmin=true' can be used when both RunAs=localuser and Password=required are specified.) ‘AsAdmin=true’ cannot be used with a clear-text string for the password. |
edit: added row numbers to the tables for external referencing of each type