如何使用具有自动凭据的connect-msolservice?

顶部代码块不起作用,而底部代码块起作用。底部提示出现典型的MFA O365登录窗口“ microsoft登录电子邮件或电话”(如下图所示),我想使用cmdlet Connect-MsolService的凭据参数。我们在这里不使用密码,而是使用证书,因此我想以编程方式向Connect-MsolService cmdlet提供用户的电子邮件地址,而无需使用密码,就像使用MFA登录进行身份验证一样窗口。如何做到这一点?

$adminName = "blah@blah.com";
#$pass = ConvertTo-SecureString "notneeded" -AsPlainText -Force;

$creds = New-Object System.Management.Automation.PSCredential -ArgumentList $adminName;
Connect-MsolService -Credential $creds; 
$currentDateTime = (GET-DATE);

$lastDirSyncTime =(Get-MsolCompanyInformation).LastDirSyncTime.ToLocalTime();

$timeDifference = $currentDateTime - $lastDirSyncTime;

Write-Host "";
Write-Host "Minutes since the last sync:" $timeDifference.TotalMinutes "minutes."; 

以下工作正常,但打开了下图所示的MFA身份验证窗口,要求输入登录用户名

Connect-MsolService; 
$currentDateTime = (GET-DATE);

$lastDirSyncTime =(Get-MsolCompanyInformation).LastDirSyncTime.ToLocalTime();

$timeDifference = $currentDateTime - $lastDirSyncTime;

Write-Host "";
Write-Host "Minutes since the last sync:" $timeDifference.TotalMinutes "minutes."; 

如何使用具有自动凭据的connect-msolservice?

GUDUNVHAI 回答:如何使用具有自动凭据的connect-msolservice?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2870346.html

大家都在问