$failinimi="D:\jaagup\failid1.xls" $olemas=Test-Path $failinimi if($olemas -eq $true){ Remove-Item $failinimi Write-Host "Kustutati $failinimi" } $excel=New-Object -ComObject Excel.Application $excel.Visible=$true $raamat=$excel.Workbooks.Add() $leht=$raamat.Worksheets.Item(1) $leht.Cells.Item(2, 1)="Failide andmed" $rida=3 $failid=Get-ChildItem foreach($fail in $failid){ $leht.Cells.Item($rida, 1)=$fail.Name $leht.Cells.Item($rida, 2)=$fail.Length $rida=$rida+1 } $raamat.SaveAs($failinimi) $excel.Quit()