Create disableuseraccount.ps1

This commit is contained in:
taylor_socfortress
2022-09-20 10:11:11 -05:00
committed by GitHub
parent 26236db7db
commit 3bf72f1deb

View File

@@ -0,0 +1,25 @@
################################
##Script to disable local user account
################################
##########
##info@socfortress.co
##########
# Read the Alert that triggered the Active Response in manager and convert to Array
$INPUT_JSON = Read-Host
$INPUT_ARRAY = $INPUT_JSON | ConvertFrom-Json
$ErrorActionPreference = "SilentlyContinue"
$user = ($INPUT_ARRAY."parameters"."alert"."cmd").ToString()
if ((Net user $user))
{
try{
Net user $user /active:no
echo "$user was disabled" | ConvertTo-Json -Compress | Out-File -width 2000 C:\"Program Files (x86)"\ossec-agent\active-response\active-responses.log -Append -Encoding ascii
}
catch {
throw $_.Exception.Message
}
}
else {
echo "$user was not found" | ConvertTo-Json -Compress | Out-File -width 2000 C:\"Program Files (x86)"\ossec-agent\active-response\active-responses.log -Append -Encoding ascii
}