Create a list that contains folder names, paths, owners of a fileserver

Configurare noua (How To)

Situatie

Solutie

Use bellow script in powershell:

$RootFolder = “D:\Shared” # Change this to your file server’s root folder
$OutputFile = “C:\FolderList.csv”

# Get all folders
$Folders = Get-ChildItem -Path $RootFolder -Recurse -Directory

# Collect data
$FolderList = foreach ($Folder in $Folders) {
$Owner = (Get-Acl -Path $Folder.FullName).Owner
[PSCustomObject]@{
Folder = $Folder.Name
Path = $Folder.FullName
CreatedBy = $Owner
}
}

# Export to CSV
$FolderList | Export-Csv -Path $OutputFile -NoTypeInformation

Write-Host “Folder list exported to $OutputFile”

Tip solutie

Permanent

Voteaza

(2 din 6 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?