WebAdministrationDsc icon indicating copy to clipboard operation
WebAdministrationDsc copied to clipboard

How to add credentials with empty password in xWebAppPool.

Open pwyrwas opened this issue 3 years ago • 2 comments

Hello,

base on #80 i saw that is possibility to put empty password when I have account wihtout a password. But I have problem to do this. I'am trying in that way:


Configuration IisConfiguration
{
    Import-DscResource -ModuleName xWebAdministration
    Import-DscResource -ModuleName PSDscResources -ModuleVersion "2.12.0.0"
    $password = "test"
    $pw=  ConvertTo-SecureString $password  -AsPlainText -Force
    $un = "user$";
    $credential = New-Object System.Management.Automation.PSCredential ($un, $pw)
    

    Node $NodeName
    {
        xwebapppooldefaults pooldefaults
        {
            issingleinstance      = 'yes'
            managedruntimeversion = ''
            identitytype          = 'applicationpoolidentity'
        }

        xwebsitedefaults sitedefaults
        {
            issingleinstance       = 'yes'
            logformat              = 'iis'
            logdirectory           = 'd:\inetpub\logs\logfiles'
            tracelogdirectory      = 'd:\inetpub\logs\failedreqlogfiles'
        }

        xWebAppPool MyApi
        {
            Name                           = 'API'
            Ensure                         = 'Present'
            State                          = 'Started'
            autoStart                      = $true
            identityType                   = 'SpecificUser'
            Credential                       = $credential          
        }
    }
}

$configData = @{
    AllNodes = @(
                    @{
                        NodeName = "*";
                        PSDscAllowPlainTextPassword = $true
                    }
                    @{
                        NodeName = "localhost";
                        Roles=@("web")

                    }


        )
    }

IisConfiguration -ConfigurationData $configData

The result is that I have set accout without $. How to set accout with $. It is possible directly in IIS.

pwyrwas avatar Jun 07 '22 10:06 pwyrwas

It is not possible to use empty password for a property using PSCredential type. See https://github.com/dsccommunity/WebAdministrationDsc/issues/581#issuecomment-663145677.

johlju avatar Jun 07 '22 17:06 johlju

If you're saying the account has no password because it's a gmsa, you can assign below to the credential. Credential = New-Object System.Management.Automation.PSCredential("Domain\Account", (ConvertTo-SecureString "Test" -AsPlainText -Force))

But if it's a gmsa it's a domain account, so you also need to decorate your node data with: PSDscAllowDomainUser = $true;

quillypowers avatar Sep 22 '22 20:09 quillypowers