Skip to content

Commit d4ae15f

Browse files
effingerwknithinc
authored andcommitted
Support VNext update (#374)
* Delete ERCS_AzureStackLogs.ps1 * enhance error checking * Delete ERCS_AzureStackLogs.ps1 * .Net UI cleanup * Doc Update * Delete ERCS_AzureStackLogs.ps1 * Logic change check for Module * Delete AzS-PoSh-Environment.ps1 * added logic for logon failures * Delete AzS-PoSh-Environment.ps1 * UI update * Delete ERCS_AzureStackLogs.ps1 * Added CloudDeployment JSON check * Delete AzS-PoSh-Environment.ps1 * Added CloudDeployment JSON check * Delete ERCS_AzureStackLogs.ps1 * adding CloudDeploymentLogs * Update to zip exclusions
1 parent c46d2e2 commit d4ae15f

File tree

3 files changed

+114
-58
lines changed

3 files changed

+114
-58
lines changed

Support/AzS_PoSh/AzS-PoSh-Environment.ps1

+47-17
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,17 @@ $global:Toolspath ="C:\AzureStackTools\AzureStack-Tools-master"
112112
#Check for the JSON
113113
If ((Test-Path -Path "$($Env:ProgramData)\AzureStackStampInformation.json") -eq $true)
114114
{
115-
Write-Host "`n[INFO] Load AzureStackStampInformation.json" -ForegroundColor yellow
115+
Write-Host "`n[INFO] Loaded AzureStackStampInformation.json from ProgramData" -ForegroundColor Yellow
116116
$FoundJSONFile = Get-Content -Raw -Path "$($Env:ProgramData)\AzureStackStampInformation.json" | ConvertFrom-Json
117117
}
118+
If ((Test-Path -Path "$($Env:ProgramData)\AzureStackStampInformation.json") -eq $false)
119+
{
120+
if ((Test-Path -Path "$($env:SystemDrive)\CloudDeployment\Logs\AzureStackStampInformation.json") -eq $true)
121+
{
122+
Write-Host "`n[INFO] Loaded AzureStackStampInformation.json from CloudDeployment" -ForegroundColor Yellow
123+
$FoundJSONFile = Get-Content -Raw -Path "$($env:SystemDrive)\CloudDeployment\Logs\AzureStackStampInformation.json" | ConvertFrom-Json
124+
}
125+
}
118126

119127
#Go Get the JSON file
120128
if(!($FoundJSONFile))
@@ -238,32 +246,54 @@ If($envInfo)
238246
Try
239247
{
240248
$TenantId = $envInfo.TenantId
241-
Write-Host "`n[INFO] - Login to Azure RM with AzureStack Stamp Service Admin Account" -ForegroundColor Yellow
242-
Login-AzureRmAccount -Environment "AzureStackAdmin" -TenantId $TenantId
249+
Write-Host "`n[INFO] - Login to Azure RM" -ForegroundColor Yellow
250+
251+
function Read-InputBoxDialog([string]$Message, [string]$WindowTitle, [string]$DefaultText)
252+
{
253+
Add-Type -AssemblyName Microsoft.VisualBasic
254+
return [Microsoft.VisualBasic.Interaction]::InputBox($Message, $WindowTitle, $DefaultText)
255+
}
243256

244-
$location = Get-AzsLocation
245-
$location = $location.Name
257+
Write-Host "`n[Prompt] for AzureStack Administrator name" -ForegroundColor Yellow
246258

247-
Write-Host "`n[INFO] - Obtaining subscriptions" -ForegroundColor Yellow
248-
[array] $AllSubs = get-AzureRmSubscription
259+
[String]$AzSUser = Read-InputBoxDialog -Message "Please enter AzureStack the Admin you use to log into the Administrative portal: `n`n`tUSER@$($envInfo.IdTenantName)" -WindowTitle "Azure Stack Administrative portal user" -DefaultText "​SOMEUSER@$($envInfo.IdTenantName)"
260+
$cred = Get-Credential -UserName $AzSUser -Message "$($AzSUser) Password"
261+
$AzSLogin = Login-AzureRmAccount -Credential $cred -TenantId $TenantId -Environment "AzureStackAdmin"
262+
$azsadmin = $AzSLogin.Context.Account.Id
263+
if($azsadmin)
264+
{
265+
Write-Host "`t$($azsadmin)"
266+
$location = Get-AzsLocation
267+
$location = $location.Name
268+
269+
Write-Host "`n[INFO] - Obtaining subscriptions" -ForegroundColor Yellow
270+
[array] $AllSubs = get-AzureRmSubscription
271+
}
272+
Else
273+
{
274+
Write-Host "`n`t`t[Error] Did not login $_" -ForegroundColor Red
275+
Write-Host "`n Press any key to continue ...`n"
276+
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
277+
exit
278+
}
249279
}
250280
catch [System.Exception]
251281
{
252-
Write-Host "`n`t`t[Error] Wrong Password: $_" -ForegroundColor Red
282+
Write-Host "`n`t`t[Error] Wrong Username or Password: $_" -ForegroundColor Red
253283
Write-Host "`n Press any key to continue ...`n"
254284
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
255285
exit
256286
}
257-
If ($AllSubs.count -eq 1)
287+
If (($AllSubs.count -eq 1) -and ($azsadmin))
258288
{
259289
Select-AzureRmSubscription -Subscriptionid $AllSubs.id | Out-Null
260-
Write-Host "`tSuccess" -ForegroundColor Green
290+
Write-Host "`tSuccess" -ForegroundColor White
261291
}
262292
Else
263293
{
264-
If ($AllSubs)
294+
If (($AllSubs) -and ($azsadmin))
265295
{
266-
Write-Host "`tSuccess" -ForegroundColor Green
296+
Write-Host "`tSuccess" -ForegroundColor White
267297

268298
}
269299
Else
@@ -283,7 +313,7 @@ If($envInfo)
283313

284314
$SelSub = $SelSubName.SubscriptionId
285315
Select-AzureRmSubscription -Subscriptionid $SelSub | Out-Null
286-
Write-Host "`tSuccess" -ForegroundColor Green
316+
Write-Host "`tSuccess" -ForegroundColor White
287317
}
288318
Else
289319
{
@@ -303,7 +333,7 @@ If ((Test-Path -Path "$($AzSToolsPath)\Support\ERCS_Logs\ERCS_AzureStackLogs.ps1
303333
Write-host "`n[INFO] Copying files to $($LocalPath)" -ForegroundColor Yellow
304334
New-Item $LocalPath -Type directory -Force | out-null
305335
Copy-Item -Path $AzSToolsPath -Destination $LocalPath -Recurse | out-null
306-
Write-Host "`tSuccess" -ForegroundColor Green
336+
Write-Host "`tTools are installed" -ForegroundColor Green
307337
}
308338
catch [System.Exception]
309339
{
@@ -475,9 +505,8 @@ If ((Test-Path -Path "$($Toolspath)\Support\ERCS_Logs\ERCS_AzureStackLogs.ps1")
475505
return Get-Module
476506
}
477507

478-
479-
480-
508+
if($azsadmin)
509+
{
481510
#show Info made from the script
482511
Write-host "`n[INFO] `$EnvInfo variable created" -ForegroundColor Yellow
483512
Write-host "`tAvailable command: '`$EnvInfo' to view stamp endpoints`n"
@@ -488,3 +517,4 @@ Write-host "`n[INFO] AzureStackAdmin AzureRmEnvironment created" -ForegroundColo
488517
Write-host "`tRun 'Get-AzureRmEnvironment -Name AzureStackAdmin' to see environment "
489518
Write-host "`n[INFO] AzureStackUser AzureRmEnvironment created" -ForegroundColor Yellow
490519
Write-host "`tRun 'Get-AzureRmEnvironment -Name AzureStackUser' to see environment "
520+
}

Support/ERCS_Logs/ERCS_AzureStackLogs.ps1

+65-39
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<#
22
.SYNOPSIS
3-
Built to be run on the HLH or DVM from an administrative powershell session the script uses seven methods to find the privileged endpoint virtual machines. The script connects to selected privileged endpoint and runs Get-AzureStackLog with supplied parameters. If no parameters are supplied the script will default to prompting user via GUI for needed parameters.
3+
Built to be run on the HLH, DVM, or Jumpbox from an administrative powershell session the script uses seven methods to find the privileged endpoint virtual machines. The script connects to selected privileged endpoint and runs Get-AzureStackLog with supplied parameters. If no parameters are supplied the script will default to prompting user via GUI for needed parameters.
44
.DESCRIPTION
55
The script will use one of the below seven methods; Gather requested logs, Transcript, and AzureStackStampInformation.json. The script will also save AzureStackStampInformation.json in %ProgramData% and in created log folder. AzureStackStampInformation.json in %ProgramData% allows future runs to have ERCS IP information populated at beginning of script.
66
@@ -45,7 +45,7 @@
4545
(Get-TimeZone -Name "US Eastern*").id
4646
"Pacific Standard Time"
4747
.PARAMETER IncompleteDeployment
48-
Specifies if Azure Stack Deployment is incomplete (Only for use in ASDK or DVM)
48+
Specifies if Azure Stack Deployment is incomplete. Only for use in Azure Stack Development Kit deployment or DVM
4949
Yes
5050
No
5151
.EXAMPLE
@@ -151,7 +151,7 @@ else
151151
# ERCS_AzureStackLogs
152152
#
153153
# VERSION:
154-
# 1.6.0
154+
# 1.6.1
155155
#------------------------------------------------------------------------------
156156

157157
"------------------------------------------------------------------------------ " | Write-Host -ForegroundColor Yellow
@@ -171,7 +171,7 @@ else
171171
" ERCS_AzureStackLogs.ps1 " | Write-Host -ForegroundColor Yellow
172172
"" | Write-Host -ForegroundColor Yellow
173173
" VERSION: " | Write-Host -ForegroundColor Yellow
174-
" 1.6.0" | Write-Host -ForegroundColor Yellow
174+
" 1.6.1" | Write-Host -ForegroundColor Yellow
175175
"" | Write-Host -ForegroundColor Yellow
176176
"------------------------------------------------------------------------------ " | Write-Host -ForegroundColor Yellow
177177
"" | Write-Host -ForegroundColor Yellow
@@ -268,14 +268,27 @@ If(!($IP))
268268
{
269269
If ((Test-Path -Path "$($Env:ProgramData)\AzureStackStampInformation.json") -eq $true)
270270
{
271-
Write-Host "`n `t[INFO] Load AzureStackStampInformation.json" -ForegroundColor Green
271+
Write-Host "`n `t[INFO] Loaded AzureStackStampInformation.json from ProgramData" -ForegroundColor Green
272272
$FoundJSONFile = Get-Content -Raw -Path "$($Env:ProgramData)\AzureStackStampInformation.json" | ConvertFrom-Json
273273
[string]$FoundDomainFQDN = $FoundJSONFile.DomainFQDN
274274
[array]$ERCSIPS = $FoundJSONFile.EmergencyConsoleIPAddresses
275275
$StampTimeZone = $FoundJSONFile.Timezone
276276
$FoundSelERCSIP = $FoundJSONFile.EmergencyConsoleIPAddresses | Out-GridView -Title "Please Select Emergency Console IP Address" -PassThru
277277
$IP = $FoundSelERCSIP
278278
}
279+
If ((Test-Path -Path "$($Env:ProgramData)\AzureStackStampInformation.json") -eq $false)
280+
{
281+
if ((Test-Path -Path "$($env:SystemDrive)\CloudDeployment\Logs\AzureStackStampInformation.json") -eq $true)
282+
{
283+
Write-Host "`n `t[INFO] Loaded AzureStackStampInformation.json from CloudDeployment" -ForegroundColor Green
284+
$FoundJSONFile = Get-Content -Raw -Path "$($env:SystemDrive)\CloudDeployment\Logs\AzureStackStampInformation.json" | ConvertFrom-Json
285+
[string]$FoundDomainFQDN = $FoundJSONFile.DomainFQDN
286+
[array]$ERCSIPS = $FoundJSONFile.EmergencyConsoleIPAddresses
287+
$StampTimeZone = $FoundJSONFile.Timezone
288+
$FoundSelERCSIP = $FoundJSONFile.EmergencyConsoleIPAddresses | Out-GridView -Title "Please Select Emergency Console IP Address" -PassThru
289+
$IP = $FoundSelERCSIP
290+
}
291+
}
279292
}
280293

281294
#Sel AzureStackStampInformation
@@ -1324,7 +1337,7 @@ if($IP)
13241337
#
13251338
#buttonselect
13261339
#
1327-
$buttonselect.Location = New-Object -TypeName System.Drawing.Point -ArgumentList @(12,258)
1340+
$buttonselect.Location = New-Object -TypeName System.Drawing.Point -ArgumentList @(12,262)
13281341
$buttonselect.Name = 'buttonselect'
13291342
$buttonselect.Size = New-Object -TypeName System.Drawing.Size -ArgumentList @(121,23)
13301343
$buttonselect.TabIndex = 1
@@ -1334,7 +1347,7 @@ if($IP)
13341347
#
13351348
#buttondefault
13361349
#
1337-
$buttondefault.Location = New-Object -TypeName System.Drawing.Point -ArgumentList @(139,258)
1350+
$buttondefault.Location = New-Object -TypeName System.Drawing.Point -ArgumentList @(139,262)
13381351
$buttondefault.Name = 'buttondefault'
13391352
$buttondefault.Size = New-Object -TypeName System.Drawing.Size -ArgumentList @(133,23)
13401353
$buttondefault.TabIndex = 2
@@ -1407,26 +1420,30 @@ if($IP)
14071420
}
14081421
If($IncompleteDeployment -eq "Yes")
14091422
{
1410-
cd "$($env:SystemDrive)\CloudDeployment\AzureStackDiagnostics"
1411-
1412-
$Folders=@()
1413-
$Folders += Get-ChildItem | Where {$_.attributes -eq 'directory'}
1414-
1415-
foreach ($Folder in $Folders)
1423+
$checkdiag = test-path -Path "$($env:SystemDrive)\CloudDeployment\AzureStackDiagnostics\Microsoft.AzureStack.Diagnostics.DataCollection\Microsoft.AzureStack.Diagnostics.DataCollection.psm1"
1424+
if($checkdiag -eq $true)
1425+
{
1426+
Import-Module "$($env:SystemDrive)\CloudDeployment\AzureStackDiagnostics\Microsoft.AzureStack.Diagnostics.DataCollection\Microsoft.AzureStack.Diagnostics.DataCollection.psm1" -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
1427+
$AzSDig = Get-Module -Name Microsoft.AzureStack.Diagnostics.DataCollection
1428+
}
1429+
if ($AzSDig.Name -eq "Microsoft.AzureStack.Diagnostics.DataCollection")
14161430
{
1417-
if (Get-ChildItem -Name $Folder -include *.psm1)
1418-
{
1419-
Import-Module $Folder\$(Get-ChildItem -Name $Folder -include *.psm1) -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
1420-
}
1431+
$incompletedeploymentdate = Get-Date -format MM-dd-hhmm
1432+
$incompletedeploymentfoldername = "-IncompleteDeployment_AzureStackLogs"
1433+
$incompletedeploymentsharename = $incompletedeploymentdate + $incompletedeploymentfoldername
1434+
If (!(Test-Path "$($Env:SystemDrive)\$($incompletedeploymentsharename)")) {$incompletedeploymentfolder = New-Item -Path "$($Env:SystemDrive)\$($incompletedeploymentsharename)" -ItemType directory}
1435+
Get-AzureStackLogs -OutputPath $incompletedeploymentfolder.FullName -FilterByRole $FilterByRole -FromDate $FromDate -ToDate $ToDate
1436+
}
1437+
Else
1438+
{
1439+
Write-Host "`n[Error] unable to load Microsoft.AzureStack.Diagnostics.DataCollection: $_" -ForegroundColor Red
1440+
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
1441+
exit
14211442
}
1422-
$incompletedeploymentdate = Get-Date -format MM-dd-hhmm
1423-
$incompletedeploymentfoldername = "-IncompleteDeployment_AzureStackLogs"
1424-
$incompletedeploymentsharename = $incompletedeploymentdate + $incompletedeploymentfoldername
1425-
If (!(Test-Path "$($Env:SystemDrive)\$($incompletedeploymentsharename)")) {$incompletedeploymentfolder = New-Item -Path "$($Env:SystemDrive)\$($incompletedeploymentsharename)" -ItemType directory}
1426-
Get-AzureStackLogs -OutputPath $incompletedeploymentfolder.FullName -FilterByRole $FilterByRole -FromDate $FromDate -ToDate $ToDate
14271443
#remotepowershell
1428-
Clear-Host
14291444
$s = New-PSSession -ComputerName $IP -ConfigurationName PrivilegedEndpoint -Credential $mySecureCredentials
1445+
Try
1446+
{
14301447
Write-Host "`n `t[INFO] Getting Azure Stack stamp information" -ForegroundColor Green
14311448
Invoke-Command -Session $s -ScriptBlock {Get-AzureStackStampInformation -WarningAction SilentlyContinue} -OutVariable StampInformation -WarningAction SilentlyContinue | Out-Null
14321449
Invoke-Command -Session $s -ScriptBlock {Get-VirtualDisk -CimSession S-Cluster} -OutVariable ClusterDiskInformation -WarningAction SilentlyContinue | Out-Null
@@ -1437,21 +1454,30 @@ if($IP)
14371454
Write-Host "`n `t[INFO] Saving AzureStackStampInformation to $($Env:SystemDrive)\$($incompletedeploymentsharename)" -ForegroundColor Green
14381455
$StampInformation | ConvertTo-Json | Out-File -FilePath "$($Env:SystemDrive)\$($incompletedeploymentsharename)\AzureStackStampInformation.json" -Force
14391456
$ClusterDiskInformation | Out-File -FilePath "$($Env:SystemDrive)\$($incompletedeploymentsharename)\ClusterVirtualDiskInfo.txt" -Force
1457+
}
1458+
catch
1459+
{
1460+
Write-Host "`n[Error] unable to connect to PEP: $_" -ForegroundColor Red
1461+
}
1462+
#zip files
14401463
try
1441-
{
1442-
Write-Host "`n`t[INFO] Compressing gathered files" -ForegroundColor Green
1443-
$zipdate = $incompletedeploymentdate
1444-
Compress-Archive -Path (Get-ChildItem -Path $Env:SystemDrive\$incompletedeploymentsharename).FullName -CompressionLevel Optimal -DestinationPath "$Env:SystemDrive\$incompletedeploymentsharename\$($zipdate)_AzureStackLogs_archive.zip" -Force
1445-
Write-Host "`tFile created: $Env:SystemDrive\$incompletedeploymentsharename\$($zipdate)_AzureStackLogs_archive.zip" -ForegroundColor White
1446-
Invoke-Item $incompletedeploymentfolder.FullName
1447-
Write-Host "`n `t[INFO] Opening $($incompletedeploymentfolder.FullName)" -ForegroundColor Green
1448-
}
1449-
catch
1450-
{
1451-
Write-Host "`n`t`t[WARN] Did not create a archive" -ForegroundColor Yellow
1452-
}
1453-
Write-Host "`n `tPress any key to continue ...`n"
1454-
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
1464+
{
1465+
Write-Host "`n`t[INFO] Compressing gathered files" -ForegroundColor Green
1466+
$zipdate = $incompletedeploymentdate
1467+
if((Test-Path -Path $Env:SystemDrive\CloudDeployment\Logs) -eq $true)
1468+
{Compress-Archive -Path (Get-ChildItem -Path $Env:SystemDrive\CloudDeployment\Logs).FullName -CompressionLevel Optimal -DestinationPath "$Env:SystemDrive\$incompletedeploymentsharename\$($zipdate)_CloudDeploymentLogs_archive.zip" -Force}
1469+
if((Test-Path -Path $Env:SystemDrive\MASLogs) -eq $true)
1470+
{Compress-Archive -Path (Get-ChildItem -Path $Env:SystemDrive\MASLogs).FullName -CompressionLevel Optimal -DestinationPath "$Env:SystemDrive\$incompletedeploymentsharename\$($zipdate)_MASLogs_archive.zip" -Force}
1471+
Compress-Archive -Path (Get-ChildItem -Path $Env:SystemDrive\$incompletedeploymentsharename).FullName -CompressionLevel Optimal -DestinationPath "$Env:SystemDrive\$incompletedeploymentsharename\$($zipdate)_AzureStackLogs_archive.zip" -Force
1472+
Write-Host "`tFile created: $Env:SystemDrive\$incompletedeploymentsharename\$($zipdate)_AzureStackLogs_archive.zip" -ForegroundColor White
1473+
Invoke-Item $incompletedeploymentfolder.FullName
1474+
Write-Host "`n `t[INFO] Opening $($incompletedeploymentfolder.FullName)" -ForegroundColor Green
1475+
}
1476+
catch
1477+
{
1478+
Write-Host "`n`t`t[WARN] Did not create a archive" -ForegroundColor Yellow
1479+
}
1480+
#cleanup
14551481
exit
14561482
}
14571483
#setting remotepowershell options
@@ -1642,7 +1668,7 @@ if($IP)
16421668
{
16431669
Write-Host "`n`t[INFO] Compressing gathered files" -ForegroundColor Green
16441670
$zipdate = $date
1645-
Compress-Archive -Path (Get-ChildItem -Path $Env:SystemDrive\$sharename).FullName -CompressionLevel Optimal -DestinationPath "$Env:SystemDrive\$sharename\$($zipdate)_AzureStackLogs_archive.zip" -Force
1671+
Compress-Archive -Path (Get-ChildItem -Exclude Transcripts_* -Path $Env:SystemDrive\$sharename).FullName -CompressionLevel Optimal -DestinationPath "$Env:SystemDrive\$sharename\$($zipdate)_AzureStackLogs_archive.zip" -Force
16461672
Write-Host "`tFile created: $Env:SystemDrive\$sharename\$($zipdate)_AzureStackLogs_archive.zip" -ForegroundColor White
16471673
Invoke-Item $Files.Parent.FullName
16481674
Write-Host "`n `t[INFO] Opening $($Files.Parent.FullName)" -ForegroundColor Green
@@ -1683,4 +1709,4 @@ else
16831709
Write-Host "`n Press any key to continue ...`n"
16841710
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
16851711
exit
1686-
}
1712+
}

Support/ERCS_Logs/ReadMe.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# ​ERCS_AzureStackLogs​.ps1 #
22

3-
![](https://github.com/effingerw/AzureStack-Tools/blob/vnext/Support/ERCS_Logs/Media/ERCS.gif?raw=true)
3+
![](https://github.com/Azure/AzureStack-Tools/blob/vnext/Support/ERCS_Logs/Media/ERCS.gif?raw=true)
44

5-
Built to be run on the HLH or DVM from an administrative powershell session the script uses seven methods to find the privileged endpoint virtual machines. The script connects to selected privileged endpoint and runs Get-AzureStackLog with supplied parameters. If no parameters are supplied the script will default to prompting user via GUI for needed parameters.
5+
Built to be run on the HLH, DVM, or Jumpbox from an administrative powershell session the script uses seven methods to find the privileged endpoint virtual machines. The script connects to selected privileged endpoint and runs Get-AzureStackLog with supplied parameters. If no parameters are supplied the script will default to prompting user via GUI for needed parameters.
66

77

88
The script will use one of the below seven methods; Gather requested logs, Transcript, and AzureStackStampInformation.json. The script will also save AzureStackStampInformation.json in %ProgramData% and in created log folder. AzureStackStampInformation.json in %ProgramData% allows future runs to have ERCS IP information populated at beginning of script.

0 commit comments

Comments
 (0)