What T-SQL code could I use that would iterate through all Logins on an instance and identify SQL Server Authenticated logins that are locked? I know how to determine if a given Login is locked, e.g.
declare @login sysname
set @login = 'LoginOfInterest'
select LOGINPROPERTY(@login, 'IsLocked') as islocked;
But would like to execute this in a loop, daily, to pre-identify any Locked logins before any app owners report a Login is locked and should be unlocked. Sure this could be done with PowerShell--feel free to include that code if you'd like. But I'd specifically like to do this using T-SQL.
Thanks in advance.