Test D365Command - FH-Inway/d365fo.tools GitHub Wiki
Validate or show parameter set details with colored output
Test-D365Command [-CommandText] <String> [-Mode] <String> [-SplatInput <Hashtable>] [-ShowSplatStyleV1]
[-ShowSplatStyleV2] [-IncludeHelp] [<CommonParameters>]
Analyze a function and it's parameters
The cmdlet / function is capable of validating a string input with function name and parameters
Test-D365Command -CommandText 'Import-D365Bacpac -ImportModeTier2 -SqlUser "sqladmin" -SqlPwd "XyzXyz" -BacpacFile2 "C:\temp\uat.bacpac"' -Mode "Validate" -IncludeHelp
This will validate all the parameters that have been passed to the Import-D365Bacpac cmdlet. All supplied parameters that matches a parameter will be marked with an asterisk. Will print the coloring help.
Test-D365Command -CommandText 'Import-D365Bacpac' -Mode "ShowParameters" -IncludeHelp
This will display all the parameter sets and their individual parameters. Will print the coloring help.
$params = @{}
PS C:\> $params.DatabaseName = "SAMPLEVALUE" PS C:\> Test-D365Command -CommandText 'Import-D365Bacpac -ImportModeTier2' -SplatInput $params -Mode "Validate"
This builds a hashtable with a property names "DatabaseName". The hashtable is passed to the cmdlet to be part of the validation.
The string that you want to analyze
If there is parameter value present, you have to use the opposite quote strategy to encapsulate the string correctly
E.g. for double quotes -CommandText 'Import-D365Bacpac -ImportModeTier2 -SqlUser "sqladmin" -SqlPwd "XyzXyz" -BacpacFile2 "C:\temp\uat.bacpac"'
E.g. for single quotes -CommandText "Import-D365Bacpac -ExportModeTier2 -SqlUser 'sqladmin' -SqlPwd 'XyzXyz' -BacpacFile2 'C:\temp\uat.bacpac'"
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The operation mode of the cmdlet / function
Valid options are:
- Validate
- ShowParameters
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Pass in your hashtable that you use for your command execution and have it validated
Type: Hashtable
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Include an hashtable splatting for all parameter sets in the output
The example is built like this: PS C:\> $params = @{} PS C:\> $params.PropertyName = "SAMPLEVALUE" PS C:\> Test-FakeCommand @params
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Include an hashtable splatting for all parameter sets in the output
The example is built like this: PS C:\> $params = @{ PS C:\> PropertyName = "SAMPLEVALUE" PS C:\> } PS C:\> Test-FakeCommand @params
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Switch to instruct the cmdlet / function to output a simple guide with the colors in it
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Author: Mötz Jensen (@Splaxi)