How to export properties into a csv-file

Hello Guys
I have a question…
I want to export several properties into a csv-file.
I tried it with export-csv and output-file and it even generated me a file, but it was blank.
So what could i do so that it generate a file which isn’t blank.

In order for there to be data in the file, you have to pipe something to it. In your other thread, you had a pipeline that was producing zero objects by the time it got to Export-Csv, which will always result in a blank file.

i made foreach-object loop and filtered out the properties which value was over 50000.
Now the script look like this:
Param (
[string]$Path = "N:",
[string]$ReportPath = “N:\Test\report.csv”,
[switch]$Recurse
)

Function AddObject {
Param (
$FileObject
)

$FileObject
$Size = [double]($FSO.GetFolder($FileObject.FullName).Size)
$Script:TotSize += $Size

# Got rid of the code that converted $Size from a double to a String here

$Script:Report += New-Object PSObject -Property @{
    FolderName = $FileObject.FullName
    CreatedOn = $FileObject.CreationTime
    LastUpdated = $FileObject.LastWriteTime
    Size = $Size
    Owner = (Get-Acl $FileObject.FullName).Owner
}

}

Function CalculateSize {
Param (
[double]$Size
)
If ($Size -gt 1000000)
{ $ReturnSize = ($Size / 1GB)
}
Else
{ $ReturnSize = ($Size / 1MB)
}
Return $ReturnSize
}

Function Set-AlternatingRows {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,ValueFromPipeline=$True)]
[object]$Lines,

    [Parameter(Mandatory=$True)]
   	[string]$CSSEvenClass,
   
    [Parameter(Mandatory=$True)]
    [string]$CSSOddClass
)
Begin {
	$ClassName = $CSSEvenClass
}
Process {
    ForEach ($Line in $Lines)
    {	$Line = $Line.Replace("<tr>","<tr class=""$ClassName"">")
		If ($ClassName -eq $CSSEvenClass)
		{	$ClassName = $CSSOddClass
		}
		Else
		{	$ClassName = $CSSEvenClass
		}
		Return $Line
    }
}

}

cls
$Report = @()
$TotSize = 0
$FSO = New-Object -ComObject Scripting.FileSystemObject

#First get the properties of the starting path
$Root = Get-Item -Path $Path
AddObject $Root

#Now loop through all the subfolders
$ParamSplat = @{
Path = $Path
Recurse = $Recurse
}
ForEach ($Folder in (Get-ChildItem @ParamSplat | Where { $_.PSisContainer }))
{
AddObject $Folder
}

$Report | ForEach-Object {

If($_.Size -gt 500000) {
    write-host $_.Size ,$_.Owner ,$_.FolderName 

    
}

}

I don’t see any call to Export-Csv or Out-File in your code. Also, you’re using Write-Host inside that foreach-object loop. Write-Host outputs to the console, but does not produce any pipeline output. I’m not sure what you’re trying to accomplish with that bit of code.

If you just want to filter out based on size, it’s better to use Where-Object:

$Report |
Where-Object { $_.Size -gt 500000 } |
Whatever

Thanks Dave Wyatt
because of the Export-csv i removed it from the code, because it haven’t done anything

Assuming that there are no folders found with sizes greater than your limit, what do you want to be in the files? As I’ve said, if you pipe nothing to Export-Csv, nothing is what you get. It’s possible to work around that, but I don’t know what your requirements are at this point.