確定參數集有效,Powershell 說:“無法解析參數集...”

確定參數集有效,Powershell 說:“無法解析參數集...”

我正在嘗試運行一個僅接受三個特定參數之一的 Powershell cmdlet。我確信我知道這些參數是什麼,並且我正確地輸入了這些參數。我以管理員身份運行 Powershell,並且確信關聯的 Powershell 模組已加載,並且我嘗試的 cmdlet 有效並從該模組加載。

此 cmdlet和Set-ADFSRelyingPartyTrust -SamlResponseSignature有效參數由以下提供:MessageOnly AssertionOnlyMessageAndAssertionhttps://docs.microsoft.com/en-us/powershell/module/adfs/set-adfsrelyingpartytrust?view=winserver2012r2-ps

我遇到的問題是,無論我嘗試這三個中的哪一個,我都會收到錯誤:

Set-AdfsRelyingPartyTrust : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Set-AdfsRelyingPartyTrust -SamlResponseSignature MessageAndAssertion
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-AdfsRelyingPartyTrust], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.IdentityServer.Management.Commands.SetRelyingPartyTrustCommamd

令人沮喪的是,如果我使用已知的錯誤參數來執行 cmdlet,並使用 -Whatif,它會報告:

Set-AdfsRelyingPartyTrust : Cannot validate argument on parameter 'SamlResponseSignature'. 
The argument "False" does not belong to the set "AssertionOnly,MessageAndAssertion,MessageOnly" 
specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.

即使我從報告集中複製並貼上一個值,我也會收到相同的錯誤。我到底做錯了什麼?

如果這個問題已經得到回答,我深表歉意。我查看的每個搜尋結果僅涉及如果該錯誤作為較大​​腳本的一部分彈出或發布者不確定有效的參數集該怎麼辦。當 cmdlet 獨立運行並且參數集已知時,我找不到有關此錯誤的討論。

答案1

如果仔細查看文檔,您可以看到三個參數集,如果仔細查看,您會發現除了 1 個唯一參數之外的所有參數。這 1 個唯一參數也恰好是必需的

所以對於命令列開關Set-ADFSRelyingPartyTrust必須透過三種方式之一指定目標。

您必須具備以下條件之一:

  • -TargetRelyingParty
  • -TargetIdentifier
  • -TargetName

請注意,在文件中,大多數參數都有方括號,但這 3 個參數沒有,而且它們以不同的顏色呈現。這些差異告訴您這些是必要的。

相關內容