Skip to content

SPManagedAccount

Yorick Kuijs edited this page Nov 13, 2020 · 18 revisions

SPManagedAccount

Parameters

Parameter Attribute DataType Description Allowed Values
AccountName Key String The username of the account
Account Write PSCredential The credential with password of the account
EmailNotification Write UInt32 How many days before a password change should an email be sent
PreExpireDays Write UInt32 How many days before a password expires should it be changed
Schedule Write String What is the schedule for the password reset
Ensure Write String Present ensures managed account exists, absent ensures it is removed Present, Absent
InstallAccount Write PSCredential POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5

Description

Type: Distributed Requires CredSSP: No

This resource will ensure a managed account is provisioned in to the SharePoint farm. The Account object specific the credential to store (including username and password) to set as the managed account. The settings for EmailNotification, PreExpireDays and Schedule all relate to enabling automatic password change for the managed account, leaving these option out of the resource will ensure that no automatic password changing from SharePoint occurs.

The default value for the Ensure parameter is Present. When not specifying this parameter, the managed account is created.

Examples

Example 1

This example shows how to create a new managed account in a local farm.

    Configuration Example
    {
        param(
            [Parameter(Mandatory = $true)]
            [PSCredential]
            $SetupAccount,

            [Parameter(Mandatory = $true)]
            [PSCredential]
            $ManagedAccount
        )
        Import-DscResource -ModuleName SharePointDsc

        node localhost {
            SPManagedAccount NewManagedAccount
            {
                AccountName          = $ManagedAccount.UserName
                Account              = $ManagedAccount
                Ensure               = "Present"
                PsDscRunAsCredential = $SetupAccount
            }
        }
    }

Example 2

This example shows how to create a new managed account in a local farm, using the automatic password change schedule

    Configuration Example
    {
        param(
            [Parameter(Mandatory = $true)]
            [PSCredential]
            $SetupAccount,

            [Parameter(Mandatory = $true)]
            [PSCredential]
            $ManagedAccount
        )
        Import-DscResource -ModuleName SharePointDsc

        node localhost {
            SPManagedAccount NewManagedAccount
            {
                AccountName          = $ManagedAccount.UserName
                Account              = $ManagedAccount
                Ensure               = "Present"
                Schedule             = "monthly between 7 02:00:00 and 7 03:00:00"
                PsDscRunAsCredential = $SetupAccount
            }
        }
    }
Clone this wiki locally