【问题标题】:Powershell script to verify IIS Settings用于验证 IIS 设置的 Powershell 脚本
【发布时间】:2016-08-02 14:03:07
【问题描述】:

是否可以使用 Power Shell 脚本获取 IIS 设置?

我希望使用脚本获取/检查以下信息:

  1. 检查是否正确列出了 Windows 身份验证提供程序(协商、NTLM)
  2. 检查是否启用了 Windows 身份验证
  3. Windows 身份验证高级设置 -> 启用内核模式已开启

【问题讨论】:

    标签: windows powershell iis


    【解决方案1】:

    是的,这一切都可以通过 PowerShell 轻松实现。网上有很多样例和例子。

    (IIS) Administration Cmdlets in Windows PowerShell 尤其是Get-WebConfigurationGet-WebConfigurationProperty

    要获取有关 Windows 身份验证高级设置的信息,请使用:

    $windowsAuthFilter = "/system.WebServer/security/authentication/windowsAuthentication"
    $winKernel = (Get-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'Default Web Site' -filter "$windowsAuthFilter" -name "useKernelMode").Value
    $winKernel 
    $winProviders = Get-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'Default Web Site' -filter "$windowsAuthFilter/providers" -name "." 
    $winProviders.Collection | Format-Table value
    

    【讨论】:

    • 已尝试:Import-Module WebAdministration cd IIS: IIS:\>Get-WebConfiguration -Filter "System.WebServer/Security/Authentication/* /*" -Recurse |其中 {$_.enabled -eq $True} | Format-List ' 但得到如下错误: IIS:\>Get-WebConfiguration : 术语 'IIS:\>Get-WebConfiguration' 未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查名称的拼写,如果包含路径,请验证路径是否正确并重试。
    • 运行 Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerManagementTools 安装 IIS cmdlet,如果您有旧的 Windows 版本,请通过 GUI 安装它们。
    • 下面的代码运行良好,但在输出中它没有显示是否为 IIS 启用了 Windows 身份验证:Get-WebConfiguration system.webServer/security/authentication/windowsAuthentication/* 'IIS:\站点\默认网站'-递归 |格式列表
    【解决方案2】:

    下面是阅读匿名和windows认证的答案:

    $anonAuthFilter =    "/system.WebServer/security/authentication/AnonymousAuthentication"
    $windowsAuthFilter = "/system.WebServer/security/authentication/windowsAuthentication"
    
    $value = 'false'
    $AppName = "test"
    
    $anonAuth = Get-WebConfigurationProperty -filter $anonAuthFilter -name Enabled -location $AppName
    Write-Host  $anonAuth.Value
    
    
    $winAuth = Get-WebConfigurationProperty -filter $windowsAuthFilter -name Enabled -location $AppName
    Write-Host  $winAuth.Value
    

    @彼得·汉多夫 仍然没有找到任何线索

    检查 Windows Authentication Advanced Settings -> enable kernel-mode is on and

    检查启用的提供程序,例如 NTLM 和协商

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-15
      • 2020-10-11
      • 2010-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多