简体   繁体   English

在PowerShell中为所需状态配置脚本返回IIS Windows身份验证提供程序

[英]Return IIS Windows Authentication Provider in PowerShell for Desired State Configuration script

I am writing some logic for DSC to check if Negotiate:Kerberos is in the provider list for Windows Authentication under one of our Websites. 我正在为DSC编写一些逻辑,以检查Negotiate:Kerberos是否在我们网站之一下的Windows身份验证的提供程序列表中。 I've written the logic to check for Windows Authentication and confirm that's turned on: 我已经编写了检查Windows身份验证并确认已打开的逻辑:

Script ActiveSyncAuthentication
            {
                SetScript = {
                     Set-WebConfiguration system.webServer/security/authentication/windowsAuthentication -PSPath IIS:\ -Location 'Default Web Site/MySite' -Value @{enabled="True"}
                }
                TestScript = {
                     return ((Get-WebConfigurationProperty //system.webServer/security/authentication/windowsAuthentication -PSPath IIS:\ -Location 'Default Web Site/MySite' -Name Enabled) -eq "True")  
                }
                GetScript = { }    
            }  

I know that I can add to the list of providers with the below: 我知道我可以使用以下方法添加到提供商列表中:

Add-WebConfiguration -Filter system.webServer/security/authentication/windowsAuthentication/providers -PSPath IIS:\ -Location 'Default Web Site/MySite' -Value Negotiate:Kerberos  

However, I'm struggling with returning this using Get-WebConfiguration or Get-WebConfigurationProperty. 但是,我很努力地使用Get-WebConfiguration或Get-WebConfigurationProperty返回它。

You can use this : 您可以使用:

        $WinAuthen = Get-WebConfigurationProperty -filter /system.webServer/security/authentication/windowsAuthentication -PSPath $PSPath -Name enabled | Select Name,Value
    $WinProviders = Get-WebConfigurationProperty -filter /system.webServer/security/authentication/windowsAuthentication -PSPath $PSPath -Name Providers
    $WinProviders = $WinProviders.Collection | Select Value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM