Update-RpConfigCommand¶
SYNOPSIS¶
Modifies configuration parameters of a specified command in a PowerShell module using a configuration JSON file or an interactive WPF-based GUI.
SYNTAX¶
ShowDialog (Default)¶
Update-RpConfigCommand [-ModuleName <String>] [-CommandName <String>] [-Id <String>] [-ConfigFilePath <String>]
[-ShowDialog] [-ProgressAction <ActionPreference>] [<CommonParameters>]
ConfigurationItems¶
Update-RpConfigCommand [-ModuleName <String>] [-CommandName <String>] [-Id <String>] [-Parameters <Hashtable>]
[-Description <String>] [-ConfigFilePath <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
NoDialog¶
Update-RpConfigCommand [-Parameters <Hashtable>] [-Description <String>] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
DESCRIPTION¶
The `Update-RpConfigCommand` function is used to load and modify parameters for a specified command within a PowerShell module. The function retrieves configuration information from a JSON file and supports updating parameters either by launching a GUI (if `-ShowDialog` is specified) or by directly passing a hashtable of parameter values through the `-Parameters` parameter. The updated configuration is saved back to the JSON file, preserving all previous configurations.
By default, the function opens a GUI for parameter editing, making it user-friendly for interactive scenarios. Advanced users and scripts can also bypass the GUI and pass values directly through `-Parameters`.
EXAMPLES¶
EXAMPLE 1¶
Update-RpConfigCommand -ModuleName 'MilestonePSTools' -CommandName
'Get-VmsCameraReport' -Id 18 -ConfigFilePath $(Get-Rpconfigpath) -ShowDialog
This example loads the configuration for the 'Get-VmsCameraReport' command in the 'MilestonePSTools' module and opens a GUI dialog to allow users to interactively edit parameter values. Once edited, the configuration is saved back to the JSON file.
EXAMPLE 2¶
Update-RpConfigCommand -ModuleName 'MilestonePSTools' -CommandName
'Get-VmsCameraReport' -Id 18 -ConfigFilePath $(Get-Rpconfigpath) -Parameters
@{ "Verbose" = $true; "Debug" = $false }
This example directly sets the 'Verbose' and 'Debug' parameters without opening the GUI. A hashtable is provided via the `-Parameters` parameter, which updates the configuration in the JSON file with these values.
EXAMPLE 3¶
Update-RpConfigCommand -ModuleName 'MilestonePSTools' -CommandName
'Get-VmsCameraReport' -Id 18 -ConfigFilePath $(Get-Rpconfigpath) -Description
"New description for the command"
This example updates the description of the 'Get-VmsCameraReport' command in the 'MilestonePSTools' module without opening the GUI.
PARAMETERS¶
-ModuleName¶
The name of the module containing the command to be modified. This parameter is mandatory and required for identifying the correct module in the configuration.
Type: String
Parameter Sets: ShowDialog, ConfigurationItems
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-CommandName¶
The name of the specific command to be modified within the module. This parameter is mandatory and helps locate the command configuration within the JSON file.
Type: String
Parameter Sets: ShowDialog, ConfigurationItems
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-Id¶
A unique integer ID identifying the command version in the configuration file. This ensures that specific versions of the command can be targeted and modified.
Type: String
Parameter Sets: ShowDialog, ConfigurationItems
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-Parameters¶
(Optional) A hashtable containing parameter names as keys and their desired values as values. Use this parameter to bypass the GUI and directly update the command configuration with the specified values.
Type: Hashtable
Parameter Sets: ConfigurationItems, NoDialog
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-Description¶
(Optional) A string containing the new description for the command. Use this parameter to update the command description directly.
Type: String
Parameter Sets: ConfigurationItems, NoDialog
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-ConfigFilePath¶
The path to the configuration JSON file where command configurations are stored. This file is required and will be updated with any modified parameter values.
Type: String
Parameter Sets: ShowDialog, ConfigurationItems
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-ShowDialog¶
(Optional) Displays a WPF GUI dialog for interactive parameter editing. If this switch is specified, any `Parameters` passed directly will be ignored, and the GUI will allow users to make adjustments.
Type: SwitchParameter
Parameter Sets: ShowDialog
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-ProgressAction¶
{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters¶
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS¶
OUTPUTS¶
NOTES¶
The configuration file must be in JSON format and already include a structure for ConfigCommands and the specified module. Any missing structure will cause an error.
Note: The order of parameters in the GUI may not match the JSON file order due to how PowerShell handles JSON deserialization. To ensure a specific order, consider using an OrderedDictionary or manually managing parameter order.
Ensure that the PresentationFramework, PresentationCore, and WindowsBase assemblies are available for WPF support to allow the GUI dialog to open.