Skip to content

Commit

Permalink
fix: added splatting to azure-cli scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ssokolic committed Oct 18, 2024
1 parent 39e4132 commit 75c0392
Show file tree
Hide file tree
Showing 98 changed files with 1,132 additions and 1,417 deletions.
2 changes: 1 addition & 1 deletion aws-cli/workspaces/aws-cli-stop-worksapce.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$AzResourceGroupName = "myResourceGroupName"
[string]$AzResourceGroup = "myResourceGroup"
)

#Set Error Action to Silently Continue
Expand Down
4 changes: 2 additions & 2 deletions aws-cli/workspaces/wip_aws-cli-create-workspace.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
.LINK
https://github.com/xoap-io/scripted-actions
.PARAMETER AzResourceGroupName
.PARAMETER AzResourceGroup
Defines the name of the Azure Resource Group.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$AzResourceGroupName = 'myResourceGroup'
[string]$AzResourceGroup = 'myResourceGroup'
)

#Set Error Action to Silently Continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
.LINK
https://github.com/xoap-io/scripted-actions
.PARAMETER AzResourceGroupName
.PARAMETER AzResourceGroup
Defines the name of the Azure Resource Group.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$AzResourceGroupName
[string]$AzResourceGroup
)

#Set Error Action to Silently Continue
Expand Down
4 changes: 2 additions & 2 deletions aws-ps/connect/wip_set-awscredential.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
.LINK
https://github.com/xoap-io/scripted-actions
.PARAMETER AzResourceGroupName
.PARAMETER AzResourceGroup
Defines the name of the Azure Resource Group.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$AzResourceGroupName
[string]$AzResourceGroup
)

#Set Error Action to Silently Continue
Expand Down
22 changes: 9 additions & 13 deletions azure-cli/avd/az-cli-avd-application-group-create.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.DESCRIPTION
This script creates an Azure Virtual Desktop Application Group with the Azure CLI.
The script uses the following Azure CLI command:
az desktopvirtualization applicationgroup create --resource-group $AzResourceGroupName --name $AzAppGroupName --location $AzLocation --host-pool-arm-path $AzHostPoolArmPath --application-group-type $AzAppGroupType
az desktopvirtualization applicationgroup create --resource-group $AzResourceGroup --name $AzAppGroupName --location $AzLocation --host-pool-arm-path $AzHostPoolArmPath --application-group-type $AzAppGroupType
.PARAMETER AppGroupType
Defines the type of the Azure Virtual Desktop Application Group.
Expand All @@ -16,7 +16,7 @@
.PARAMETER Name
Defines the name of the Azure Virtual Desktop Application Group.
.PARAMETER ResourceGroupName
.PARAMETER ResourceGroup
Defines the name of the Azure Resource Group.
.PARAMETER Description
Expand All @@ -32,7 +32,7 @@
Defines the tags for the Azure Virtual Desktop Application Group.
.EXAMPLE
.\az-cli-avd-applicationgroup-create.ps1 -AzResourceGroupName "MyResourceGroup" -AzAppGroupName "MyAppGroup" -AzLocation "eastus" -AzHostPoolArmPath "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DesktopVirtualization/hostPools/myHostPool" -AzAppGroupType "RemoteApp"
.\az-cli-avd-applicationgroup-create.ps1 -AzResourceGroup "MyResourceGroup" -AzAppGroupName "MyAppGroup" -AzLocation "eastus" -AzHostPoolArmPath "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DesktopVirtualization/hostPools/myHostPool" -AzAppGroupType "RemoteApp"
.LINK
https://learn.microsoft.com/en-us/cli/azure/desktopvirtualization/applicationgroup
Expand Down Expand Up @@ -67,7 +67,7 @@ param(

[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$ResourceGroupName,
[string]$ResourceGroup,

[Parameter(Mandatory=$false)]
[string]$Description,
Expand Down Expand Up @@ -104,12 +104,11 @@ param(
)

# Splatting parameters for better readability
$parameters = @{
'--application-group-type' = $AppGroupType
'--resource-group'= $ResourceGroupName
'--name' = $AppGroupName
'--host-pool-arm-path' = $HostPoolArmPath
}
$parameters = `
'--application-group-type', $AppGroupType
'--resource-group', $ResourceGroup
'--name', $AppGroupName
'--host-pool-arm-path', $HostPoolArmPath

if ($Description) {
$parameters += '--description', $Description
Expand All @@ -135,10 +134,7 @@ try {

} catch {
# Log the error to the console

Write-Output "Error message $errorMessage"


Write-Error "Failed to create the Azure Virtual Desktop Application Group: $($_.Exception.Message)"

} finally {
Expand Down
22 changes: 9 additions & 13 deletions azure-cli/avd/az-cli-avd-application-group-delete.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
.DESCRIPTION
This script deletes an Azure Virtual Desktop Application Group with the Azure CLI.
The script uses the following Azure CLI command:
az desktopvirtualization applicationgroup delete --name $AzAppGroupName --resource-group $AzResourceGroupName --subscription $AzSubscription --yes
az desktopvirtualization applicationgroup delete --name $AzAppGroupName --resource-group $AzResourceGroup --subscription $AzSubscription --yes
.PARAMETER IDs
The IDs of the Azure Virtual Desktop Application Group.
.PARAMETER Name
Defines the name of the Azure Virtual Desktop Application Group.
.PARAMETER ResourceGroupName
.PARAMETER ResourceGroup
Defines the name of the Azure Resource Group.
.PARAMETER yes
Do not prompt for confirmation.
.EXAMPLE
.\az-cli-avd-applicationgroup-delete.ps1 -AzAppGroupName "MyAppGroup" -AzResourceGroupName "MyResourceGroup" -AzSubscription "MySubscription" -AzYes
.\az-cli-avd-applicationgroup-delete.ps1 -AzAppGroupName "MyAppGroup" -AzResourceGroup "MyResourceGroup" -AzSubscription "MySubscription" -AzYes
.LINK
https://learn.microsoft.com/en-us/cli/azure/desktopvirtualization/applicationgroup
Expand All @@ -47,20 +47,19 @@ param(

[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$ResourceGroupName,
[string]$ResourceGroup,

[Parameter(Mandatory=$false)]
[ValidateNotNullOrEmpty()]
[switch]$yes
)

# Splatting parameters for better readability
$parameters = @{
'--ids'= $IDs
'--name'= $NName
'--resource-group'= $ResourceGroupName
'--yes' = $yes
}
$parameters = `
'--ids', $IDs
'--name', $NName
'--resource-group', $ResourceGroup
'--yes', $yes

# Set Error Action to Stop
$ErrorActionPreference = "Stop"
Expand All @@ -74,10 +73,7 @@ try {

} catch {
# Log the error to the console

Write-Output "Error message $errorMessage"


Write-Error "Failed to delete the Azure Virtual Desktop Application Group: $($_.Exception.Message)"

} finally {
Expand Down
22 changes: 9 additions & 13 deletions azure-cli/avd/az-cli-avd-application-group-list.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
.DESCRIPTION
This script lists Azure Virtual Desktop Application Groups with the Azure CLI.
The script uses the following Azure CLI command:
az desktopvirtualization applicationgroup list --resource-group $AzResourceGroupName
az desktopvirtualization applicationgroup list --resource-group $AzResourceGroup
.PARAMETER ResourceGroupName
.PARAMETER ResourceGroup
Defines the name of the Azure Resource Group.
.PARAMETER Filter
Expand All @@ -20,7 +20,7 @@
Token to retrieve the next page of results.
.EXAMPLE
.\az-cli-avd-applicationgroup-list.ps1 -AzResourceGroupName "MyResourceGroup"
.\az-cli-avd-applicationgroup-list.ps1 -AzResourceGroup "MyResourceGroup"
.LINK
https://learn.microsoft.com/en-us/cli/azure/desktopvirtualization/applicationgroup
Expand Down Expand Up @@ -51,16 +51,15 @@ param(

[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$ResourceGroupName
[string]$ResourceGroup
)

# Splatting parameters for better readability
$parameters = @{
'--filter' = $Filter
'--max-items' = $MaxItems
'--next-token' = $NextToken
'--resource-group' = $ResourceGroupName
}
$parameters = `
'--filter', $Filter
'--max-items', $MaxItems
'--next-token', $NextToken
'--resource-group', $ResourceGroup

# Set Error Action to Stop
$ErrorActionPreference = "Stop"
Expand All @@ -74,10 +73,7 @@ try {

} catch {
# Log the error to the console

Write-Output "Error message $errorMessage"


Write-Error "Failed to list the Azure Virtual Desktop Application Groups: $($_.Exception.Message)"

} finally {
Expand Down
20 changes: 8 additions & 12 deletions azure-cli/avd/az-cli-avd-application-group-show.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
.DESCRIPTION
This script shows details of an Azure Virtual Desktop Application Group with the Azure CLI.
The script uses the following Azure CLI command:
az desktopvirtualization applicationgroup show --name $AzAppGroupName --resource-group $AzResourceGroupName
az desktopvirtualization applicationgroup show --name $AzAppGroupName --resource-group $AzResourceGroup
.PARAMETER IDs
One or more resource IDs (space-delimited).
.PARAMETER Name
The name of the Azure Virtual Desktop Application Group.
.PARAMETER ResourceGroupName
.PARAMETER ResourceGroup
The name of the Azure Resource Group.
.EXAMPLE
.\az-cli-avd-applicationgroup-show.ps1 -AzAppGroupName "MyAppGroup" -AzResourceGroupName "MyResourceGroup"
.\az-cli-avd-applicationgroup-show.ps1 -AzAppGroupName "MyAppGroup" -AzResourceGroup "MyResourceGroup"
.LINK
https://learn.microsoft.com/en-us/cli/azure/desktopvirtualization/applicationgroup
Expand All @@ -44,15 +44,14 @@ param(

[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$ResourceGroupName
[string]$ResourceGroup
)

# Splatting parameters for better readability
$parameters = @{
'--ids' = $AzIds
'--name' = $AzAppGroupName
'--resource-group' = $AzResourceGroupName
}
$parameters = `
'--ids', $Ids
'--name', $AppGroupName
'--resource-group', $ResourceGroup

# Set Error Action to Stop
$ErrorActionPreference = "Stop"
Expand All @@ -66,10 +65,7 @@ try {

} catch {
# Log the error to the console

Write-Output "Error message $errorMessage"


Write-Error "Failed to retrieve the Azure Virtual Desktop Application Group details: $($_.Exception.Message)"

} finally {
Expand Down
32 changes: 14 additions & 18 deletions azure-cli/avd/az-cli-avd-application-group-update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.DESCRIPTION
This script updates an Azure Virtual Desktop Application Group with the Azure CLI.
The script uses the following Azure CLI command:
az desktopvirtualization applicationgroup update --name $AzAppGroupName --resource-group $AzResourceGroupName
az desktopvirtualization applicationgroup update --name $AzAppGroupName --resource-group $AzResourceGroup
.PARAMETER Add
Add an object to a list of objects by specifying a path and key value pairs.
Expand Down Expand Up @@ -44,7 +44,7 @@
Defines the tags for the Azure Virtual Desktop Application Group.
.EXAMPLE
.\az-cli-avd-applicationgroup-update.ps1 -AzAppGroupName "MyAppGroup" -AzResourceGroupName "MyResourceGroup"
.\az-cli-avd-applicationgroup-update.ps1 -AzAppGroupName "MyAppGroup" -AzResourceGroup "MyResourceGroup"
.LINK
https://learn.microsoft.com/en-us/cli/azure/desktopvirtualization/applicationgroup
Expand Down Expand Up @@ -127,19 +127,18 @@ param(
)

# Splatting parameters for better readability
$parameters = @{
'--add'= $Add
'--application-group-type'= $ApplicationGroupType
'--description'= $Description
'--force-string'= $ForceString
'--friendly-name'= $FriendlyName
'--host-pool-arm-path'= $HostPoolArmPath
'--ids'= $IDs
'--name'= $Name
'--remove'= $Remove
'--resource-group'= $ResourceGroup
'--set'= $Set
}
$parameters = `
'--add', $Add
'--application-group-type', $ApplicationGroupType
'--description', $Description
'--force-string', $ForceString
'--friendly-name', $FriendlyName
'--host-pool-arm-path', $HostPoolArmPath
'--ids', $IDs
'--name', $Name
'--remove', $Remove
'--resource-group', $ResourceGroup
'--set', $Set

if ($Tags) {
$parameters += '--tags', $Tags
Expand All @@ -157,10 +156,7 @@ try {

} catch {
# Log the error to the console

Write-Output "Error message $errorMessage"


Write-Error "Failed to update the Azure Virtual Desktop Application Group: $($_.Exception.Message)"

} finally {
Expand Down
Loading

0 comments on commit 75c0392

Please sign in to comment.