Skip to content

Instantly share code, notes, and snippets.

View noblevarghese's full-sized avatar
:octocat:
it's raining PowerShell

noblevarghese noblevarghese

:octocat:
it's raining PowerShell
View GitHub Profile
@JohnL4
JohnL4 / Get-WindowsServicesAndTasksWithHardcodedPasswords.ps1
Last active August 23, 2022 18:05
PowerShell command to find logon account of Windows services; also cmd line to dump attributes of scheduled tasks to CSV file
<#
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