Skip to content

Commit ae2cad2

Browse files
GeorgeH-MSbganapa
authored andcommitted
Update Create-AzSStorageDashboard.ps1
Remove -AzureRM content
1 parent 99e67d4 commit ae2cad2

1 file changed

Lines changed: 14 additions & 40 deletions

File tree

CapacityManagement/DashboardGenerator/Create-AzSStorageDashboard.ps1

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -79,51 +79,25 @@ function Save-AzureStackVolumesPerformanceDashboardJson {
7979
[string]$outputLocation = '.'
8080
)
8181

82-
# check if AzureRM Module is present
83-
$AzureRMModule = Get-command -Name Get-AzureRmContext -ErrorAction SilentlyContinue
84-
if($AzureRMModule){
82+
# check if Az Module is present
83+
$AzModule = Get-command -Name Get-AzContext -ErrorAction SilentlyContinue
84+
if($AzModule){
8585
# do nothing, cmdlets should work natively.
86-
8786
} else {
88-
# check if Az Module is present
89-
$AzModule = Get-command -Name Get-AzContext -ErrorAction SilentlyContinue
90-
if($AzModule){
91-
$answer = Read-Host "`n'Az' module detected, script requires 'Enable-AzureRmAlias' to be enabled for this session.`n`nType 'Y' to Enable or Press Enter for Exit`n"
92-
switch($answer){
93-
Y {
94-
try {
95-
Write-Host "`nExecuting 'Enable-AzureRmAlias -Scope Local' to created Aliases, this will not persist outside of this session.`n"
96-
Enable-AzureRmAlias -Scope Local
97-
} catch {
98-
Write-Host -ForegroundColor Red "Error: $($error[0].Exception.Message)"
99-
throw "Error executing 'Enable-AzureRmAlias'"
100-
}
101-
}
102-
$null {
103-
Write-Host "Script exiting..."
104-
Return
105-
}
106-
default {
107-
Write-Host "Script exiting..."
108-
Return
109-
}
110-
}
111-
} else {
112-
throw "Error: This script requires either the 'AzureRM' or 'Az' PowerShell Module to be installed."
113-
}
87+
throw "Error: This script requires 'Az' PowerShell Module to be installed."
11488
}
11589

11690
# If user do not input DefaultProfile
11791
if ($null -eq $DefaultProfile) {
118-
$script:context = Get-AzureRmContext
92+
$script:context = Get-AzContext
11993
}
12094
else {
12195
$script:context = $DefaultProfile.Context
12296
}
12397

124-
# if user hadn't added and login to AzureRmEnvironment, exit
98+
# if user hadn't added and login to AzEnvironment, exit
12599
if ($null -eq $script:context.Account) {
126-
throw "Please login in AzureRm or Az account first."
100+
throw "Please login in Az account first."
127101
}
128102

129103
if ((Test-Path -Path $outputLocation) -eq $false) {
@@ -192,13 +166,13 @@ function Get-AzureStackResourceId {
192166
param (
193167
)
194168
try {
195-
Write-Host "Getting resource Id from AzureRmSubscription."
169+
Write-Host "Getting resource Id from AzSubscription."
196170
$adminSubscription = $script:context.Subscription
197-
$location = Get-AzureRmLocation -DefaultProfile $script:context -ErrorAction Stop -Verbose
171+
$location = Get-AzLocation -DefaultProfile $script:context -ErrorAction Stop -Verbose
198172
}
199173
catch {
200174
Write-Error $_
201-
throw "Please login in AzureRm or Az account. If still happens, check your environment settings in psm1 file."
175+
throw "Please login in Az account. If still happens, check your environment settings in psm1 file."
202176
}
203177
"subscriptions/$($adminSubscription.Id)/resourceGroups/System.$($location.location)/providers/Microsoft.Fabric.Admin/fabricLocations/$($location.location)"
204178
}
@@ -210,11 +184,11 @@ function Get-AzureStackVolumes {
210184
try {
211185
Write-Host "Getting volumes data from ARM."
212186

213-
$location = Get-AzureRmLocation -DefaultProfile $script:context -ErrorAction Stop -Verbose
187+
$location = Get-AzLocation -DefaultProfile $script:context -ErrorAction Stop -Verbose
214188
$location = $location.Location
215-
$scaleUnits = Get-AzureRmResource -DefaultProfile $script:context -ResourceName $location -ResourceType Microsoft.Fabric.Admin/fabricLocations/scaleunits -ResourceGroupName "System.$($location)" -ApiVersion "2016-05-01"
216-
$sotrageSubSystems = Get-AzureRmResource -DefaultProfile $script:context -ResourceName $scaleUnits.Name -ResourceType Microsoft.Fabric.Admin/fabricLocations/scaleunits/storageSubSystems -ResourceGroupName "System.$($location)" -ApiVersion "2018-10-01"
217-
$volumes = Get-AzureRmResource -DefaultProfile $script:context -ResourceName $sotrageSubSystems.Name -ResourceType Microsoft.Fabric.Admin/fabricLocations/scaleunits/storageSubSystems/volumes -ResourceGroupName "System.$($location)" -ApiVersion "2018-10-01"
189+
$scaleUnits = Get-AzResource -DefaultProfile $script:context -ResourceName $location -ResourceType Microsoft.Fabric.Admin/fabricLocations/scaleunits -ResourceGroupName "System.$($location)" -ApiVersion "2016-05-01"
190+
$sotrageSubSystems = Get-AzResource -DefaultProfile $script:context -ResourceName $scaleUnits.Name -ResourceType Microsoft.Fabric.Admin/fabricLocations/scaleunits/storageSubSystems -ResourceGroupName "System.$($location)" -ApiVersion "2018-10-01"
191+
$volumes = Get-AzResource -DefaultProfile $script:context -ResourceName $sotrageSubSystems.Name -ResourceType Microsoft.Fabric.Admin/fabricLocations/scaleunits/storageSubSystems/volumes -ResourceGroupName "System.$($location)" -ApiVersion "2018-10-01"
218192
}
219193
catch {
220194
Write-Error $_.ToString()

0 commit comments

Comments
 (0)