Normally I would just trial and error this till I got it, but not finding exactly what I’m looking for searching here.
Need help formatting a CSV(or Saved Array Variable) to “group” similar results and leave a space between, to allow better visibility in the output without having to manually modify the csv after wards.
Cant get this to come out without the extra space between lines, so its hard to demonstrate.
Creating a report of hotfixes for certain servers, that list the hotfixes, with dates. But need to break up the report so there is a ROW/line space between servers with different names.
Seems like something that should be fairly easy to do. attempted to just add a line space via `n after the query statement before the end of the foreach loop but that did not work. Error’d out
$results = foreach ($server in $servers.name){
$limit = (Get-Date).AddDays(-60)
get-hotfix -computername $server -Erroraction Continue |select PScomputername, installedon, hotfixID, Description,Caption |where {$_.InstalledOn -gt $limit} |sort PSComputername, installedon
}
$date=(get-date -Format d) -replace “/” , “-”
$time = (get-date -format t) -replace “:” , “-”
$results |export-csv “C:\Monthly Patch Reports\Powershell_Test$date $time PreTESTPatchReport.csv” -NoTypeInformation
Example Intended Results
computer1 - data - data - data
computer1 - data - data - data
computer1 - data - data - data
computer2 - data - data - data
computer3 - data - data - data
computer3 - data - data - data
Example ACTUAL Results
computer1 - data - data - data
computer1 - data - data - data
computer1 - data - data - data
computer2 - data - data - data
computer3 - data - data - data
computer3 - data - data - data