Skip to content

Instantly share code, notes, and snippets.

@NicholasLeader
Last active February 6, 2019 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NicholasLeader/9f614ad249398be8d32346b9b7944ba6 to your computer and use it in GitHub Desktop.
Save NicholasLeader/9f614ad249398be8d32346b9b7944ba6 to your computer and use it in GitHub Desktop.
<#
Nicholas Leader
09.08.2018
Merging 2 sets of data with compare-object lookup.
List of servers and adding columns to the CSV from a AV CSV
This script returns *all* data elements from both CSVs, rather than just from 1 CSV with compare-object
#>
#date stamp in string
$DateStamp = get-date -Format MM.dd.yyyy.mm
# source list of servers
$a = import-csv 'server_report.csv'
# AV report - adding a 'hostname' property from the 'system name' field, which has the hostname so I can compare on hostname
$b = import-csv 'Agent_Communication_Summary_(Nicholas).csv' | Select-Object *, @{name='hostname';expression={$_.'system name'}}
# taking the orginal server report and adding some calculated properties
# using 'compare-object' to compare on host name and then return the invidual property in the delta that I'm interested in
# this effectively performs a look-up on the CSV and returns data
$a | Select-Object *,
@{name='McAfee DAT Version (VirusScan Enterprise)'; expression={
(Compare-Object $b $_ -Property 'Hostname' -ExcludeDifferent -includeEqual -PassThru).'DAT Version (VirusScan Enterprise)'}},
@{name='McAfee Product Version (VirusScan Enterprise)'; expression={
(Compare-Object $b $_ -Property 'Hostname' -ExcludeDifferent -includeEqual -PassThru).'Product Version (VirusScan Enterprise)'}},
@{name='McAfee (EPO) Agent Version'; expression={
(Compare-Object $b $_ -Property 'Hostname' -ExcludeDifferent -includeEqual -PassThru).'Product Version (Agent)'}},
@{name='McAfee AP Enabled State'; expression={
(Compare-Object $b $_ -Property 'Hostname' -ExcludeDifferent -includeEqual -PassThru).'AP Enabled State'}},
@{name='McAfee OAS Enabled State'; expression={
(Compare-Object $b $_ -Property 'Hostname' -ExcludeDifferent -includeEqual -PassThru).'OAS Enabled State'}} |
# writing out to CSV with date stamp
Export-Csv -NoTypeInformation "MES_mcAFee_lookup.$DateStamp.csv"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment