0

我一直在尝试为 Office 365 上的用户启用 MFA(多因素身份验证)。尝试运行以下代码时,出现以下错误。我尝试了与此相关的不同组合,但没有运气。

Import-Module ActiveDirectory
Import-Module MSOnline

$password = ConvertTo-SecureString 'PASSWORD' -AsPlainText -Force
$LiveCred = New-Object System.Management.Automation.PSCredential ("admin@contoso.com", $password)
New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection

Connect-MsolService -Credential $Livecred

$st = New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationRequirement
$st.RelyingParty = "*"
$st.State = "Enforced"
$sta = @($st)
Set-MsolUser -UserPrincipalName "user@contoso.com"  -StrongAuthenticationRequirements $sta

错误信息:

Property 'State' cannot be found on this object; make sure it exists and is settable.
At line:21 char:1
+ $st.State = "Enforced"
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

Set-MsolUser : A parameter cannot be found that matches parameter name 'StrongAuthenticationRequirements'.
At line:23 char:59
+ Set-MsolUser -UserPrincipalName "user@contoso.com"  -StrongAuthenticationR ...
+                                                           ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-MsolUser], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Online.Administration.Automation.SetUser
4

0 回答 0