Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

File permissions to excel

$
0
0

Can anyone tell me why this script isn't working?

clear-host
$Servers = Get-Content("C:\Scripts\NextGen\Servers.txt")

$Excel = new-Object -comobject Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
$Sheet = $Excel.Worksheets.Item(1)
$Sheet.Cells.Item(1,1) = "Server Name - File Path"
$Sheet.Cells.Item(1,2) = "FileSystemRights"
$Sheet.Cells.Item(1,3) = "AccessControlType"
$Sheet.Cells.Item(1,4) = "IdentityReference"
$intRow = 2
$WorkBook = $Sheet.UsedRange
$WorkBook.Font.Bold = $True

foreach ($server in $Servers)
{

$path = "\\$Server\C$\NextGen\RptSQLLog.log"
Get-Acl -path $Path | select -expand access | where { $_.IdentityReference -like "BUILTIN\Remote Desktop Users" }

$_.Access | % {
$Sheet.Cells.Item($intRow, 1) = $Path
$Sheet.Cells.Item($intRow, 2) = $_.FileSystemRights
$Sheet.Cells.Item($intRow, 3) = $_.AccessControlType
$Sheet.Cells.Item($intRow, 4) = $_.IdentityReference
$intRow = $intRow + 1
}
}

$WorkBook.EntireColumn.AutoFit()
$Sheet.Cells.Item($intRow,1).Font.Bold = $True

For my results, I don't get anything for the filesystemrights, Accesscontroltype or identityreference:

I am trying to audit a couple hundred servers for the Remote Desktop User permissions on a single specific file.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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