add chart with data source


hello,

i have powershell imports disk sizes servers , puts in excel.

no have chart display this. there way powershell don't have add hand. powershell follow:

$excel=new-object -comobject excel.application;
$excel.visible=$true;
#setup workbooks
$sourceworkbook=$excel.workbooks.open($sourcefile);
$targetworkbook=$excel.workbooks.open($destfile);
#load worksheets
$sourceworkbook.worksheets.item(1).activate();
$targetworkbook.worksheets.item(1).activate();
#get source location
$sourcerange1=$sourceworkbook.worksheets.item(1).range("d2");
$sourcerange1.copy() | out-null
#look value ensure keeps searching empty cell
$foundemptycell = $false
#the first row check in range
$rownumber = 4
#declare variable
$range = ""
#loop through rows until find 1 without 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 value in 
$targetworkbook.activesheet.paste($targetrange1)

thanks !!!!!



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

server manager error: ADAM.events.xml could not be enumerated.

Cannot access Anywhere Access using domain name?

WMI Failure: Unable to update Local Resource Group