1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# Borrar gráfico anterior rm .\grafico.html $datos = "[" foreach($proceso in (Get-Process | Sort-Object -Descending name )) { if(!$proceso.cpu) { $datos += "['"+ $proceso.name +"', 0]," } else { $datos += "['"+ $proceso.name +"', "+$proceso.cpu+"]," } } $datos += "]" $datos = $datos.Replace("],]","]]") $inicio="<head> <script src=""https://www.gstatic.com/charts/loader.js""></script> <script> google.charts.load('current', {packages: ['corechart']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { // Define the chart to be drawn. var data = new google.visualization.DataTable(); data.addColumn('string', 'Proceso'); data.addColumn('number', 'Consumo CPU en segundos'); data.addRows("+$datos+"); var options = {'title':'La cantidad de tiempo de procesador que el proceso ha utilizado en todos los procesadores, en segundos','width':1200,'height':2000}; // Instantiate and draw the chart. var chart = new google.visualization.BarChart(document.getElementById('myPieChart')); chart.draw(data, options); } </script> </head> <body> <!-- Identify where the chart should be drawn. --> <div id=""myPieChart""></div> </body>" $inicio | Out-File grafico.html -Encoding default -Append |