-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathLogCollector.ps1
More file actions
531 lines (480 loc) · 24.7 KB
/
LogCollector.ps1
File metadata and controls
531 lines (480 loc) · 24.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
<#
.Synopsis
Invoke-LogCollector
.DESCRIPTION
This tool is used to collect logs from nodes or all nodes in a cluster and bring them back to a single location
.EXAMPLE
Invoke-GetLogs
#>
Function Invoke-LogCollector{
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = 'High')]
param($param)
# Version
$Ver="1.86"
#region Telemetry Information
Write-Host "Logging Telemetry Information..."
Function EndScript{
break
}
Function Upload-FileToCase{
param (
[string]$FilePath = '',
[string]$ServiceTag = '',
[string]$CaseNumber = '',
[string]$PreferredName = '',
[string]$Email = ''
)
$dfilename=Split-Path -Leaf $FilePath
If (!($Global:CaseSrId)) {$Global:CaseSrId= (Invoke-RestMethod -Uri "https://tdm.dell.com/tdm-file-upload/public/v2/cases-by-generic-id/$CaseNumber").cases.id}
$body = @{"customerEmail"="$Email";"fileName"="$dfilename";"fileSize"="20";"lightningCaseId"="$($Global:CaseSrId)";"preferredName"="$PreferredName";"serviceRequestNb"="$CaseNumber"} | ConvertTo-Json
$header = @{
"Accept"="application/json"
"Content-Type"="application/json"
}
$StartUpload=Invoke-RestMethod -Headers $header -Body $body -Uri "https://tdm.dell.com/tdm-file-upload/public/v2/initiate-upload" -Method Post -SessionVariable session
# Define the input file and chunk size
$tempdir=$env:TEMP+"\"+(New-Guid)
New-Item -Path $tempdir -ItemType Directory | Out-Null
$chunkSize = 20000000
$bufferSize = 8192 # Size of the buffer to read/write data
$outputStream=$null
Write-Host "Preparing file for upload"
# Open the input file in binary mode
$inputStream = [System.IO.File]::OpenRead($FilePath)
try {
$chunkIndex = 1
Do {
$chunkFile = Join-Path $tempdir "$(Split-Path -Leaf ($FilePath.substring(0,$FilePath.length-4)))-$chunkIndex"
$totalBytesRead = 0
$buffer = New-Object byte[] $bufferSize
Do {
$bytesRead = $inputStream.Read($buffer, 0, [Math]::Min($bufferSize, $chunkSize - $totalBytesRead))
if ($bytesRead -ne 0) {
if (!($outputStream)) { $outputStream = [System.IO.File]::OpenWrite($chunkFile)}
$outputStream.Write($buffer, 0, $bytesRead)
$totalBytesRead += $bytesRead
}
} while ($totalBytesRead -lt $chunkSize -and $bytesRead -gt 0)
$outputStream.Close()
$outputStream = $null
$chunkIndex++
} while ($totalBytesRead -ge $chunkSize)
}
finally {$inputStream.Close()}
$percChunk=100/($chunkIndex-1)
Add-Type -AssemblyName 'System.Net.Http'
$httpClient = New-Object System.Net.Http.Httpclient
Write-Host -NoNewLine "Uploading file."
Foreach ($chunkFile in (gci $tempdir -File | Sort LastWriteTime)) {
try {$packageFileStream.close()} catch {}
$packageFileStream = New-Object System.IO.FileStream @($chunkFile.FullName, [System.IO.FileMode]::Open)
[int]$chunkNumber=$chunkFile.Name.Substring($chunkFile.Name.LastIndexOf("-")).substring(1)
$contentDispositionHeaderValue = New-Object System.Net.Http.Headers.ContentDispositionHeaderValue "form-data"
$contentDispositionHeaderValue.Name = "file"
$contentDispositionHeaderValue.FileName = ("blob")
$streamContent = New-Object System.Net.Http.StreamContent $packageFileStream
$streamContent.Headers.ContentDisposition = $contentDispositionHeaderValue
try {$streamContent.Headers.ContentType = New-Object System.Net.Http.Headers.MediaTypeHeaderValue $ContentType} catch {}
$content = New-Object System.Net.Http.MultipartFormDataContent
$content.add((New-Object System.Net.Http.StringContent $email),'customerEmail')
$content.add((New-Object System.Net.Http.StringContent $StartUpload.fileId),'fileId')
$content.add((New-Object System.Net.Http.StringContent $StartUpload.uploadId),'uploadId')
$content.add((New-Object System.Net.Http.StringContent "$chunkNumber"),'chunkNumber')
$content.Add($streamContent)
$httpClient = New-Object System.Net.Http.Httpclient
$response=$httpClient.PostAsync("https://tdm.dell.com/tdm-file-upload/public/v2/upload-chunk", $content).Result
if ($response.StatusCode -ne "204") {Write-Warning "Chunk $chunkNumber upload failed!!";$response;$packageFileStream.close();return 1}
$packageFileStream.close()
Write-Host -NoNewLine "$([int]($chunkNumber*$percChunk))%."
$chunkNumber++
}
Write-Host "."
$body=@{customerEmail="$email";fileId=$($StartUpload.fileId);uploadId=$($StartUpload.uploadId)} | ConvertTo-Json
$response=Invoke-RestMethod -Uri "https://tdm.dell.com/tdm-file-upload/public/v2/upload-complete" -Body $body -Headers @{"Accept"="application/json, text/plain, */*";"Accept-Encoding"="gzip, deflate, br, zstd";"Accept-Language"="en-US,en;q=0.9"} -Method Post -WebSession $session #?uploadId=$($StartUpload.uploadId)&fileId=$($StartUpload.fileId)&chunkNumber=1&customerEmail=$email
$body=@{emailId="$email";fileId=$($StartUpload.fileId);serviceTag=$Stag;language="en_US"} | ConvertTo-Json
$response=Invoke-RestMethod -Uri "https://tdm.dell.com/tdm-file-upload/public/v2/file-status"-Body $body -Headers @{"Accept"="application/json, text/plain, */*";"Accept-Encoding"="gzip, deflate, br, zstd";"Accept-Language"="en-US,en;q=0.9"} -Method Post -WebSession $session
If ($response.uploadCompleted -eq $true) {
Write-Host "Upload Completed..."
Remove-Item $tempdir -Force -Recurse
return 0
} else {
Write-Warning "Upload Failed!!!"
return 1
}
}
Clear-Host
# Logs
$DateTime=Get-Date -Format yyyyMMdd_HHmmss
Start-Transcript -NoClobber -Path "C:\programdata\Dell\LogCollector\LogCollector_$DateTime.log"
# Clean up
IF(Test-Path -Path "$((Get-Item $env:temp).fullname)\logs"){ Remove-Item "$((Get-Item $env:temp).fullname)\logs" -Recurse -Confirm:$false -Force}
try {Start-Job -Name "Telemetry" -ScriptBlock {
} | Out-Null} catch {}
$text = @"
v$Ver
_ ___ _ _ _
| | ___ __ _ / __|___| | |___ __| |_ ___ _ _
| |__/ _ \/ _' | | (__/ _ \ | / -_) _| _/ _ \ '_|
|____\___/\__, | \___\___/_|_\___\__|\__\___/_|
|___/
"@
Write-Host $text
Write-Host ""
#region Telemetry Information
# =====================================================
$uploadToAzure=$True
IF($uploadToAzure){
Write-Host "Logging Telemetry Information..."
function Add-TableData {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]$TableName,
[Parameter(Mandatory=$true)]
[string]$PartitionKey,
[Parameter(Mandatory=$true)]
[hashtable]$Data
)
if (-not $uploadToAzure) { return }
$RowKey = [guid]::NewGuid().Guid
$TableSvcSasUrl = 'https://gsetools.table.core.windows.net/?sv=2024-11-04&ss=t&srt=so&sp=a&se=2028-03-11T21:32:20Z&st=2026-03-11T12:17:20Z&spr=https&sig=zYIhaiCnIiphMZLI38Uj6AcJ1WLJOKe4KRMl4WzX818%3D'
$uri = "https://gsetools.table.core.windows.net/$TableName$($TableSvcSasUrl.Substring($TableSvcSasUrl.IndexOf('?')))"
$headers = @{
"Accept" = "application/json;odata=nometadata"
"Content-Type" = "application/json"
"x-ms-version" = "2019-02-02"
}
$Data["PartitionKey"] = $PartitionKey
$Data["RowKey"] = $RowKey
$body = $Data | ConvertTo-Json -Depth 5
$maxRetries = 3
$attempt = 0
$success = $false
while (-not $success -and $attempt -lt $maxRetries) {
try {
Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -Body $body | Out-Null
$success = $true
Write-Indent "Telemetry recorded successfully" 1 Green
}
catch {
$attempt++
if ($attempt -lt $maxRetries) {
Write-Indent "Retrying telemetry upload ($attempt/$maxRetries)..." 1 Yellow
Start-Sleep -Seconds 2
}
else {
Write-Indent "Telemetry upload failed after $maxRetries attempts" 1 Yellow
}
}
}
}
function Write-Indent {
param(
[string]$Message,
[int]$Level = 1,
[string]$Color = "Gray"
)
$prefix = " " * $Level
Write-Host "$prefix$Message" -ForegroundColor $Color
}
# Unique report id
$CReportID = [guid]::NewGuid().Guid
Write-Indent "Resolving Geo Location..."
try {
if (-not $global:GeoCache) {
$global:GeoCache = Invoke-RestMethod "https://ipwho.is/" -TimeoutSec 5
}
$response = $global:GeoCache
if ($response.success -eq $true) {
$country = $response.country
$countryCode = $response.country_code
$region = $response.region
$city = $response.city
$latitude = $response.latitude
$longitude = $response.longitude
$timezone = $response.timezone.id
Write-Indent "Country: $country" 2
Write-Indent "Region : $region" 2
}
}
catch {
Write-Indent "WARN: ipwho lookup failed" 2 Yellow
}
$data = @{
Region = $region
Version = $Ver
ReportID = $CReportID
country = $country
countryCode = $countryCode
geoRegion = $region
city = $city
lat = $latitude
lon = $longitude
timezone = $timezone
Timestamp = (Get-Date).ToUniversalTime().ToString("o")
HostOS = [System.Environment]::OSVersion.VersionString
PSVersion = $PSVersionTable.PSVersion.ToString()
}
# We use tool name for this value
$PartitionKey = "LogCollector"
Add-TableData `
-TableName "LogCollectorTelemetryData" `
-PartitionKey $PartitionKey `
-Data $data
}
#endregion
Write-Host "To assist with troubleshooting, this tool will collect environment"
Write-Host "information (such as hostnames, IP addresses, and diagnostic logs)"
Write-Host "and attach it to your support case."
Write-Host ""
Write-Host "This data helps support engineers diagnose issues faster."
Write-Host ""
# =====================================================
Write-Host "Do you allow this information to be collected and attached?"
$consent = (Read-Host "(Y/[N]) ").ToUpper()
if ($consent -eq "Y") {
# Collect data to improve customer experience
Write-Host "Thank you for participating in our program. Your input is valuable to us!"
$x=0
$Email=$null
Do {
try {$Email = [mailaddress] (Read-Host -Prompt "`r`nPlease enter your email address")} catch {Write-Warning "Email address invalid. Please correct"}
$x++
} while ($x -lt 4 -and !($Email))
If ($x -eq 4) {
Write-Host " ERROR: Too many tries. Exiting..." -ForegroundColor Red
EndScript
}
} else {
$consent = "N"
# Do not collect data
Write-Host "We respect your decision. Your privacy is important to us."
Write-Host "Logs will be only stored locally."
}
#only collect personal data when $consent eq 'Y'
Write-Host ""
$MyTemp=(Get-Item $env:temp).fullname
$Global:CaseNumber =$null
$Global:CaseSrId=$null
$x=0
Do {
If ($consent -eq "Y") {
try {$Global:CaseNumber = [long] (Read-Host -Prompt "Please enter the relevant technical support case number")} catch {}
$x++
try {$Global:CaseSrId= (Invoke-RestMethod -ErrorAction SilentlyContinue -Uri "https://tdm.dell.com/tdm-file-upload/public/v2/cases-by-generic-id/$($Global:CaseNumber)").cases.id} catch {}
If (!($Global:CaseSrId)) {Write-Host "Invalid Case Number. Please try again" -ForegroundColor Yellow}
} else {If (!($Global:CaseNumber)) {$Global:CaseNumber="99999999999"}}
} while ($x -lt 4 -and !($Global:CaseSrId) -and $consent -eq "Y")
If ($x -eq 4) {
Write-Host " ERROR: Too many tries. Exiting..." -ForegroundColor Red
EndScript
}
# Run Menu
Function ShowMenu{
do
{
$selection=""
Clear-Host
Write-Host $text
Write-Host ""
Write-Host "============ Please make a selection ==================="
Write-Host ""
Write-Host "0) APEX Logs (ACP/ECE)"
Write-Host "1) Azure Local/HCI/S2D logs (SDDC)"
Write-Host "2) PowerEdge logs (TSR)"
Write-Host "3) Switch logs (Show Tech)"
Write-Host "4) Windows Failover Clustering, Hyper-v and Standalone Server (TSS)"
Write-Host "Q to Quit"
Write-Host ""
$selection = Read-Host "Type a number(s) and press [Enter]"
}
until ($selection -match '[0-4,qQ,hH]')
$Global:CollectACPECE = "N"
$Global:CollectSTS = "N"
$Global:CollectSDDC = "N"
$Global:CollectTSR = "N"
$Global:CollectTSS = "N"
IF($selection -imatch 'h'){
Clear-Host
Write-Host ""
Write-Host "What's New in"$Ver":"
Write-Host $WhatsNew
Write-Host ""
Write-Host "Useage:"
Write-Host " Make a select by entering a comma delimited string of numbers from the menu."
Write-Host ""
Write-Host " Example: 1 will Collect Show Tech-Support(s) only and create a report."
Write-Host " Show Tech-Support is a log collection from a Dell switch."
Write-Host ""
Write-Host " Example: 1,3 will Collect Show Tech-Support(s) and "
Write-Host " PrivateCloud.DiagnosticInfo (SDDC) and create a report."
Write-Host ""
Pause
ShowMenu
}
IF($selection -match 0){
Write-Host "Gathering APEX Logs (ACP/ECE)..."
$Global:CollectACPECE = "Y"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;Invoke-Expression('$module="RunAcpLogCollector";$repo="PowershellScripts";'+(new-object System.net.webclient).DownloadString('https://raw.githubusercontent.com/DellProSupportGse/Tools/main/run_acp_log_collect.ps1'))
$ACPLogPath = Invoke-RunAPEXlogsCollector -confirm:$False
}
IF($selection -match 3){
Write-Host "Gathering Switch logs (Show Tech)..."
$Global:CollectSTS = "Y"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;Invoke-Expression('$module="GetShowTech";$repo="PowershellScripts"'+(new-object System.net.webclient).DownloadString('https://raw.githubusercontent.com/DellProSupportGse/Tools/main/GetShowTech.ps1'))
Invoke-GetShowTech -confirm:$False -CaseNumber $Casenumber
}
IF($selection -match 2){
Write-Host "Collecting PowerEdge logs (TSR)..."
$Global:CollectTSR = "Y"
If(Get-Service clussvc -ErrorAction SilentlyContinue){
#$credential=Get-Credential -Message "Please enter the iDRAC Adminitrator credentials"
Do {
$credential=Get-Credential -Message "Please enter the iDRAC Administrator credentials" -UserName root;$cred2=Get-Credential -Message "Confirm iDRAC Password" -UserName $credential.GetNetworkCredential().UserName
} while (($credential.GetNetworkCredential().Password -ne $cred2.GetNetworkCredential().Password) -or ($credential.GetNetworkCredential().UserName -ne $cred2.GetNetworkCredential().UserName))
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;Invoke-Expression('$module="TSRCollector";$repo="PowershellScripts"'+(new-object net.webclient).DownloadString('https://raw.githubusercontent.com/DellProSupportGse/Tools/main/TSRCollector.ps1'))
$iDRACIPs = @(Invoke-TSRCollector -confirm:$False -CaseNumber $CaseNumber -credential $credential)
}
}
IF($selection -match 1){
if ($PSSenderInfo) {Write-Host -ForegroundColor Yellow "This module is not supported using a remote powershell session. Please run locally";EndScript}
If ((invoke-command -scriptblock {try {get-cluster -ErrorAction SilentlyContinue} catch {}}).Name -eq $null) {Write-Host -ForegroundColor DarkYellow "This module MUST be run locally on a cluster node. Waiting 10 seconds.";sleep 10}
Write-Host "Collecting Azure Local/HCI/S2D logs (SDDC)..."
$Global:CollectSDDC = "Y"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;Invoke-Expression('$module="SDDC";$repo="PowershellScripts"'+(new-object net.webclient).DownloadString('https://raw.githubusercontent.com/DellProSupportGse/Tools/main/RunSDDC.ps1'))
Invoke-RunSDDC -confirm:$False -CaseNumber $CaseNumber
}
IF($selection -match 4){
if ($PSSenderInfo) {Write-Host -ForegroundColor Yellow "This module is not supported using a remote powershell session. Please run locally";EndScript}
Write-Host "Collecting Windows Server (TSS)..."
$Global:CollectTSS = "Y"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;Invoke-Expression('$module="TSSCollect"; $repo="PowershellScripts"'+(new-object net.webclient).DownloadString('https://raw.githubusercontent.com/fginacio/MS/main/TSSCollect.ps1'))
Invoke-TSSCollect -confirm:$False -CaseNumber $CaseNumber
}
IF($Global:CollectTSR -eq "Y") {
$i=0
#Write-Host "iDrac IPs $iDRACIPs and count is $($iDRACIPs.count)"
if (($iDRACIPs -match ".").count) {
New-Item "$MyTemp\logs\TSRCollector" -ItemType "directory" -ErrorAction SilentlyContinue | Out-Null
do {
$idracCount=$iDRACIPs.count
foreach ($idrac_ip in $iDRACIPs) {
if (!($idrac_ip -match "!|#")) {
$uri = "https://$idrac_ip/redfish/v1/Systems/System.Embedded.1"
$result = Invoke-WebRequest -Uri $uri -Credential $credential -Method Get -UseBasicParsing -ErrorVariable RespErr -Headers @{"Accept"="application/json"}
$servicetag = ($result.Content | ConvertFrom-Json).Oem.Dell.DellSystem.ChassisServiceTag
if (!(test-path "$MyTemp\logs\TSRCollector\TSR*_$($servicetag).zip")) {
try {$result=Invoke-WebRequest -UseBasicParsing -Uri "https://$idrac_ip/redfish/v1/Dell/sacollect.zip" -Credential $credential -Method GET -OutFile "$MyTemp\logs\TSRCollector\TSR$(get-date -Format "yyyyMMddHHmmss")_$($servicetag).zip" -ErrorAction SilentlyContinue -ErrorVariable RespErr} catch {}
}
} else {$idracCount--}
}
$TSRsCollected = (Get-ChildItem -Path $MyTemp\logs -Filter "TSR??????????????_*.zip" -Recurse)
$totalTSRsCollected = $TSRsCollected.Count
$i++
Write-Host "$totalTSRsCollected / $($idracCount) TSR's collected so far, and waited $i / 20 minutes"
if ($totalTSRsCollected -lt $idracCount) {Sleep -Seconds 60}
}
while ($totalTSRsCollected -lt $idracCount -and $i -le 20)
Get-ChildItem -Path $MyTemp\logs -Filter "TSR??????????????_*.zip" -Recurse | Compress-Archive -DestinationPath "$MyTemp\logs\TSRReports_$(get-date -Format "yyyyMMdd-HHmm")_$($CaseNumber)"
foreach ($idrac_ip in $iDRACIPs) {if (($idrac_ip -match "!|#")) {Write-Host "ERROR: Failed to capture TSR from $idrac_ip" -ForegroundColor Red}}
}
}
IF($selection -imatch 'q'){
Write-Host "Bye Bye..."
EndScript
}
IF($consent -eq "Y") {UploadLogs}
}#End of ShowMenu
Function ZipNClean{
# Zip up
Write-Host "Compressing Logs..."
$MyTemp=(Get-Item $env:temp).fullname
$DT=Get-Date -Format "yyyyMMddHHmm"
IF(Test-Path -Path "$MyTemp\logs"){
Compress-Archive -Path "$MyTemp\logs\*.*" -DestinationPath "c:\dell\LogCollector_$($DT).zip"
Sleep 60
IF(Test-Path -Path "c:\dell\LogCollector_$($DT).zip"){
Write-Host "Logs can be found here: C:Dell\LogCollector_$($DT).zip"
# Clean up
Write-Host "Clean up..."
Remove-Item "$MyTemp\logs" -Recurse -Confirm:$false -Force
cd c:\dell
Invoke-Expression "explorer ."
}Else{
Write-Host "ERROR: Failed to compress $MyTemp\logs." -ForegroundColor Red
cd "$MyTemp\logs"
Invoke-Expression "explorer ."
}
}
}
Function UploadLogs {
$MyTemp=(Get-Item $env:temp).fullname
Write-Host "Uploading files. Please wait...."
# Upload ACPECE logs
IF($ACPLogPath){
$s=Upload-FileToCase -FilePath $ACPLogPath -CaseNumber $CaseNumber -Email $email.Address -PreferredName $email.User -ServiceTag "$(Get-WmiObject Win32_BIOS | Select-Object -ExpandProperty SerialNumber)"
if ($s -eq 0) {Write-Host "ACP/ECE logs uploaded to case $CaseNumber"}
else {Write-Warning "ACP/ECE logs upload FAILED!!. Please upload using https://tdm.dell.com/file-upload"}
}
#Upload SDDC
IF(Test-Path -Path "$MyTemp\logs\Healthtest*$CaseNumber*"){
$HealthZip = Get-ChildItem $MyTemp\logs\Healthtest*$CaseNumber* | sort lastwritetime | select -last 1
$s=Upload-FileToCase -FilePath $HealthZip.Fullname -CaseNumber $CaseNumber -Email $email.Address -PreferredName $email.User -ServiceTag "$(Get-WmiObject Win32_BIOS | Select-Object -ExpandProperty SerialNumber)"
#Get the File-Name without path
#$name = (Get-Item $HealthZip).Name
#The target URL wit SAS Token
#$uri = "https://gsetools.blob.core.windows.net/sddcdata/$($name)?sp=acw&st=2022-06-28T17:26:35Z&se=2032-06-29T01:26:35Z&spr=https&sv=2021-06-08&sr=c&sig=4gtvKkicwS%2BcD6BSBgapTziNrfar11CL%2B6hsVHWzJXI%3D"
#Define required Headers
#$headers = @{
# 'x-ms-blob-type' = 'BlockBlob'
# }
#Upload File...
#$resp=Invoke-RestMethod -Uri "$uri" -Method Put -Headers $headers -InFile $HealthZip -ErrorAction Continue -Verbose 4>&1
if ($s -eq 0) {Write-Host "SDDC uploaded to case $CaseNumber"}
else {Write-Warning "SDDC upload FAILED!!. Please upload using https://tdm.dell.com/file-upload"}
}
#Upload ShowTech
IF(Test-Path -Path "$MyTemp\logs\ShowTechs_$CaseNumber*"){
$ZipPath=Get-ChildItem $MyTemp\logs\ShowTechs_$CaseNumber* | sort lastwritetime | select -Last 1
Expand-Archive -Path $ZipPath.Fullname -DestinationPath ($env:temp+"\$($ZipPath.BaseName)")
$content= Get-Content (Get-ChildItem ($env:temp + "\$($ZipPath.BaseName)") -File | Select -First 1).Fullname
Remove-Item ($env:temp + "\$($ZipPath.BaseName)") -Recurse -Force
$parsed=($content | Select-String -context 0,2 -SimpleMatch "Svc Tag").ToString()
$servicetag=(($parsed.split("`r")[2]) -split " ")[-2]
$s=Upload-FileToCase -FilePath $ZipPath.Fullname -CaseNumber $CaseNumber -Email $email.Address -PreferredName $email.User -ServiceTag $servicetag
#Get the File-Name without path
#$name = (Get-Item $ZipPath).Name
#The target URL wit SAS Token
#$uri = "https://gsetools.blob.core.windows.net/showtech/$($name)?sp=acw&st=2022-08-14T20:19:23Z&se=2032-08-15T04:19:23Z&spr=https&sv=2021-06-08&sr=c&sig=XfWDMd2y4sQrXm1gxA6up6VRGV5XPrwPkxEINpKTKCs%3D"
#Define required Headers
#$headers = @{
# 'x-ms-blob-type' = 'BlockBlob'
# }
#Upload File...
#$resp2=Invoke-RestMethod -Uri $uri -Method Put -Headers $headers -InFile $ZipPath -ErrorAction Continue -Verbose 4>&1
if ($s -eq 0) {Write-Host "Showtech uploaded to case $CaseNumber"}
else {Write-Warning "Showtech upload FAILED!!. Please upload using https://tdm.dell.com/file-upload"}
}
#Upload TSS
IF((Get-ChildItem -Path "C:\Dell\Logs" -Filter "$($CaseNumber).zip" -Recurse).count){
$ZipPath=Get-ChildItem -Path "C:\Dell\Logs" -Filter "$($CaseNumber).zip" -Recurse | sort lastwritetime | select -last 1
$ZipPath=Rename-Item $ZipPath.FullName "TSS-$($ZipPath.Name)" -PassThru
#Upload File...
$s=Upload-FileToCase -FilePath $ZipPath.Fullname -CaseNumber $CaseNumber -Email $email.Address -PreferredName $email.User -ServiceTag "$(Get-WmiObject Win32_BIOS | Select-Object -ExpandProperty SerialNumber)"
if ($s -eq 0) {Write-Host "TSS uploaded on case $CaseNumber"}
else {Write-Warning "TSS upload FAILED!!. Please upload using https://tdm.dell.com/file-upload"}
}
#Upload TSR
IF((Get-ChildItem -Path $MyTemp\logs -Filter TSRReports_*$CaseNumber* -Recurse).count){
$ZipPath=Get-ChildItem -Path $MyTemp\logs -Filter TSRReports_*$CaseNumber* -Recurse | sort lastwritetime | select -last 1
#Upload File...
$s=Upload-FileToCase -FilePath $ZipPath.Fullname -CaseNumber $CaseNumber -Email $email.Address -PreferredName $email.User -ServiceTag $servicetag
if ($s -eq 0) {Write-Host "TSRs uploaded on case $CaseNumber"}
else {Write-Warning "TSRs upload FAILED!!. Please upload using https://tdm.dell.com/file-upload"}
}
}
ShowMenu
Stop-Transcript
}# End invoke-LogCollector