Link to home
Start Free TrialLog in
Avatar of aquila98
aquila98

asked on

how to check group permission on a file located on a remote server ?

Hello

I need to perform the equivalent of :
icacls C:\Windows\System32\winevt\Logs\application.evtx to check if AD group [domain]\[GROUPNAME] has the right to see the log.

I need to do this for each and every server on our company's vlan!

I think this could be automated... but how can my desktop connect to each server to perform the same  function as icacls ??? ( I am of course admin of all of the servers)

I tried  with SelectQuery = New SelectQuery(String.Format("SELECT * FROM  Win32_Directory WHERE name = '{0}'", sFileName))  or ManagementObject with a scope but then how can I obtain the list of permissions ???


Have you any hints as to how I should proceed ???

thanks
Avatar of aquila98
aquila98

ASKER

maybe I could use powershell ? I know nothing about powershell language but a little googling and I was ablt to build this script which does not work... but could you help improve it ?
function Get-PathPermissions {
 
param ( [Parameter(Mandatory=$true)] [System.String]${Path} )
 
    begin {
    $root = Get-Item $Path
    ($root | get-acl).Access | Add-Member -MemberType NoteProperty -Name "Path" -Value $($root.fullname).ToString() -PassThru
    }
    process {
    $containers = Get-ChildItem -path $Path -recurse | ? {$_.psIscontainer -eq $true}
    if ($containers -eq $null) {break}
        foreach ($container in $containers)
        {
        (Get-ACL $container.fullname).Access | ? { $_.IsInherited -eq $false } | Add-Member -MemberType NoteProperty -Name "Path" -Value $($container.fullname).ToString() -PassThru
        }
    }
}



    $ErrorActionPreference = "Stop"
      
      $secpasswd = ConvertTo-SecureString "mypassword" -AsPlainText -Force
      $credential = New-Object System.Management.Automation.PSCredential ("mylogin", $secpasswd)

      Enter-PSSession -ComputerName "theremoteserver.net" -Credential $credential
      
      Get-PathPermissions $args[0]
      
      Exit-PSSession

and I call it thusly from a dos command window:
powershell -executionPolicy bypass -file "d:\temp\myscript.ps1" "C:\Windows\System32\winevt\Logs\application.evtx"

what is wrong ?

thanks for any tips
ASKER CERTIFIED SOLUTION
Avatar of aquila98
aquila98

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
not too bad for a newby ;)