Skip to content

Instantly share code, notes, and snippets.

@MSAdministrator
Last active January 20, 2023 08:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MSAdministrator/d8293d4fc4b35e94bcdde5e89d23ab6c to your computer and use it in GitHub Desktop.
Save MSAdministrator/d8293d4fc4b35e94bcdde5e89d23ab6c to your computer and use it in GitHub Desktop.
$methods = @('Get-AttckTool', 'Get-AttckTechnique', 'Get-AttckTactic', 'Get-AttckMitigation', 'Get-AttckMalware', 'Get-AttckActor')
foreach ($method in $methods){
$properties = @('Name', 'Id')
foreach ($prop in $properties){
${"($method)NameScriptBlock"} = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
(& $method)."$prop".ForEach({
"'" + $_ + "'"
})
}.GetNewClosure()
Register-ArgumentCompleter -CommandName $method -ParameterName $prop -ScriptBlock ${"($method)NameScriptBlock"}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment