@@ -9,13 +9,15 @@ function Set-EntraAppRoleToApplicationUser {
9
9
HelpMessage = " Specify the data source type: 'DatabaseorDirectory', 'SAPCloudIdentity', or 'Generic' which determines the column attribute mapping." ,
10
10
ParameterSetName = ' Default' )]
11
11
[Parameter (Mandatory = $true , ParameterSetName = ' ExportResults' )]
12
+ [Parameter (Mandatory = $true , ParameterSetName = ' ValidateAction' )]
12
13
[ValidateSet (" DatabaseorDirectory" , " SAPCloudIdentity" , " Generic" )]
13
14
[string ]$DataSource ,
14
15
15
16
[Parameter (Mandatory = $true ,
16
17
HelpMessage = " Path to the input file containing users, e.g., C:\temp\users.csv" ,
17
18
ParameterSetName = ' Default' )]
18
19
[Parameter (Mandatory = $true , ParameterSetName = ' ExportResults' )]
20
+ [Parameter (Mandatory = $true , ParameterSetName = ' ValidateAction' )]
19
21
[ValidateNotNullOrEmpty ()]
20
22
[ValidateScript ({ Test-Path $_ })]
21
23
[System.IO.FileInfo ]$FileName ,
@@ -24,6 +26,7 @@ function Set-EntraAppRoleToApplicationUser {
24
26
HelpMessage = " Name of the application (Service Principal) to assign roles for" ,
25
27
ParameterSetName = ' Default' )]
26
28
[Parameter (Mandatory = $true , ParameterSetName = ' ExportResults' )]
29
+ [Parameter (Mandatory = $true , ParameterSetName = ' ValidateAction' )]
27
30
[ValidateNotNullOrEmpty ()]
28
31
[string ]$ApplicationName ,
29
32
@@ -34,7 +37,10 @@ function Set-EntraAppRoleToApplicationUser {
34
37
35
38
[Parameter (Mandatory = $false , ParameterSetName = ' ExportResults' ,
36
39
HelpMessage = " Path for the export file. Defaults to current directory." )]
37
- [System.IO.FileInfo ]$ExportFileName = (Join-Path (Get-Location ) " EntraAppRoleAssignments_$ ( Get-Date - Format ' yyyyMMdd_HHmmss' ) .csv" )
40
+ [System.IO.FileInfo ]$ExportFileName = (Join-Path (Get-Location ) " EntraAppRoleAssignments_$ ( Get-Date - Format ' yyyyMMdd_HHmmss' ) .csv" ),
41
+
42
+ [Parameter (Mandatory = $false , ParameterSetName = ' ValidateAction' )]
43
+ [switch ]$Validate
38
44
)
39
45
40
46
process {
@@ -130,6 +136,7 @@ function Set-EntraAppRoleToApplicationUser {
130
136
}
131
137
132
138
$newApp = New-EntraApplication @appParams
139
+ $validationStatus += " New application will be created with displayName - '$DisplayName '"
133
140
Write-ColoredVerbose " Created new application: $DisplayName "
134
141
135
142
# Create service principal for the application
@@ -320,6 +327,7 @@ function Set-EntraAppRoleToApplicationUser {
320
327
function StartOrchestration {
321
328
322
329
try {
330
+ $validationStatus = @ ()
323
331
# Import users from the CSV file
324
332
Write-ColoredVerbose " Importing users from file: $FileName " - Color " Cyan"
325
333
$users = Import-Csv - Path $FileName
0 commit comments