CPM - How To Test Managing Windows Usages Via Command Line
Objective
The Windows Services, Windows Scheduled Tasks, and Windows Registry usage plugins all utilize the same remote management methods that Microsoft's sc.exe, schtasks.exe, and reg.exe utilize, respectively. Therefore, we can use these Microsoft tools to test remotely managing these dependencies from the CPM, external to the Idira software itself.
Environment
14.2;14.6 Privileged Access Manager (PAM, self-hosted);Privilege Cloud Central Policy Manager (CPM)
Procedure
Please Do NOT Skip This Step!!
The first step to testing these password management tasks is to ensure that we're running this test in the same fashion that the CPM would perform them. Which user we use is going to depend on your particular configuration. There are three different possible configurations, each listed below:
1) Logon account associated to the usage account itself:
2) Logon account associated to the master account:
3) No logon account in use:
Ensure that you choose the correct account to use when testing, as not doing so would invalidate the test.
Once you've confirmed the configuration, open Command Prompt on the CPM and run the following command:
runas.exe /netonly /user:<logon_domain>\<logon_account> "cmd"
Replace <logon domain> and <logon account> with the correct values as determined above, and then hit Enter. After entering the accounts' password and hitting Enter again, and new Command Prompt window will open in the context of the logon user. It is in this new window that you will run the relevant test below.
Windows Service
Note: Make sure you're using the correct logon account as explained in the first section!
To test managing a remote Windows Service from the CPM, you'll be using sc.exe. First, confirm the exact address of the object in PVWA under the accounts' properties/details section. For the test to be valid, you must use the address exactly as it is listed here. With the address in hand, run the following command:
sc.exe \\<target_system> query
This command will return all running services on the target system. If you receive an error, abandon the test and troubleshoot accordingly. If you're not able to query for any services, the following tests will also fail.
If the test succeeds, the next step is to query for the specific service in question. First, referring back to the details of the account, ensure you use the exact service name as shown in PVWA for the object. To note, the service name is case sensitive and cannot contain whitespace (as opposed to the display name, which is not case sensitive and can contain whitespace). With the service name in hand, run the following command:
sc.exe \\<target_system> query <service_name>
If the specific service in question is returned, continue below. However, if you receive an error, abandon the test and troubleshoot accordingly. If you're not able to query for the service, the following tests will also fail.
Now that we've confirmed the service can be queried remotely from the CPM, the next step is to try and update the services' stored password. To note, the password is not actually being changed in the same context that a Windows account password is changed. The services' password is simply being replaced. Additionally, the password that is set is the password that is stored in the Vault for the target account object.
To test updating the password, run the following command:
sc.exe \\<target_system> config <service_name> password=<new_password>
The new password should meet the requirements specified on the target accounts' platform policy. If the password you choose contains special characters, wrap the password in single quotes so that the parameter becomes: password='<new_password>'
If the test above succeeds, this confirms that the remote Windows Service in question can be successfully managed from the CPM.
If you have Restart Service set to Yes and wish to test the ability of the CPM to remotely restart the service after setting the new password, run the following two commands in succession:
sc.exe \\<target_system> stop <service_name> sc.exe \\<target_system> start <service_name>
As long as no errors are generated, this confirms the ability to restart the service.
Windows Scheduled Task
Note: Make sure you're using the correct logon account as explained in the first section!
To test managing a remote Windows Scheduled Task from the CPM, you'll be using schtasks.exe. First, confirm the exact address of the object in PVWA under the accounts' properties/details section. For the test to be valid, you must use the address exactly as it is listed here. With the address in hand, run the following command:
schtasks.exe /query /s <target_system>
This command will return all scheduled tasks on the target system. If you receive an error, abandon the test and troubleshoot accordingly. If you're not able to query for any tasks, the following tests will also fail.
If the test succeeds, the next step is to query for the specific scheduled task in question. First, referring back to the details of the account, ensure you use the exact scheduled task name as shown in PVWA for the object. To note, the task name is case sensitive. With the task name in hand, run the following command:
schtasks.exe /query /s <target_system> /tn <task_name>
If the specific scheduled task in question is returned, continue below. However, if you receive an error, abandon the test and troubleshoot accordingly. If you're not able to query for the task, the following test will also fail.
Now that we've confirmed the scheduled task can be queried remotely from the CPM, the next step is to try and update the tasks' stored password. To note, the password is not actually being changed in the same context that a Windows account password is changed. The tasks' password is simply being replaced. Additionally, the password that is set is the password that is stored in the Vault for the target account object.
To test updating the password, run the following command:
schtasks.exe /change /s <target_system> /u <logon_to>\<username> /p <current_password> /rp <new_password> /tn <task_name>
The new password should meet the requirements specified on the target accounts' platform policy. If the password you choose contains special characters, wrap the password in single quotes so that the parameter becomes: '<new_password>'
If the test above succeeds, this confirms that the remote Windows Scheduled Task in question can be successfully managed from the CPM.
Windows Registry
Note: Make sure you're using the correct logon account as explained in the first section!
To test managing a remote Windows Registry Key from the CPM, you'll be using reg.exe. First, confirm the exact address of the object in PVWA under the accounts' properties/details section. For the test to be valid, you must use the address exactly as it is listed here. With the address in hand, run the following command:
reg.exe query \\<target_system>\hklm\software
This command will return all registry keys under the HKLM\Software registry node on the target system. If you receive an error, abandon the test and troubleshoot accordingly. If you're not able to query for any registry keys, the following tests will also fail.
If the test succeeds, the next step is to query for the specific registry key and value in question. First, referring back to the details of the account, ensure you use the exact registry key path and value as shown in PVWA for the object. With the key path and value name in hand, run the following command:
reg.exe query \\<target_system>\<path to registry key> /v <value>
If the specific registry key in question are returned, continue below. However, if you receive an error, abandon the test and troubleshoot accordingly. If you're not able to query for the specific registry key, the following test will also fail.
Now that we've confirmed the registry key can be queried remotely from the CPM, the next step is to try and update the registry key values' stored password. To note, the password is not actually being changed in the same context that a Windows account password is changed. The values' password is simply being replaced. Additionally, the password that is set is the password that is stored in the Vault for the target account object.
To test updating the password, run the following command:
reg.exe add \\<target_system>\<path to registry key> /v <value> /d <new_password> /f
The new password should meet the requirements specified on the target accounts' platform policy. If the password you choose contains special characters, wrap the password in single quotes so that the parameter becomes: '<new_password>'
If the test above succeeds, this confirms that the remote Windows Registry key and associated value in question can be successfully managed from the CPM.