Skip to content

Instantly share code, notes, and snippets.

@jasonadsit
Last active February 23, 2022 16:22
Show Gist options
  • Save jasonadsit/e2ebc4e6234eeba6c504ab1a58e78c19 to your computer and use it in GitHub Desktop.
Save jasonadsit/e2ebc4e6234eeba6c504ab1a58e78c19 to your computer and use it in GitHub Desktop.
TenablePluginTextParsing.ps1
Get-TenablePluginOutput -PluginID $PluginID | ForEach-Object {
$IpAddress = $_.IpAddress
$NetBiosName = $_.NetBiosName
$_.PluginOutput -split "`n`n" | Where-Object { $_ -cmatch '<Block matching regex>' } | ForEach-Object {
$Lines = $_ -split "`n" | ForEach-Object { $_.Trim() }
$EachOne = @{}
$Lines | ForEach-Object {
$Key = ($_ -split '\s:\s')[0].Trim()
$Value = ($_ -split '\s:\s')[-1].Trim()
$EachOne.Add($Key,$Value)
}
[pscustomobject][ordered]@{
IpAddress = $IpAddress
NetBiosName = $NetBiosName
Property1 = $EachOne['Property 1']
Property2 = $EachOne['Property 2']
Property3 = $EachOne['Property 3']
PropertyN = $EachOne['Property N']
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment