Windows / PowerShell
Incorporating Windows PowerShell into your Discovery enhances vScope’s ability to collect information from the operating systems of Windows servers or clients.
Using PowerShell, instead of WMI over DCOM or WinRM, allows for a more flexible inventory, including the capability to customize the collection of Windows Registry Keys. Furthermore, PowerShell enables the use of Microsoft’s JEA (Just Enough Administration) for more efficient permission management in your environment.
Adding Windows OS (PowerShell)
Notice: Administrator privileges are required to add Windows OS to vScope.
- Go to Discovery > Credentials.
- Click Create Credential, and select Windows (PowerShell).
- Configure your Integration Settings by adding the credential details. You can reuse an existing credential, or create a new one from scratch.
- Select the target to be discovered by this credential and click Create.
Good job! You have now configured Windows OS inventory using PowerShell.
Collect registry keys from Windows OS
With PowerShell, you can collect additional values from the operating system, specifically from the Windows Registry, by configuring the keys in your credentials and Creating tags from Discovery.
- Go to your Windows (PowerShell) credential in Discovery > Credentials.
- Under Advanced Settings, enter a registry key that you want to collect from your Windows assets.
eg.HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\TimeZoneInformation
vScope will automatically collect all nested subkeys from the configured key. - Click Add and then Update to save your changes.
- Run a Discovery, and go to Tags > Created from discovery.
- Click Create tag and select Windows > All Machines.
- Configure your tag by entering a name and selecting the key you want to collect the value from. You can choose to format the value.
- Click Create and rerun a Discovery (Discovery > Credentials > Select Windows (PowerShell) and Rediscovery).
Congratulations, vScope will now collect your configured registry key(s) for every Windows OS discovered with your Windows PowerShell credential!
Configuring JEA (Just Enough Administration)
Prerequisites
- The vScope Server and target server must be part of a Windows domain.
- The JEA credentials with non-administrator rights must be domain-level credentials.
- PowerShell 5.0 or Windows Management Framework 5.1 must be installed on the target Windows machines.
- PowerShell Remoting must be enabled on the target Windows machines.
Example Assumptions
For the sake of the guide, we will assume the following in our example:
- The JEA endpoint will be registered as
vScopeScan
- The role capabilities will be registered as
vScopeJEA
- The user allowed to connect to the JEA endpoint is
DOMAIN\VSCOPEUSER
and will be assigned the role capabilitiesvScopeJEA
- The computer where the JEA endpoint is configured is named
ComputerXYZ
Role Capabilities
The Role Capabilities file (psrc) is the heart of JEA and specifies what a role is allowed to do when connecting with JEA. This file is a detailed specification of which cmdlets, functions, providers and modules are available when using the JEA endpoint.
Execute the following in a PowerShell to create a new file with default contents.
Edit the vScopeJEA.psrc
to specify the cmdlets, functions, providers and modules that vScope is allowed access to. Here’s the contents of the most recent role capabilities file needed for a complete vScope inventory:
The next step is to register the role capabilities.
Create a PowerShell Module for Role Capabilities
The following example creates a PowerShell script module called vScopeJEA
in the $env:ProgramFiles
path to host the role capabilities file vScopeJEA.psrc
. Run the following from the same folder as the vScopeJEA.psrc
file you created earlier.
vScopeJEA.psrc
is copied to C:\Program Files\WindowsPowerShell\Modules\vScopeJEA\RoleCapabilities
and can be edited at any time.
Create Session Configuration
A JEA endpoint must be registered on the system. This done using a PowerShell session configuration file (pssc). This configuration defines who can use the JEA endpoint and which roles they have access to. It also contains global settings that apply to all users of the JEA session.
To configure the PowerShell JEA endpoint for vScope, first create a session configuration file by executing the following in a PowerShell:
This will create vScopeJEA.pssc
and then test the validity of the configuration with Test-PSSessionConfigurationFile
. The result of the command should be true
, otherwise there is something wrong with the configuration.
SessionType
defines the most strict and locked down mode of PowerShell (RestrictedRemoteServer
) which operates in NoLanguage
mode. Only a few commands and cmdlets are available in this mode:
Clear-Host
(cls
,clear
)Exit-PSSession
(exsn
,exit
)Get-Command
(gcm
)Get-FormatData
Get-Help
Measure-Object
(measure
)Out-Default
Select-Object
(select
)
There is no way for vScope to execute arbitrary commands or scripts in RestrictedRemoteServer
mode. This is why the role capabilities file contains extra cmdlets (VisibleCmdlets), functions (VisibleFunctions and FunctionDefinitions), providers (VisibleProviders) and modules (ModulesToImport) that vScope needs for a successful inventory.
RunAsVirtualAccount
makes users connecting to the JEA endpoint administrators but only within the capabilities allowed by the role capabilities.
RoleDefinitions
specifies the RoleCapabilities assigned to users that have access to the JEA endpoint. The account DOMAIN\VSCOPEUSER
is assigned the capabilities in the vScopeJEA.psrc
file we created earlier. Change this to match the account used in your environment.
Register Session Configuration
The session configuration (vScopeJEA.pssc
) we created earlier must be registered to create the JEA endpoint. Execute the following command from the same folder vScopeJEA.pssc
. This will register a new JEA endpoint named vScopeScan
:
To verify that the session configuration is registered:
The output should include the vScopeScan
endpoint and list DOMAIN\VSCOPEUSER
with permissions.
If you ever need to change the session configuration you must first unregister it and then register it again.
Test the JEA Endpoint
From the same computer where the JEA endpoint was configured you may run the command below. When you input credentials, make sure to use an account specified in the session configuration. In our example this would be DOMAIN\VSCOPEUSER
specified in the session configuration.
From a remote computer, use the command below to connect:
To list the cmdlets and functions available in the remote session execute the following in the established remote session created with Enter-PSSession
:
The output should include all default commands the extra cmdlets and functions defined in the role capabilities file.
Deployment
For managing JEA endpoints across large environments, consider using PowerShell DSC. Learn more here:
There are examples for DSC available in the JEA GitHub Repository.
You may also use Ansible Playbooks for deployment.
Further Reading
Read more about configuring JEA at Microsoft. There you will also find information on how to audit JEA and other security considerations.