Login domain\user’ has granted one or more permissions. Revoke the permission before dropping the login (Microsoft SQL Server, Error: 15173)
$svrs = ## list of servers Get-Content from text fiel etc
foreach ($svr in $svrs) {
$server = New-Object Microsoft.SQLServer.Management.Smo.Server $svrs
foreach ($endpoint in $server.Endpoints['Mirroring']) {
if ($endpoint.Owner = 'Domain\User') {
$endpoint.Owner = 'Domain\NEWUser'
$endpoint.Alter()
}
}
}