Powershell Get-WebConfiguration unrecognized attribute enableSslRSS

4 replies

Last post Jan 27, 2018 06:02 PM by marcomangiante

  • Powershell Get-WebConfiguration unrecognized attribute enableSsl

    Jan 24, 2018 11:28 AM|marcomangiante|LINK

    Hello,

    I'm trying to obtain with the powershell cmdlet Get-WebConfiguration the smtp information of one of my site; I used the cmdlet:

    $smtpSettings = Get-WebConfiguration -pspath "iis:\Sites\MIT_Admin" -Filter system.net/mailSettings/smtp/*

    and when I use it I obtaint the error:

    Get-WebConfiguration : Filename: \\?\C:\inetpub\wwwroot\MIT_Admin\web.config
    Line number: 31
    Error: Unrecognized attribute 'enableSsl'
    At line:1 char:17
    + $smtpSettings = Get-WebConfiguration -pspath "iis:\Sites\MIT_Admin\" -Filter sys ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Get-WebConfiguration], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.IIs.PowerShell.Provider.GetConfi
    gurationCommand

    I also tried to load the settings with 'Configuration Editor" but have a similar error.

    Could you please help to find a solution.

    --

    Regards

  • Re: Powershell Get-WebConfiguration unrecognized attribute enableSsl

    Jan 25, 2018 03:18 AM|Yuk Ding|LINK

    Hi marcomangiante,

     I think the problem is both IIS manger and webadminsitration module doesn't reconginze the enablessl attribute. If you go to system.net/mailSettings/smtp/network, you could see that only "defaultcredentials","host","password","port","username" is supported. EnableSSL is not an original IIS configuration but a .net application configuration. So please remove this configuration and try again.

    In additon, maybe you could try to install the smtp virtual server if you were running an windows server machine.

    Or you could try the other configuration instead of get-webadministtration for IIS.

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: Powershell Get-WebConfiguration unrecognized attribute enableSsl

    Jan 27, 2018 12:40 PM|marcomangiante|LINK

    Hello Yuk,

    thanks a lot for your interest and the reply.

    In additon, maybe you could try to install the smtp virtual server if you were running an windows server machine.

    even if it is off topic, could you please post a link where to start with? I found some infos, but I don't understand if it is available with Server 2012.

    Or you could try the other configuration instead of get-webadministtration for IIS.

    Do you mean for "the other configuration" that with smtp virtual server?

    Do you think there is another option with powershell to retrieve the username in  system.net/mailSettings/smtp/network or however directly in the web.config?

    --

    Regards,

    Marco Mangiante

  • Re: Powershell Get-WebConfiguration unrecognized attribute enableSsl

    Jan 27, 2018 05:31 PM|lextm|LINK

    IIS PowerShell cmdlet relies on the schema file to determine which attributes are supported,

    https://github.com/lextm/iis_schema/blob/master/FX_schema.xml#L269

    and clearly enableSsl is not part of the schema it supports.

    In your case, use XML functions of PowerShell or .NET System.Configuration API to query the settings would be the right way to go.

    Lex Li
    Affordable IIS Consulting Services at https://support.lextudio.com/services/consulting.html
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Powershell Get-WebConfiguration unrecognized attribute enableSsl

    Jan 27, 2018 06:02 PM|marcomangiante|LINK

    Hello,

    I resolved with this code and now reading the reply in the forum I found that I followed the right way:

    #Set the Connection String and the path to web.config
    $webConfigPath = "Web.config"
    
    # Get the content of the config file and cast it to XML
    $xml = [xml](get-content $webConfigPath)     
    $root = $xml.get_DocumentElement();
    
    $mailUsername = $root."system.net".mailSettings.smtp.network.userName
    

    My thanks to Chris Kooken that edited the post https://stackoverflow.com/questions/23957949/powershell-modify-web-config-mailsettings

    Thanks to everyone for their interest.

    --

    Regards,

    Marco Mangiante