Important

   

This space contains documentation for TrueSight Server Automation 8.9.03 and the later service packs for 8.9. For earlier releases, see BMC Server Automation 8.9.

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.

Note

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:

Name

Default value

Description

PS_STATE

Enabled

This field is used to enable or disable the PowerShell feature. The possible values are Enabled or Disabled.

PS_CMD

Windows - powershell.exe/pwsh.exe

Non-windows - pwsh

This field represents the name of the PowerShell executable. The possible values are:

Microsoft Windows:

  • powershell.exe - is used if powershell.exe is found in the PATH environment variable.
  • pwsh.exe - is used if powershell.exe is not found in the PATH environment variable and if pwsh.exe is found in the PATH environment variable.
    When powershell.exe or pwsh.exe is not found in the PATH environment variable, the default value of this field is powershell.exe.

Linux:

pwsh

PS_ARGS

-NoLogo -inputformat NONE -NonInteractive

This field represents the PowerShell options that are passed to the PowerShell executable.

PS_POLICY

-ExecutionPolicy RemoteSigned

This field represents the PowerShell policy which is passed to the PowerShell executable. 

PS_SCRIPT_TYPE

-File

This field represents the type of the PowerShell script. This option is passed to the PowerShell executable just before the PowerShell script.

PS_DIR


(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:

Option

Description

-enable

Enables the PowerShell feature.

-disable

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:

blpowershell -setoption PS_STATE "disabled"

-getoption "option"

Retrieves the configured value of the option from blpowershell.cnf configuration file.

-getoption

Retrieves all the configured options from blpowershell.cnf configuration file.

-resetoption

Resets all options to default values in blpowershell.cnf configuration file.

-removeoption "option"

Removes the option from blpowershell.cnf configuration file.

-help

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.

Option

Description

Example

-blpsignoreargs

Ignore the configured PS_ARGS values.

Option used: -blpsignoreargs

Final command:

powershell.exe -ExecutionPolicy RemoteSigned -File sample.ps1

-blpsaddargs "Value"

Add the provided value to PowerShell arguments when forming the final command.

Option used: -blpsaddargs "-version 2.0"

Final command:

powershell.exe -version 2.0 -NoLogo -inputformat NONE -NonInteractive -ExecutionPolicy RemoteSigned -File sample.ps1

-blpsignoredir

Ignore the configured PS_DIR values.

Option used: -blpsignoredir

Final Command:

powershell.exe -NoLogo -inputformat NONE -NonInteractive -ExecutionPolicy RemoteSigned -File sample.ps1

-blpsusedir "Value"

Use the provided directory value instead of the configured PS_DIR.

Option used: -blpsusedir  "C:\Windows\System32\WindowsPowerShell\v1.0"

Final Command:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -inputformat NONE -NonInteractive -ExecutionPolicy RemoteSigned -File sample.ps1

-blpsusecmd "Value"

Use the provided command value instead of the configured PS_CMD.

Option used: -blpsusecmd  "pwsh.exe"

Final Command:

pwsh.exe -NoLogo -inputformat NONE -NonInteractive -ExecutionPolicy RemoteSigned -File sample.ps1

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.

Videos

The following video (6:28) provides an overview of how to manage the blpowershell.cnf file.

https://youtu.be/Uqe5bym3jjk

The following videos provide an overview of how to override the PowerShell configurations at runtime.


https://youtu.be/jAXy2Im4U-0

https://youtu.be/RBPp4ezMqY0

Related topics

Executing PowerShell scripts on target servers

FAQs and additional resources

Was this page helpful? Yes No Submitting... Thank you

Comments