Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, April 29, 2019 1:01 PM
Every week task scheduler will run a program and generates the CSV file and saves in file location. I want to compare the last two CSV file(very latest) every time and need to generate the differences in a CSV and chart using powershell. Can you please help
All replies (4)
Monday, April 29, 2019 2:06 PM
Please carefully review the following links to set your expectation for posting in technical forums.
This Forum is for Scripting Questions Rather than script requests |
|
Microsoft Virtual Academy - Getting Started with Microsoft PowerShell |
|
\(ツ)_/
Monday, April 29, 2019 5:22 PM
To get you started you should carefully review the help for the following cmdlets:
Compare-Object and
For each of these cmdlets you should read the complete help including the examples.
Live long and prosper!
(79,108,97,102|%{[char]$_})-join''
Monday, April 29, 2019 6:08 PM
Thank you BOFH_666.
I kind of got until there. I am looking for chart thing.
Monday, April 29, 2019 7:09 PM
Based on the research I've done within the past half hour, you need to download the Microsoft Chart Controls (https://www.microsoft.com/en-us/download/details.aspx?id=14422). This script (https://gallery.technet.microsoft.com/scriptcenter/Charting-Line-Chart-using-df47af9c) creates a line chart, using the Chart Controls.
To input data from your CSV files, modify the lines in the script:
#physical memory
[void]$MemoryUsageChart1.Series.Add("PM")
$MemoryUsageChart1.Series["PM"].BorderWidth = 3
$MemoryUsageChart1.Series["PM"].ChartType = [System.Windows.Forms.DataVisualization.Charting.SeriesChartType]::Line
$Processes = Get-Process | Sort-Object -Property WS | Select-Object Name,PM,VM -Last 5
$ProcessList = @(foreach($Proc in $Processes){$Proc.Name + "`n"+[math]::floor($Proc.PM/1MB)})
$Placeholder = @(foreach($Proc in $Processes){$Proc.PM/1MB})
$MemoryUsageChart1.Series["PM"].Points.DataBindXY($ProcessList, $Placeholder)
#virtual memory
[void]$MemoryUsageChart1.Series.Add("VM")
$MemoryUsageChart1.Series["VM"].BorderWidth = 3
$MemoryUsageChart1.Series["VM"].ChartType = [System.Windows.Forms.DataVisualization.Charting.SeriesChartType]::Line
$Processes = Get-Process | Sort-Object -Property WS | Select-Object Name,PM,VM -Last 5
$ProcessList = @(foreach($Proc in $Processes){$Proc.Name + "`n"+[math]::floor($Proc.VM/1MB)})
$Placeholder = @(foreach($Proc in $Processes){$Proc.VM/1MB})
$MemoryUsageChart1.Series["VM"].Points.DataBindXY($ProcessList, $Placeholder)
And to put the column data from your csv files into an array, you could probably run a command like:
Import-CSV "example.csv" | ForEach-Object {Write-Host 'ColumnName=' +$_.ColumnName}