$exeList = @()
$Denied = @()
# Collect EXEs
Get-ChildItem C:\ -Recurse -File -Include *.exe -ErrorAction SilentlyContinue |
ForEach-Object {
$exeList += [PSCustomObject]@{
FullName = $_.FullName
CreationTime = $_.CreationTime
}
}
# Collect Access Denied folders
Get-ChildItem C:\ -Recurse -Directory -Force -ErrorAction SilentlyContinue -ErrorVariable Denied |
Out-Null
# Write EXE list to file
"===== ALL EXE FILES =====" | Out-File "F:\All EXE.txt"
$exeList | Format-List | Out-File "F:\All EXE.txt" -Append
# Add header for denied section
"`n`n===== ACCESS DENIED =====" | Out-File "F:\All EXE.txt" -Append
# Write denied folders
$Denied |
Select-Object TargetObject |
Format-List |
Out-File "F:\All EXE.txt" -Append4 views