I’m looking to create a quick PowerShell script that will ask for the managed accounts to create in SharePoint and then just loops through until the user is no longer wanted to create anymore accounts. This is what I have so far and I’m looking for any feedback. Thanks
#Create Managed Accounts for SharePoint
Write-Host “This script must be run as administrator!”
$create = Read-Host “Do you want to create a managed account(y/n)?”
Do
{
If($create -match “y”)
{$cred = Get-Credential
New-SPManagedAccount -Credential $cred}
$create = Read-Host “Do you want to create a managed account(y/n)?”
}
While($create -match “y”)
#Get a list of all managed accounts.
Get-SPManagedAccount
looks pretty well! You might also wanna take a look at what Brian Lalancette did in the massive AutoSPInstaller script which installs / configures SharePoint. Download this: https://autospinstaller.codeplex.com/ and check the functions file. It’s a gold mine!
Does what I need to do. I would add a check to see if the SharePoint snap-in is loaded and if not, load it.
Looks good to me. You could add some error handling in case the user does not exist/enters a wrong password. Other than that, great!