@@ -119,13 +119,7 @@ function New-GraphAccessToken() {
119
119
[string ]$ApplicationId ,
120
120
121
121
[Parameter (Mandatory = $true )]
122
- [securestring ]$ClientSecret ,
123
-
124
- [Parameter (Mandatory = $true )]
125
- [string ]$Username ,
126
-
127
- [Parameter (Mandatory = $true )]
128
- [securestring ]$Password
122
+ [securestring ]$ClientSecret
129
123
)
130
124
131
125
begin {
@@ -139,12 +133,9 @@ function New-GraphAccessToken() {
139
133
}
140
134
Body = @ {
141
135
" resource" = " https://graph.microsoft.com"
142
- " grant_type" = " password "
136
+ " grant_type" = " client_credentials "
143
137
" client_id" = " $applicationId "
144
138
" client_secret" = " $ ( ConvertFrom-SecureString - SecureString $clientSecret - AsPlainText) "
145
- " username" = " $username "
146
- " password" = " $ ( ConvertFrom-SecureString - SecureString $password - AsPlainText) "
147
- " scope" = " openid"
148
139
}
149
140
}
150
141
}
@@ -238,18 +229,12 @@ function Initialization {
238
229
$clientSecret = Read-Host - Prompt " Client Secret" - AsSecureString
239
230
if ([string ]::IsNullOrEmpty($clientSecret )) { Write-Error - Message " Client Secret cannot be blank." - ErrorAction Stop }
240
231
241
- $username = Read-Host - Prompt " Username"
242
- if ([string ]::IsNullOrEmpty($username )) { Write-Error - Message " Username cannot be blank." - ErrorAction Stop }
243
-
244
- $password = Read-Host - Prompt " Password" - AsSecureString
245
- if ([string ]::IsNullOrEmpty($password )) { Write-Error - Message " Password cannot be blank." - ErrorAction Stop }
246
-
247
232
Clear-Host
248
233
Write-Host " AWS Single Sign-On Integration - Sync Starting" - ForegroundColor Yellow
249
234
}
250
235
251
236
process {
252
- $accessToken = New-GraphAccessToken - TenantId $tenantId - ApplicationId $applicationId - ClientSecret $clientSecret - Username $username - Password $password
237
+ $accessToken = New-GraphAccessToken - TenantId $tenantId - ApplicationId $applicationId - ClientSecret $clientSecret
253
238
$servicePrincipalId = Get-GraphServicePrincipal - AccessToken $accessToken - DisplayName $displayName
254
239
$jobId = Get-GraphSynchronizationJobId - AccessToken $accessToken - ServicePrincipalId $servicePrincipalId
255
240
Start-GraphSynchronizationJob - AccessToken $accessToken - ServicePrincipalId $servicePrincipalId - JobId $jobId
0 commit comments