Skip to content

Instantly share code, notes, and snippets.

View Purp1eW0lf's full-sized avatar

Dray Agha Purp1eW0lf

View GitHub Profile
#needs the SAMAccountName
$user = "afairfax";
Disable-ADAccount -Identity "$user" -whatif # confirm this is what you want
Disable-ADAccount -Identity "$user" -verbose
#check it's disabled. Will return false if it is disabled.
(Get-ADUser -Identity $user).enabled
#re-enable the account when you're ready
$user = "afairfax";
get-wsmaninstance -resourceuri shell -enumerate |
select Name, State, Owner, ClientIP, ProcessID, MemoryUsed,
@{Name = "ShellRunTime"; Expression = {[System.Xml.XmlConvert]::ToTimeSpan($_.ShellRunTime)}},
@{Name = "ShellInactivity"; Expression = {[System.Xml.XmlConvert]::ToTimeSpan($_.ShellInactivity)}}
@Purp1eW0lf
Purp1eW0lf / Process_User_cmd.ps1
Last active May 11, 2022 14:36
Process_User_cmd.ps1
gwmi win32_process |
Select Name,@{n='Owner';e={$_.GetOwner().User}},CommandLine |
sort Name -unique -descending | Sort Owner |
ft -wrap -autosize