Skip to content

Commit d4d9a88

Browse files
committed
fix(requires): 🐛 Replace requires statement with custom logic
1 parent 0f375f5 commit d4d9a88

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/public/New-MdeServicePrincipal.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#Requires -PSEdition Core
22
#Requires -Version 7.0
3-
#Requires -Modules Az
43

54
<#
65
.SYNOPSIS
@@ -134,9 +133,10 @@ function New-MdeServicePrincipal {
134133
@{name = 'User.Read.All'; id = 'ffd6563e-842b-4cfc-b349-06006e0473a3' }
135134
@{name = 'Vulnerability.Read'; id = '63a677ce-818c-4409-9d12-5c6d2e2a6bfe' }
136135
)
136+
try { Get-Command Get-AzContext -ErrorAction Stop } catch { Throw 'Az module not found, please install it and connect to Azure.' }
137+
$context = (Get-AzContext)
137138
}
138139
Process {
139-
$context = (Get-AzContext)
140140
if ($context) {
141141
$sp = New-AzADServicePrincipal -DisplayName $name
142142
# Wait for Azure AD
@@ -177,7 +177,7 @@ function New-MdeServicePrincipal {
177177
}
178178
}
179179
else {
180-
Throw 'No active Az session found, please execute Connect-AzAccount first.'
180+
Throw 'No active Az session found, please run Connect-AzAccount first.'
181181
}
182182
}
183183
End {}

0 commit comments

Comments
 (0)