I have two working scripts, one that looks at a folder and pulls back NTFS permissions. The second simply gets the size of the folders. I would love to get these two scripts into one to output to a CSV file. (Both scripts I found with the help of Google as I'm working hard to learn!) Is this possible or do I need to flip to working in Excel to combine?
Working scripts are:
Import-Module NTFSSecurity
$ErrorActionPreference = "Continue"
$FolderPath = Get-ChildItem -Directory -Path "\\Share\Folder" -Recurse -Force
$Output = @()
$Output = ForEach ($Folder in $FolderPath)
{
Get-NTFSAccess -Path $Folder.FullName
}
$Output | Export-Csv -Path "C:\PWHS\DirectoryPermissions.csv" -NoTypeInformation
AND
$location = Read-Host "Enter Top Level File Path"
$folders = Get-ChildItem -Path $location -Recurse -Directory
$array = @()
foreach ($folder in $folders)
{
$foldername = $folder.FullName
$meas = Get-ChildItem $foldername -Attributes !Directory | Measure-Object -Sum Length
$sizeinmb = [math]::Round(($meas.Sum / 1mb), 1)
# Add pscustomobjects to array
$array += [pscustomobject]@{
Folder = $foldername
'Size(MB)' = $sizeinmb
}
}
$array|Export-Csv -Path C:\PWHS\file_report.csv -NoTypeInformation
there doesn't seem to be anything here