Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88809

Powershell get infos about files and try to Export them

$
0
0

I try do write a script where i can choose a folder and powershell shows me the Name, Size,.... of all the files in that folder. After that powershell should export the Informations in a Excel Table. But im stuck and dont know what to do :C

Here is my code that i tried to build

Function Get-Folder($initialDirectory)

{
    [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")|Out-Null

    $foldername = New-Object System.Windows.Forms.FolderBrowserDialog
    $foldername.Description = "Select a folder"
    $foldername.rootfolder = "MyComputer"

    if($foldername.ShowDialog() -eq "OK")
    {
        $folder += $foldername.SelectedPath
    }
    return $folder
}

$a = Get-Folder

$folder = $a
Get-ChildItem -Path $folder | SELECT Name, @{Name="Size In KB";Expression={$_.Length / 1Kb}}, Attributes, LastaccessTime, @{n='Owner';e={(get-acl $_.Fullname).Owner}}| Format-Table -AutoSize 

Export-Csv "C:\Users\DZimmermann\Desktop\Test.csv" -Delimiter ";" -Append

Viewing all articles
Browse latest Browse all 88809

Trending Articles



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