I have a new tip for you.
My very best SharePoint buddy asked me today how to configure the Automatic password change using PowerShell, he could not find an answer anywhere…it was a good question…seems like the answer was missing and that was when I started to do some research.
I found nothing! Could be that I missed something, but Technet, Blogs, Forums, none had the answer…
The impressive Engine of a Boeing 787 – Dreamliner
After a lot of testing and failing, I managed to produce this working script:
|*Must be executed in a PowerShell prompt running as administrator.
*If used in a .ps1 script file, you have to set the execution policy first.
*Replace the domain\accountname with an existing managed account.
*Change the values to valid values that you want to use.
# Set Automatic password change schedule
$SPManagedAccount = Get-SPManagedAccount -Identity “domain\accountname”
#Create a SPMonthlySchedule object and set default properties (as in the gui)
$SPSchedule = new-object Microsoft.SharePoint.SPMonthlySchedule
$SPSchedule.BeginDay = 7
$SPSchedule.EndDay = 7
$SPSchedule.BeginHour = 2
$SPSchedule.EndHour = 3
$SPSchedule.BeginMinute = 0
$SPSchedule.EndMinute = 0
$SPSchedule.beginsecond = 0
$SPSchedule.endsecond = 0
# Set the change schedule on the account
$SPManagedAccount.ChangeSchedule = $SPSchedule
$SPManagedAccount.DaysBeforeExpiryToChange = 2
# Properties not enabled in a default scenario in the GUI
$SPManagedAccount.EnableEmailBeforePasswordChange = $False
$SPManagedAccount.DaysBeforeChangeToEmail = 2
# Enable and make the change
$SPManagedAccount.AutomaticChange = $True
In my environment, it looks like this:
After successfulle updating the Managed Account with the automatic update Schedule, I just typed in
and hit enter, that gives you the most common properties
If you want to see the entire Schedule with details, type in:
$SPManagedAccount | ft ChangeSchedule
Then you get this:
Thats it, a Schedule has been set!
|If you want to use the GUI in central administration to find out what values to set, enable the Automatic Password change on any managed account, than set the values you want in the graphical user interface. Save them by clicking OK.
Next you run the following in your PowerShell prompt:
$SPTemplateManagedAccount = Get-SPManagedAccount “corp\sp10search”
$SPTemplateSchedule = $SPTemplateManagedAccount.ChangeSchedule
This will produce a list looking like this:
BeginDay : 7
EndDay : 7
Description : Monthly
BeginHour : 2
EndHour : 3
BeginMinute : 0
EndMinute : 0
BeginSecond : 0
EndSecond : 0
Use the values in the list in your script and you will have identical values set.
Note: If you want to have a Daily Schedule instead of Monthly like in my example, you will have to modify the script to create a Microsoft.SharePoint.SPDailySchedule object instead.
If you do that, you will also have to remove the lines setting the BeginDay and EndDay values, they are not used in a Daily Schedule object.
Configure automatic password change in SharePoint 2013 (GUI version only)
Plan automatic password change in SharePoint 2013
Mattias Gutke at CAG. He asked the question…
One thought on “Configure automatic password change in SharePoint 2013 using PowerShell”