Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 15264

Using PowerShell to Reset Credentials Services Use to Login

$
0
0

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()
}



Viewing all articles
Browse latest Browse all 15264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>