Configuring the blpowershell.cnf file
This topic explains the purpose of the blpowershell.cnf file, describes the available options, and details how to configure it. This topic includes the following sections:
About the blpowershell.cnf file
When the RSCD agent starts for the first time, it creates a blpowershell.cnf configuration file with the default values as mentioned in the following table. This file is present in the share directory in the RSCD installation directory on the target servers. RSCD Agent recognizes the PowerShell script based on the extension (.ps1) and these scripts are executed using the configured values in blpowershell.cnf file. When RSCD Agent starts, it checks if the configuration file exists or not. If the file doesn't exist, it is created with default values.
Ensure that you are using 8.9.04 or later version of the RSCD Agent.
The PowerShell configuration file has predefined values, as described in the following table:
This field is used to enable or disable the PowerShell feature. The possible values are Enabled or Disabled.
Windows - powershell.exe/pwsh.exe
Non-windows - pwsh
This field represents the name of the PowerShell executable. The possible values are:
-NoLogo -inputformat NONE -NonInteractive
This field represents the PowerShell options that are passed to the PowerShell executable.
This field represents the PowerShell policy which is passed to the PowerShell executable.
This field represents the type of the PowerShell script. This option is passed to the PowerShell executable just before the PowerShell script.
(Optional) This field represents the installation directory of the PowerShell. The PowerShell command in this directory is used when executing the PowerShell script. If this field is set, the absolute path of PowerShell binary is formed by appending "PS_DIR + directory separator + PS_CMD". You can use this option if the PowerShell installation directory is not present in the PATH variable or you want to use the PowerShell from a non-default location.
This is an Optional field and is not set by default.
For example, C:\PowerShellInstallDir.
The following code sample provides an example of a default blpowershell.cnf configuration file on Windows environment:
PS_STATE=Enabled PS_CMD=powershell.exe PS_ARGS=-NoLogo -inputformat NONE -NonInteractive PS_POLICY=-ExecutionPolicy RemoteSigned PS_SCRIPT_TYPE=-File
To manage PowerShell configurations
A new NSH remote command (blpowershell) is provided to manage the PowerShell default configurations. This command can be executed through a NSH Type 1 script job. The following table lists the options of the command:
Enables the PowerShell feature.
Disables the PowerShell feature.
-setoption "option" "value"
Set the value of the option in blpowershell.cnf configuration file. For example, the following command sets PS_STATE=disable in configuration file and disables the PowerShell feature:
Retrieves the configured value of the option from blpowershell.cnf configuration file.
Retrieves all the configured options from blpowershell.cnf configuration file.
Resets all options to default values in blpowershell.cnf configuration file.
Removes the option from blpowershell.cnf configuration file.
|Displays the usage message.|
The following code sample provides an example:
AppServerHost% cd //Win-Host Win-Host% blpowershell -help blpowershell: Command to manage configurations stored in blpowershell.cnf file. Usage: blpowershell -enable <enable powershell feature> blpowershell -disable <disable powershell feature> blpowershell -setoption "option" "value" <set "option" to "value" in configuration file> blpowershell -getoption "option" <retrieves configured value of "option" from configuration file> blpowershell -getoption <retrieves all the configured values from configuration file> blpowershell -resetoption <reset all option to default values in configuration file> blpowershell -removeoption "option" <remove "option" from configuration file> blpowershell -help <print this usage message> Win-Host% blpowershell -getoption PS_STATE=Enabled PS_CMD=powershell.exe PS_ARGS=-NoLogo -inputformat NONE -NonInteractive PS_POLICY=-ExecutionPolicy RemoteSigned PS_SCRIPT_TYPE=-File Win-Host% blpowershell -getoption PS_ARGS -NoLogo -inputformat NONE -NonInteractive Win-Host% blpowershell -setoption PS_ARGS "-inputformat TEXT -NonInteractive" Win-Host% blpowershell -getoption PS_ARGS -inputformat TEXT -NonInteractive Win-Host%
To override PowerShell configurations at runtime
The default PowerShell options are configured in the blpowershell.cnf file. These PowerShell options are used when creating the final PowerShell command line.
However, you can also use additional PowerShell options at runtime when executing the PowerShell script. When you use these options along with the script, these are used in creating the final PowerShell command line, and these options are not passed to the PowerShell script.
For example, when a sample.ps1 script is executed against a target Windows server where default powershell options are present, the final powershell command is created as:
powershell.exe -NoLogo -inputformat NONE -NonInteractive -ExecutionPolicy RemoteSigned -File sample.ps1
The following table lists the available options which can be used to override the configured PowerShell options at runtime. The Example column shows the final PowerShell command formed when the specified overriding option is used.
Ignore the configured PS_ARGS values.
Add the provided value to PowerShell arguments when forming the final command.
Ignore the configured PS_DIR values.
Use the provided directory value instead of the configured PS_DIR.
Use the provided command value instead of the configured PS_CMD.
You can also use a combination of one or more options. The following code sample provides an example when you are using blpsignoreargs and blpsaddargs options in a PowerShell script file named sample.ps1:
Option used: -blpsignoreargs -blpsaddargs "-WindowStyle Minimized" Final command: powershell.exe -WindowStyle Minimized -ExecutionPolicy RemoteSigned -File sample.ps1
For more information about how to pass the overriding options at runtime in NSH Type 3 script by using command line, see Executing PowerShell scripts on target servers.
The following video (6:28) provides an overview of how to manage the blpowershell.cnf file.
The following videos provide an overview of how to override the PowerShell configurations at runtime.