mirror of
				https://github.com/socfortress/Wazuh-Rules.git
				synced 2025-11-03 21:33:16 +00:00 
			
		
		
		
	Create disableuseraccount.ps1
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							26236db7db
						
					
				
				
					commit
					3bf72f1deb
				
			
							
								
								
									
										25
									
								
								Active Response/Windows/disableuseraccount.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								Active Response/Windows/disableuseraccount.ps1
									
									
									
									
									
										Normal 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
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user