Skip to content

Instantly share code, notes, and snippets.

@mbrownnycnyc
Last active December 12, 2019 13:20
Show Gist options
  • Save mbrownnycnyc/75166deda8376fd55488747ccf933894 to your computer and use it in GitHub Desktop.
Save mbrownnycnyc/75166deda8376fd55488747ccf933894 to your computer and use it in GitHub Desktop.
reg ex reference

regex to match NetBIOS domain and hostname as per MSFT documentation

https://support.microsoft.com/en-us/help/909264/naming-conventions-in-active-directory-for-computers-domains-sites-and

#input: [domain]\[hostname]
(?P<name_domain>^[^\\/:*?\"<>|]*\w{1,63})\\(?P<name_root>[^\\/:*?\"<>|]*\w{1,63}$)

#Splunk rex:
| rex field=name "(?P<name_domain>^[^\\/:*?\"<>|]*\w{1,63})\\\(?P<name_root>[^\\/:*?\"<>|]*\w{1,63}$)"

match a regex to get the index of an object in an array of objects

https://www.vistax64.com/threads/locate-array-index-with-a-match-or-regex.269558/#post-1228092

$credstoreroot[ $($credstoreroot.hostname | select-string $regextomatch | foreach-object {$_.linenumber -1 }) ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment