I have to come up with a way to reset all the sql server credentials on our domain. I realize PowerShell is great for this type of change, I havn't had the opportunity to learn it and now I have a requirement to make these changes. I found a function online and have been trying to figure out the best way to manage this type of change. Is it possible to have the function on one server with a list of servers to make the changes on in a text file and using one source for the new credentials?
Function Set-ServiceAcctCreds
(
[SERVERNAME]$strCompName,
[NonProd_SQL_Svc@usvci001.vci.na.vwg]$strServiceName,
[NEWCREDENTIALS]$newAcct,
[NEWPASSWORD]$newPass
)
{
$filter = 'Name=' + "'" + $strServiceName + "'" + ''
$service = Get-WMIObject -ComputerName $strCompName -namespace "root\cimv2" -class Win32_Service -Filter
$filter
$service.Change($null,$null,$null,$null,$null,$null,$newAcct,$newPass)
$service.StopService()
while ($service.Started)
{
sleep 2 $service = Get-WMIObject -ComputerName $strCompName -namespace "root\cimv2" -class Win32_Service -Filter $filter
}
$service.StartService()
}