Skip to content

Commit c5026de

Browse files
author
haraldpfirmann
committed
Scripts reviewed
1 parent 9d96444 commit c5026de

7 files changed

+13
-29
lines changed

Azure/Compute/Get-AzVMs.ps1

+3-5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ param(
4747
[string]$Name,
4848
[string]$ResourceGroupName,
4949
[string]$Location,
50-
[string]$Properties = "Name, Location, ResourceGroupName, Tags, VmId, StatusCode, ID",
50+
[ValidateSet('*','Name', 'Location', 'ResourceGroupName', 'Tags', 'VmId', 'StatusCode', 'ID')]
51+
[string[]]$Properties = @('Name', 'Location', 'ResourceGroupName', 'Tags', 'VmId', 'StatusCode', 'ID'),
5152
[string]$Tenant
5253
)
5354

@@ -56,9 +57,6 @@ Import-Module Az
5657
try{
5758
# ConnectAzure -AzureCredential $AzureCredential -Tenant $Tenant
5859

59-
if([System.String]::IsNullOrWhiteSpace($Properties)){
60-
$Properties = '*'
61-
}
6260
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'}
6361

6462
if([System.String]::IsNullOrWhiteSpace($Name) -eq $false){
@@ -69,7 +67,7 @@ try{
6967
$cmdArgs.Add('Location',$Location)
7068
}
7169

72-
$ret = Get-AzVM @cmdArgs | Select-Object $Properties.Split(',')
70+
$ret = Get-AzVM @cmdArgs | Select-Object $Properties
7371

7472
if($SRXEnv) {
7573
$SRXEnv.ResultMessage = $ret

Azure/Network/Get-AzNetworkSecurityGroups.ps1

+3-6
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,15 @@ param(
4444
[pscredential]$AzureCredential,
4545
[string]$Name,
4646
[string]$ResourceGroupName,
47-
[string]$Properties = "Name,Location,ResourceGroupName,Id,Tags,Etag,ProvisioningState,Subnets,ResourceGuid",
47+
[ValidateSet('*','Name','Location','ResourceGroupName','Id','Tags','Etag','ProvisioningState','Subnets','ResourceGuid')]
48+
[string[]]$Properties = @('Name','Location','ResourceGroupName','Id','Tags','Etag','ProvisioningState','Subnets','ResourceGuid'),
4849
[string]$Tenant
4950
)
5051

5152
Import-Module Az
5253

5354
try{
5455
# ConnectAzure -AzureCredential $AzureCredential -Tenant $Tenant
55-
56-
if([System.String]::IsNullOrWhiteSpace($Properties)){
57-
$Properties = '*'
58-
}
5956

6057
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'}
6158

@@ -66,7 +63,7 @@ try{
6663
$cmdArgs.Add('ResourceGroupName',$ResourceGroupName)
6764
}
6865

69-
$ret = Get-AzNetworkSecurityGroup @cmdArgs | Select-Object $Properties.Split(',')
66+
$ret = Get-AzNetworkSecurityGroup @cmdArgs | Select-Object $Properties
7067

7168
if($SRXEnv) {
7269
$SRXEnv.ResultMessage = $ret

Azure/SQL/Get-AzDatabases.1.ps1

+3-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ param(
4949
[Parameter(Mandatory = $true)]
5050
[string]$ServerName,
5151
[string]$DBName,
52-
[string]$Properties = "ResourceGroupName,ServerName,DatabaseName,Location,DatabaseId,Edition,CollationName,Status,CreationDate,Tags",
52+
[ValidateSet('*','ResourceGroupName','ServerName','DatabaseName','Location','DatabaseId','Edition','CollationName','Status','CreationDate','Tags')]
53+
[string[]]$Properties = @('ResourceGroupName','ServerName','DatabaseName','Location','DatabaseId','Edition','CollationName','Status','CreationDate','Tags'),
5354
[string]$Tenant
5455
)
5556

@@ -58,9 +59,6 @@ Import-Module Az
5859
try{
5960
# ConnectAzure -AzureCredential $AzureCredential -Tenant $Tenant
6061

61-
if([System.String]::IsNullOrWhiteSpace($Properties)){
62-
$Properties = '*'
63-
}
6462
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
6563
'ServerName' = $ServerName
6664
'ResourceGroupName' = $ResourceGroupName}
@@ -69,7 +67,7 @@ try{
6967
$cmdArgs.Add('DatabaseName',$DBName)
7068
}
7169

72-
$ret = Get-AzSqlDatabase @cmdArgs | Select-Object $Properties.Split(',')
70+
$ret = Get-AzSqlDatabase @cmdArgs | Select-Object $Properties
7371

7472
if($SRXEnv) {
7573
$SRXEnv.ResultMessage = $ret

Azure/SQL/Get-AzElasticPools.ps1

+3-6
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ param(
4949
[Parameter(Mandatory = $true)]
5050
[string]$ServerName,
5151
[string]$PoolName,
52-
[string]$Properties = "ElasticPoolName,ResourceGroupName,ServerName,ResourceID,Location,State,Edition,Dtu,DatabaseDtuMax,DatabaseDtuMin,StorageMB,CreationDate,Tags",
52+
[ValidateSet('*','ElasticPoolName','ResourceGroupName','ServerName','ResourceID','Location','State','Edition','Dtu','DatabaseDtuMax','DatabaseDtuMin','StorageMB','CreationDate','Tags')]
53+
[string[]]$Properties = @('ElasticPoolName','ResourceGroupName','ServerName','ResourceID','Location','State','Edition','Dtu','DatabaseDtuMax','DatabaseDtuMin','StorageMB','CreationDate','Tags'),
5354
[string]$Tenant
5455
)
5556

@@ -58,10 +59,6 @@ Import-Module Az
5859
try{
5960
# ConnectAzure -AzureCredential $AzureCredential -Tenant $Tenant
6061

61-
if([System.String]::IsNullOrWhiteSpace($Properties)){
62-
$Properties = '*'
63-
}
64-
6562
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
6663
'ServerName' = $ServerName
6764
'ResourceGroupName' = $ResourceGroupName}
@@ -70,7 +67,7 @@ try{
7067
$cmdArgs.Add('ElasticPoolName',$PoolName)
7168
}
7269

73-
$ret = Get-AzSqlElasticPool @cmdArgs | Select-Object $Properties.Split(',')
70+
$ret = Get-AzSqlElasticPool @cmdArgs | Select-Object $Properties
7471

7572
if($SRXEnv) {
7673
$SRXEnv.ResultMessage = $ret

Azure/SQL/Remove-AzDatabase.ps1

-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ Import-Module Az
5555
try{
5656
# ConnectAzure -AzureCredential $AzureCredential -Tenant $Tenant
5757

58-
if([System.String]::IsNullOrWhiteSpace($Properties)){
59-
$Properties = '*'
60-
}
6158
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
6259
'Force' = $null
6360
'Confirm' = $false

Azure/SQL/Remove-AzElasticPool.ps1

-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ Import-Module Az
5555
try{
5656
# ConnectAzure -AzureCredential $AzureCredential -Tenant $Tenant
5757

58-
if([System.String]::IsNullOrWhiteSpace($Properties)){
59-
$Properties = '*'
60-
}
6158
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
6259
'Force' = $null
6360
'Confirm' = $false

Azure/_LIB_/AzureAzLibrary.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function DisconnectAzure(){
8585

8686
try{
8787
[string]$conName = 'SRAzureAccess'
88-
if([System.String]::IsNullOrWhiteSpace($Tenant) -eq $true){
88+
if([System.String]::IsNullOrWhiteSpace($Tenant) -eq $false){
8989
$conName = 'SR' + $Tenant
9090
}
9191
Disconnect-AzAccount -Confirm:$false -ErrorAction Stop

0 commit comments

Comments
 (0)