PowerShell script 4 - merging the scanning script result data
As you run the Windows server scanning script on multiple systems in your environment, you will have a need to merge multiple CSV files into a single CSV file. This will allow for better searching of the scan results, and help you identify trends in your server infrastructure. PowerShell offers the Import-csv
and Export-csv
cmdlets, which provide the ability to manipulate CSV data. A common technique is to use the Import-csv
and Export-csv
cmdlets with a pipeline to import, manipulate, and export the data to a new CSV file.
To get started, you will need to create several CSV files to merge together. To create multiple CSVs that are similar to the Windows server scanning script output, you can perform the following:
$logloc = "C:\temp\POSHScript\CSVDEMO\" $date = (Get-Date -format "yyyyMMddmmss") Function create-testcsv { param($servername) $csvfile = "$logloc\$servername" + "_" + $date...