Last active
August 23, 2022 18:05
-
-
Save JohnL4/65098facb14e2b1d5c3d925bbb8bfd5e to your computer and use it in GitHub Desktop.
PowerShell command to find logon account of Windows services; also cmd line to dump attributes of scheduled tasks to CSV file
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
<# | |
This might help in finding that pesky windows service that's always locking you out when you change your password and reboot. | |
#> | |
# ft is Format-Table; -auto is auto column width; -wrap is wrap text if necessary | |
Get-WmiObject win32_service | sort startname,startmode,state,displayname | select StartMode,State,StartName,DisplayName | ft -auto -wrap | |
# Or you can select only certain services. | |
# '?' is 'where' alias; -match uses regular expressions; -not is (obviously) a 'not' operator. | |
Get-WmiObject win32_service | ? {-not ($_.state -match 'running')} | sort startname,displayname | select StartMode,State,StartName,DisplayName | ft -auto -wrap | |
<# | |
Another note: maybe you have a scheduled task that's hammering your account with the wrong password? | |
Here's a command line to dump out scheduled tasks with all properties, so you can use a spreadsheet to filter them to find the ones using | |
your account. | |
See https://msdn.microsoft.com/en-us/library/aa383608(v=vs.85).aspx ("Task Scheduler Reference") for more info | |
#> | |
# /v is verbose; /fo csv is output format of csv | |
schtasks /query /v /fo csv > c:\tmp/scheduled-tasks.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment