Skip to content

Instantly share code, notes, and snippets.

@steviecoaster
Last active April 9, 2020 15:51
Show Gist options
  • Select an option

  • Save steviecoaster/ffb8223501183bf9eb5920838091236e to your computer and use it in GitHub Desktop.

Select an option

Save steviecoaster/ffb8223501183bf9eb5920838091236e to your computer and use it in GitHub Desktop.
Choco Audit Object
function ConvertTo-ChocoObject {
[CmdletBinding()]
Param (
[Parameter(ValueFromPipeline)]
[string]$InputObject
)
Process {
# format of the 'choco list -lo -r' output is:
# full info with 'choco list -lo -r --audit
# <PACKAGE NAME>|<VERSION> (ie. adobereader|2015.6.7)
if (-not [string]::IsNullOrEmpty($InputObject)) {
$props = $_.split('|')
[pscustomobject]@{
name = $props[0]
version = $props[1]
#The following get picked up with using the --audit flag in C4B.
InstalledBy = $props[2] -replace ('User:','')
Domain = $props[3] -replace ('Domain:','')
RequestedBy = $props[4] -replace ('Original User:','')
'InstallDate(UTC)' = $props[5] -replace ('InstallDateUtc:','')
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment