locked
Is it possible to set default authentication methods via Powershell? RRS feed

  • Question

  • User-555149872 posted

     This is how we do it manually:

    In IIS Manager, click on Server Name again
    Scroll down and double click Authentication
    Right Click the Windows Authentication and select Enable
    Right Click the Windows Authentication and select Advanced Settings
    Uncheck the box for “Enable kernel-mode authentication
    Right click ASP.NET Impersonation and select Enable
    Right click on Basic Authentication and select Enable (for F5 monitoring)
     

    It appears that I can set Windows Authentication with:

    Set-WebConfigurationProperty -filter /system.webServer/security/authentication/windowsAuthentication -name enabled -value True -PSPath IIS:\

    But i don't see how to set this:

    Advanced Settings
    Uncheck the box for “Enable kernel-mode authentication

    or these:

    Right click ASP.NET Impersonation and select Enable
    Right click on Basic Authentication and select Enable (for F5 monitoring)

    Thursday, July 26, 2012 5:27 PM

Answers

  • User-555149872 posted

    By George, I think I've got it:

    If ((Get-Module "WebAdministration" -ErrorAction SilentlyContinue) -eq $null){
    Import-Module WebAdministration
    }

    if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
        Add-PSSnapin "Microsoft.SharePoint.PowerShell"
    }

    if ((Get-Module "ServerManager" -ErrorAction SilentlyContinue) -eq $null) {
        Import-Module "ServerManager"
    }


    Set-WebConfigurationProperty -filter /system.webServer/security/authentication/anonymousAuthentication -name enabled -value False -PSPath IIS:\
    Set-WebConfigurationProperty -filter /system.webServer/security/authentication/basicAuthentication -name enabled -value True -PSPath IIS:\
    Set-WebConfigurationProperty -filter /system.webServer/security/authentication/windowsAuthentication -name enabled -value True -PSPath IIS:\
    cd $env:windir\system32\inetsrv
    .\appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/windowsAuthentication /useKernelMode:"False"  /commit:apphost

    #This does the Asp.Net 

    Set-WebConfigurationProperty -Name impersonate -Filter system.web/identity -Value True

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Friday, July 27, 2012 12:24 PM

All replies

  • User-555149872 posted

    So, it seems that these work as far as they go;

    Set-WebConfigurationProperty -filter /system.webServer/security/authentication/anonymousAuthentication -name enabled -value False -PSPath IIS:\
    Set-WebConfigurationProperty -filter /system.webServer/security/authentication/basicAuthentication -name enabled -value True -PSPath IIS:\
    Set-WebConfigurationProperty -filter /system.webServer/security/authentication/windowsAuthentication -name enabled -value True -PSPath IIS:\

    The two that are aluding me are;

    Advanced Settings
    Uncheck the box for “Enable kernel-mode authentication

    or these:

    Right click ASP.NET Impersonation and select Enable

    Friday, July 27, 2012 11:25 AM
  • User-555149872 posted

    By George, I think I've got it:

    If ((Get-Module "WebAdministration" -ErrorAction SilentlyContinue) -eq $null){
    Import-Module WebAdministration
    }

    if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
        Add-PSSnapin "Microsoft.SharePoint.PowerShell"
    }

    if ((Get-Module "ServerManager" -ErrorAction SilentlyContinue) -eq $null) {
        Import-Module "ServerManager"
    }


    Set-WebConfigurationProperty -filter /system.webServer/security/authentication/anonymousAuthentication -name enabled -value False -PSPath IIS:\
    Set-WebConfigurationProperty -filter /system.webServer/security/authentication/basicAuthentication -name enabled -value True -PSPath IIS:\
    Set-WebConfigurationProperty -filter /system.webServer/security/authentication/windowsAuthentication -name enabled -value True -PSPath IIS:\
    cd $env:windir\system32\inetsrv
    .\appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/windowsAuthentication /useKernelMode:"False"  /commit:apphost

    #This does the Asp.Net 

    Set-WebConfigurationProperty -Name impersonate -Filter system.web/identity -Value True

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Friday, July 27, 2012 12:24 PM