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.