Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

add chart with data source

$
0
0

Hello,

i have a powershell that imports disk sizes from servers and puts it in a excel.

no i would like to have a chart that display this. is there a way to do this with powershell so don't have to add everything by hand. my powershell is as follow:

$excel=new-object -comobject excel.application;
$excel.visible=$True;
#Setup the workbooks
$SourceWorkBook=$Excel.Workbooks.open($sourceFile);
$TargetWorkBook=$Excel.workBooks.open($destFile);
#Load the worksheets
$SourceWorkBook.Worksheets.item(1).activate();
$TargetWorkBook.WorkSheets.item(1).activate();
#Get the source location
$SourceRange1=$SourceWorkBook.WorkSheets.item(1).range("D2");
$SourceRange1.copy() | Out-Null
#Look value to ensure that it keeps searching for an empty cell
$foundEmptyCell = $false
#The first row to check in the range
$rowNumber = 4
#Declare the variable
$range = ""
#Loop through rows until you find one without a value
while (!$foundEmptyCell)
{
    $range = "C{0}" -f $rowNumber
    $TargetRange1=$TargetWorkBook.WorkSheets.item(1).range($range);
    if ($TargetRange1.Value2 -eq $null)
    {
       
        $foundEmptyCell = $true
    }
    else
    {
        #Write-Host $TargetRange1.Value2
        $rowNumber++
    }
}
#Paste the value in 
$TargetWorkBook.ActiveSheet.Paste($TargetRange1)

thanks !!!!!


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>