-
Notifications
You must be signed in to change notification settings - Fork 3
/
asoc.ps1
713 lines (572 loc) · 19.1 KB
/
asoc.ps1
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
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
# Copyright 2023, 2024 HCL America
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
$Os = 'linux'
if($IsMacOS){
$Os = 'mac'
}elseif($IsWindows){
$Os = 'win'
}
$ClientType = "github-dast-$Os-$env:GITHUB_ACTION_REF"
Write-Host "Loading Library functions from asoc.ps1"
#FUNCTIONS
function Login-ASoC {
$jsonBody = @{
KeyId = $env:INPUT_ASOC_KEY
KeySecret = $env:INPUT_ASOC_SECRET
}
$params = @{
Uri = "$global:BaseAPIUrl/Account/ApiKeyLogin"
Method = 'POST'
Body = $jsonBody | ConvertTo-Json
Headers = @{
'Content-Type' = 'application/json'
'accept' = 'application/json'
'ClientType' = "$ClientType"
}
}
#DEBUG
Write-Debug ($jsonBody | Format-Table | Out-String)
Write-Debug ($params | Format-Table | Out-String)
$Members = Invoke-RestMethod @params
Write-Debug ($Members | Format-Table | Out-String)
#Write-Host "Auth successful - Token received: $Members.token"
$global:BearerToken = $Members.token
if($global:BearerToken -ne ""){
Write-Host "Login successful"
}else{
Write-Error "Login failed... exiting"
exit 1
}
}
function Set-AppScanPresence{
if($env:INPUT_NETWORK -eq 'private'){
$global:jsonBodyInPSObject.Add("PresenceId",$env:INPUT_PRESENCE_ID)
<#
$global:jsonBodyInPSObject =+ @{
PresenceId = $env:INPUT_PRESENCE_ID
} #>
}
}
function Lookup-ASoC-Application ($ApplicationName) {
$params = @{
Uri = "$env:INPUT_BASEURL/Apps"
Method = 'GET'
Headers = @{
'Content-Type' = 'application/json'
Authorization = "Bearer $global:BearerToken"
}
}
$Members = Invoke-RestMethod @params
Write-Host @Members
$Members.Items.Contains($ApplicationName)
}
function Run-ASoC-FileUpload($filepath){
#ls -l
$uploadedFile = [IO.File]::ReadAllBytes($filepath)
$params = @{
Uri = "$global:BaseAPIUrl/FileUpload"
Method = 'Post'
Headers = @{
'Content-Type' = 'multipart/form-data'
Authorization = "Bearer $global:BearerToken"
}
Form = @{
'uploadedFile' = Get-Item -Path $filepath
}
}
$upload = Invoke-RestMethod @params
$upload_File_ID = $upload.FileId
write-host "File Uploaded - File ID: $upload_File_ID"
return $upload_File_ID
}
function Run-ASoC-DynamicAnalyzerNoAuth {
Write-Host "Proceeding with no authentications..." -ForegroundColor Green
return Run-ASoC-DynamicAnalyzerAPI($global:jsonBodyInPSObject | ConvertTo-Json)
}
function Run-ASoC-DynamicAnalyzerUserPass{
Write-Host "Proceeding with username and password login..." -ForegroundColor Green
$Login = @{
'Username' = $env:INPUT_LOGIN_USER
'Password' = $env:INPUT_LOGIN_PASSWORD
}
$global:jsonBodyInPSObject.ScanConfiguration.Add('Login', $Login)
return Run-ASoC-DynamicAnalyzerAPI($jsonBodyInPSObject | ConvertTo-Json)
}
function Run-ASoC-DynamicAnalyzerRecordedLogin{
Write-Host "Proceeding with recorded Login..." -ForegroundColor Green
#Upload Recorded Login File
$FileID = Run-ASoC-FileUpload($env:INPUT_LOGIN_SEQUENCE_FILE)
$global:jsonBodyInPSObject.Add("LoginSequenceFileId",$FileID)
return Run-ASoC-DynamicAnalyzerAPI($jsonBodyInPSObject | ConvertTo-Json)
}
function Run-ASoC-DynamicAnalyzerWithFile{
$FileID = Run-ASoC-FileUpload($env:INPUT_SCAN_OR_SCANT_FILE)
$global:jsonBodyInPSObject.Remove('ScanConfiguration')
$global:jsonBodyInPSObject.Add("ScanOrTemplateFileId",$FileID)
return Run-ASoC-DynamicAnalyzerAPI($jsonBodyInPSObject | ConvertTo-Json)
}
function Run-ASoC-DynamicAnalyzerAPI($json){
write-host $json
$params = @{
Uri = "$global:BaseAPIUrl/Scans/Dast"
Method = 'POST'
Body = $json
Headers = @{
'Content-Type' = 'application/json'
'ClientType' = "$ClientType"
Authorization = "Bearer $global:BearerToken"
}
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
$Members = Invoke-RestMethod @params
return $Members.Id
}
function Run-ASoC-DAST{
#FIRST check if dynamic_scan_type is 'upload' or 'dast'
if($env:INPUT_DYNAMIC_SCAN_TYPE -eq 'upload'){
return Run-ASoC-DynamicAnalyzerWithFile
#If dynamic_scan_type is not 'upload' then it is a regular 'dast' scan. We proceed to check if it's a userpass login or recorded login
}elseif($env:INPUT_LOGIN_METHOD -eq 'userpass'){
return Run-ASoC-DynamicAnalyzerUserPass
}elseif($env:INPUT_LOGIN_METHOD -eq 'recorded'){
return Run-ASoC-DynamicAnalyzerRecordedLogin
}else{
return Run-ASoC-DynamicAnalyzerNoAuth
}
}
function Run-ASoC-ScanCompletionChecker($scanID){
$params = @{
Uri = "$global:BaseAPIUrl/Scans/$scanID/Executions"
Method = 'GET'
Headers = @{
'Content-Type' = 'application/json'
Authorization = "Bearer $global:BearerToken"
}
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
$counterTimerInSeconds = 0
Write-Host "Waiting for Scan Completion..." -NoNewLine
$waitIntervalInSeconds = 15
while(($scan_status -ne "Ready") -and ($counterTimerInSeconds -lt $env:INPUT_WAIT_FOR_ANALYSIS_TIMEOUT_MINUTES*60)){
$output = Invoke-RestMethod @params
$scan_status = $output.Status
Start-Sleep -Seconds $waitIntervalInSeconds
$counterTimerInSeconds = $counterTimerInSeconds + $waitIntervalInSeconds
Write-Host "." -NoNewline
if($scan_status -eq 'Failed'){
$error_message = $output.UserMessage
$scanOverviewPage = $env:INPUT_BASEURL + "/main/myapps/" + $env:INPUT_APPLICATION_ID + "/scans/" + $global:scanId
Write-Error "Scan status: $scan_status. Scan UserMessage: $error_message. For More detail, see Execution log available at your scan view: $scanOverviewPage"
Exit 1
}
}
Write-Host ""
}
function Run-ASoC-GenerateReport ($scanID) {
$params = @{
Uri = "$global:BaseAPIUrl/Reports/Security/Scan/$scanID"
Method = 'POST'
Headers = @{
'Content-Type' = 'application/json'
Authorization = "Bearer $global:BearerToken"
}
}
$body = @{
'Configuration' = @{
'Summary' = $true
'Details' = $true
'Discussion' = $true
'Overview' = $true
'TableOfContent' = $true
'Advisories' = $true
'FixRecommendation' = $true
'History' = $true
'Coverage' = $true
'MinimizeDetails' = $true
'Articles' = $true
'ReportFileType' = "HTML"
'Title' = "$global:scan_name"
'Locale' = "en-US"
'Notes' = "Github SHA: $env:GITHUB_SHA"
'Comments' = $true
}
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
Write-Debug ($body | Format-Table | Out-String)
$output_runreport = Invoke-RestMethod @params -Body ($body|ConvertTo-Json)
$report_ID = $output_runreport.Id
return $report_ID
}
function Run-ASoC-ReportCompletionChecker($reportID){
#Wait for report
#/api/v4/Reports $filter= Id eq <ReportId>
$params = @{
Uri = "$global:BaseAPIUrl/Reports" + "?%24filter=Id%20eq%20" + $reportID
Method = 'GET'
Headers = @{
'Content-Type' = 'application/json'
Authorization = "Bearer $global:BearerToken"
}
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
$report_status ="Not Ready"
while($report_status -ne "Ready"){
$json = Invoke-RestMethod @params
$output = $json.Items[0]
$report_status = $output.Status
Start-Sleep -Seconds 5
Write-Host "Generating Report... Progress: " $output.Progress "%"
}
}
function Run-ASoC-DownloadReport($reportID){
#Download Report
#/api/v4/Reports/{ReportId}/Download
$params = @{
Uri = "$global:BaseAPIUrl/Reports/$reportID/Download"
Method = 'GET'
Headers = @{
'Accept' = 'text/html'
Authorization = "Bearer $global:BearerToken"
}
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
$output_runreport = Invoke-RestMethod @params
Out-File -InputObject $output_runreport -FilePath ".\AppScan_Security_Report - $env:GITHUB_SHA.html"
}
#policies options are 'All' or 'None'
function Run-ASoC-GetIssueCount($scanID, $policyScope){
#/api/v4/Issues/Scan/<scanID>?applyPolicies=all&$filter=status eq 'Open' or Status eq 'InProgress' or Status eq 'Reopened' &$apply=groupby((Status,Severity),aggregate($count as N))
$params = @{
Uri = "$global:BaseAPIUrl/Issues/Scan/$scanID"+"?applyPolicies="+"$policyScope"+"&%24filter=Status%20eq%20%27Open%27%20or%20Status%20eq%20%27InProgress%27%20or%20Status%20eq%20%27Reopened%27&%24apply=groupby%28%28Status%2CSeverity%29%2Caggregate%28%24count%20as%20N%29%29"
Method = 'GET'
Headers = @{
'Content-Type' = 'application/json'
Authorization = "Bearer $global:BearerToken"
}
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
$jsonOutput = Invoke-RestMethod @params
#DEBUG
#$jsonOutput
return $jsonOutput.Items
}
function FailBuild-ByNonCompliance($issueCountJson){
$failBuild = $false
$totalIssues = 0
foreach($i in $issueCountJson){
$totalIssues = $totalIssues + $i.Count
}
#DEBUG
Write-Host "Total issues: $totalIssues"
if($totalIssues -gt 0){
$failBuild = $true
}
return $failBuild
}
function FailBuild-BySeverity($issueCountJson, $failureThresholdText){
#0 = Informational
#1 = Low
#2 = Medium
#3 = High
#4 = Critical
$failureThresholdNum = 0
$failureThresholdNum = Get-SeverityValue($failureThresholdText)
$totalIssuesCountAboveThreshold = 0
$failBuild = $false
foreach($i in $issueCountJson){
$sevNum = Get-SeverityValue($i.Severity)
if($sevNum -ge $failureThresholdNum){
$totalIssuesCountAboveThreshold = $totalIssuesCountAboveThreshold + $i.Count
}
}
#DEBUG
Write-Host "Total count of issues above threshold: $totalIssuesCountAboveThreshold"
if($totalIssuesCountAboveThreshold -gt 0){
$failBuild = $true
}
return $failBuild
}
function Get-SeverityValue($severityText){
$severityValue = 1;
switch($severityText){
'Informational' {$severityValue = 0;break}
'Low' {$severityValue = 1;break}
'Medium' {$severityValue = 2;break}
'High' {$severityValue = 3;break}
'Critical' {$severityValue = 4;break}
}
return $severityValue
}
function Run-ASoC-GetAllIssuesFromScan($scanId){
#Download Report
$params = @{
Uri = "$global:BaseAPIUrl/Issues/Scan/$scanId"+"?applyPolicies=None"
Method = 'GET'
Headers = @{
'Accept' = 'text/html'
Authorization = "Bearer $global:BearerToken"
}
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
$jsonIssues = Invoke-RestMethod @params
return $jsonIssues
}
function Run-ASoC-SetCommentForIssue($scanId, $issueId, $inputComment){
#Download Report
$params = @{
Uri = "$global:BaseAPIUrl/Issues/Scan/$scanId"+"?odataFilter=Id%20eq%20"+$issueId
Method = 'PUT'
Headers = @{
Authorization = "Bearer $global:BearerToken"
'Content-Type' = 'application/json'
}
}
$jsonBody =@{
Comment = $inputComment
}
#DEBUG
#Write-Debug ($params | Format-Table | Out-String)
$jsonOutput = Invoke-RestMethod @params -Body ($jsonBody|ConvertTo-JSON)
return "Done"
}
#DELETE
function Run-ASoC-SetBatchComments($scanId, $inputComment){
$params = @{
Uri = "$global:BaseAPIUrl/Issues/Scan/$scanId"+"applyPolicies=None"
Method = 'PUT'
Headers = @{
Authorization = "Bearer $global:BearerToken"
'Content-Type' = 'application/json'
}
}
$jsonBody =@{
Comment = $inputComment
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
$jsonOutput = Invoke-RestMethod @params -Body ($jsonBody|ConvertTo-JSON)
return $jsonOutput
}
function Run-ASoC-GetScanDetails($scanId){
#$latestScanExecutionId = ''
$params = @{
Uri = "$global:BaseAPIUrl/Scans/"+"?%24filter=Id%20eq%20"+$scanId
Method = 'GET'
Headers = @{
Authorization = "Bearer $global:BearerToken"
'Content-Type' = 'application/json'
}
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
$response = Invoke-RestMethod @params
$array = $response.Items
$jsonOutput = $array[0]
#$latestScanExecutionId = $jsonOutput.LatestExecution.Id
return $jsonOutput
}
function Run-ASoC-CancelScanExecution($executionId){
$params = @{
Uri = "$global:BaseAPIUrl/Scans/Execution/$executionId/"
Method = 'DELETE'
Headers = @{
Authorization = "Bearer $global:BearerToken"
'Content-Type' = 'application/json'
}
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
$jsonOutput = Invoke-WebRequest @params
Write-Debug $jsonOutput
return $jsonOutput
}
function Delete-LatestRunningScanExecution($scanId){
$ExecutionId = ''
$ExecutionProgress = ''
$scanDetailJson = Run-ASoC-GetScanDetails($scanId)
$ExecutionId = $scanDetailJson.LatestExecution.Id
$ExecutionProgress = $scanDetailJson.LatestExecution.ExecutionProgress
if($ExecutionProgress -ne 'Completed'){
$cancelStatus = Run-ASoC-CancelScanExecution($ExecutionId)
Write-Debug $cancelStatus
if($cancelStatus.StatusCode -In 200..299){
Write-Host "Latest Scan Execution with Execution ID: $ExecutionId is successfully cancelled."
}else{
Write-Host "Cancellation of Scan with Execution ID: $executionId unsuccessful. See debug output:"
Write-Host $cancelStatus
}
}else{
Write-Host "Latest scan execution ID: $ExecutionId is already completed and not occupying a scan queue."
}
}
#Epheremal presence related functions
function Run-ASoC-CreatePresence($presenceName){
#CREATE PRESENCE
$params = @{
Uri = "$global:BaseAPIUrl/Presences"
Method = 'POST'
Headers = @{
Authorization = "Bearer $global:BearerToken"
'Content-Type' = 'application/json'
}
}
$jsonBody =@{
PresenceName = $presenceName
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
$jsonOutput = Invoke-RestMethod @params -Body ($jsonBody|ConvertTo-JSON)
$presenceId = $jsonOutput.Id
return $presenceId
}
function Run-ASoC-DownloadPresence($presenceId, $OutputFileName, $platform){
#DOWNLOAD PRESENCE ZIP FILE
$params = @{
Uri = "$global:BaseAPIUrl/Presences/"+$presenceId+"/Download/"+$platform
Method = 'GET'
Headers = @{
Authorization = "Bearer $global:BearerToken"
'Content-Type' = 'application/json'
}
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
$ProgressPreference = 'SilentlyContinue'
$jsonOutput = Invoke-WebRequest @params -OutFile $OutputFileName
$ProgressPreference = 'Continue'
return $jsonOutput
}
function Run-ASoC-DeletePresence($presenceId){
$params = @{
Uri = "$global:BaseAPIUrl/Presences/"+$presenceId
Method = 'DELETE'
Headers = @{
Authorization = "Bearer $global:BearerToken"
'Content-Type' = 'application/json'
}
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
$response = ""
try {
$response = Invoke-WebRequest @params
Write-Host "Successfully deleted presence with ID: $presenceId"
}
catch {
Write-Host "Failed to delete presence with ID: $presenceId"
Write-Host "The request failed with error: $($_.Exception.Message)"
Write-Host "The request failed with HTTP status code $($response.StatusCode)"
Write-Host "The failure message is: $($response.StatusDescription)"
}
}
function Run-ASoC-GetPresenceIdGivenPresenceName($presenceName){
$params = @{
Uri = "$global:BaseAPIUrl/Presences"
Method = 'GET'
Headers = @{
Authorization = "Bearer $global:BearerToken"
'Content-Type' = 'application/json'
}
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
$response = Invoke-RestMethod @params
$array = $response.Items
foreach($i in $array){
if($i.PresenceName -eq $presenceName){
return $i.Id
}
}
}
function Run-ASoC-CheckPresenceStatus($presenceId){
#CREATE PRESENCE
$params = @{
Uri = "$global:BaseAPIUrl/Presences?%24filter=Id%20eq%20"+$presenceId
Method = 'GET'
Headers = @{
Authorization = "Bearer $global:BearerToken"
'Content-Type' = 'application/json'
}
}
#DEBUG
Write-Debug ($params | Format-Table | Out-String)
$response = Invoke-RestMethod @params
$array = $response.Items
$jsonOutput = $array[0]
if($jsonOutput.Status -eq 'Active'){
Write-Host "AppScan Presence with ID: $presenceId is in active state. "
return $true
}else{
Write-Host "AppScan Presence with ID:" $presenceId "is NOT yet in active state. State =" $array.Status
return $false
}
}
#Creates a ephemeral presence. Returns the presenceId if successful.
function Create-EphemeralPresenceWithDocker{
#$global:ephemeralPresenceName = "Github $env:GITHUB_SHA"
$presenceName = $global:ephemeralPresenceName
$presenceFileName = 'presence.zip'
$presenceFolder = 'presence'
$platform = 'linux_x64'
#DELETE PRESENCE IF PRESENT
$presenceId = Run-ASoC-GetPresenceIdGivenPresenceName($presenceName)
if($presenceId){
Run-ASoC-DeletePresence($presenceId)
}
#CREATE A NEW PRESENCE
$presenceId = Run-ASoC-CreatePresence($presenceName)
$output = Run-ASoC-DownloadPresence $presenceId $presenceFileName $platform
$dockerContainerName = 'appscanpresence_container'
$dockerImageName = 'appscanpresence_image'
$dockerfileName = 'dockerfile'
#Start presence in a container
if ((docker ps -a --format '{{.Names}}') -contains $dockerContainerName) {
docker stop $dockerContainerName
docker rm $dockerContainerName
}
Write-Host "Creating docker image..."
(docker build -f $env:GITHUB_ACTION_PATH/$dockerfileName -t $dockerImageName .) 2>&1
Write-Host "Starting container..."
docker run --name $dockerContainerName -d $dockerImageName
#Pause for 5 seconds for the commands to complete
Start-Sleep -Seconds 5
#Get latest docker log
Write-Host "Getting Latest Appscan Presence Log from the container:"
docker logs $dockerContainerName
#Check if presence is up and running
$i = 1
$checkPresenceMaxCount = 5 #Number of times to check if Presence is up and running
$pauseDuration = 5 #pause duration in seconds
$presenceStatus = $false
while(($i -le $checkPresenceMaxCount) -and ($presenceStatus -eq $false)){
Write-Host "Checking for Presence Status from ASoC..."
$presenceStatus = Run-ASoC-CheckPresenceStatus($presenceId)
Start-Sleep -Seconds $pauseDuration
$i = $i + 1
}
if($presenceStatus){
Write-Host "Ephemeral Presence is deployed and running"
$global:ephemeralPresenceId = $presenceId
}else{
Write-Error "Ephemeral Presence creation failed. Presence status = $presenceStatus"
exit 1
}
}