Discovery (TA0007)(external, opens in a new tab or window)
text code block:event.category:process and host.os.type:windows and powershell.file.script_block_text : ( NetShareEnum or NetWkstaUserEnum or NetSessionEnum or NetLocalGroupEnum or NetLocalGroupGetMembers or DsGetSiteName or DsEnumerateDomainTrusts or WTSEnumerateSessionsEx or WTSQuerySessionInformation or LsaGetLogonSessionData or QueryServiceObjectSecurity or GetComputerNameEx or NetWkstaGetInfo or GetUserNameEx or NetUserEnum or NetUserGetInfo or NetGroupEnum or NetGroupGetInfo or NetGroupGetUsers or NetWkstaTransportEnum or NetServerGetInfo or LsaEnumerateTrustedDomains or NetScheduleJobEnum or NetUserModalsGet ) and not powershell.file.script_block_text : ( ("DsGetSiteName" and ("DiscoverWindowsComputerProperties.ps1" and "param($SourceType, $SourceId, $ManagedEntityId, $ComputerIdentity)")) or ("# Copyright: (c) 2018, Ansible Project" and "#Requires -Module Ansible.ModuleUtils.AddType" and "#AnsibleRequires -CSharpUtil Ansible.Basic") or ("Ansible.Windows.Setup" and "Ansible.Windows.Setup" and "NativeMethods.NetWkstaGetInfo(null, 100, out netBuffer);") )
Install detection rules in Elastic Security
Detect PowerShell Suspicious Discovery Related Windows API Functions in the Elastic Security detection engine by installing this rule into your Elastic Stack.
To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).