Created
February 6, 2023 22:50
-
-
Save nanoDBA/2b7ae077767eb3d5ff5115faadf1f839 to your computer and use it in GitHub Desktop.
Shows users currently using process Ssms.exe in a loop executing every 55 minutes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do { | |
$ssms = Get-WmiObject -Class Win32_Process -Filter "name = 'Ssms.exe'" | |
<# Timer/time bomb stub #> $now = Get-Date | |
$timespan = New-TimeSpan -Start $now -End (Get-Date).AddMinutes(55) # '20:25') #'2077-10-09 19:30' | |
Write-Host -ForegroundColor magenta "SSMS active user count: $(($ssms.GetOwner()).User.count)" | |
Write-Host -ForegroundColor magenta "SSMS active users: $(($ssms.GetOwner()).User)" | |
Write-Host -ForegroundColor magenta "Sleeping until $((Get-date).AddSeconds($timespan.TotalSeconds)) ..." | |
Start-Sleep -Seconds $timespan.TotalSeconds | |
} | |
while ( ($ssms.GetOwner()).User.count -GT 0 ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment