使用PowerShell的用户的多重身份验证

时间:2016-09-19 13:49:43

标签: powershell office365 multi-factor

我一直在尝试为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

0 个答案:

没有答案