如何使用PowerShell创建/生成Bearer令牌?我需要找出一种使用PowerShell生成承载令牌的方法。
$ADAuthorityURL = "https://login.windows.net/common/oauth2/authorize/"
$resourceURL = "https://AQAEducation.onmicrosoft.com/<<AppRegistrion(1)>>"
$AADuserName = "[email protected]"
$AADpassword = "<<PASSWORD>>"
$AADClientID="<<Application Id of AppRegistrion(1)>>"
Write-Host "Retrieving the AAD Credentials...";
$credential = New-Object UserPasswordCredential($AADuserName, $AADpassword);
$authenticationContext = New-Object AuthenticationContext($ADAuthorityURL);
$authenticationResult = [AuthenticationContextIntegratedAuthExtensions]::AcquireTokenAsync($authenticationContext, $resourceURL, $AADClientID, $credential).Result;
$authenticationResult.AccessToken