Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Compare Directories/Permissions across all servers

by OzzyOsbourne (Chaplain)
on Mar 23, 2001 at 22:16 UTC ( #66689=sourcecode: print w/ replies, xml ) Need Help??

Category: NT Admin
Author/Contact Info OzzyOsbourne

Uses File::Find and Win32::FileSecurity to dump file permissions to a text file on shares that you specify.

Usage {share} {outputlog}


If the account does not have a permission, the script double tabs, for easy visual inspection.

By importing the resultant tab-delimited log into a spreadsheet program, you can sort by account(colC), then share(colB), then server(colA), to very simply compare directory rights across your file and prints.

Thanks to Tyke.

use strict;
use Win32::FileSecurity qw(Get EnumerateRights);
use File::Find;

my $share=$ARGV[0];
my $out=$ARGV[1];
my ($name,$mask,@rights,%hash,$server,%rights2,@folders,$subfolder,$se
@servers=map ("//$_/$share",@servers);

open (OUT, ">$out") or die "can't open log file!";    

foreach $server( @servers ) {
print "$server\n";
    find(\&wanted, $server);
    foreach $subfolder (@folders){
    print "\t:$subfolder\n";
        next unless -e $subfolder ;
    if ( Get( $subfolder, \%hash ) ) {
        while( ($name, $mask) = each %hash ) {
        print OUT "$servsplit\t$subsplit\t$name\t"; 
        EnumerateRights( $mask, \@rights ) ;#creates @rights, a list o
+f rights for the account
        foreach $right (@rights){
                $rights2{$right} = 1;
        foreach $item (@rightsmatch){
        if (exists $rights2{$item}){
            print OUT "$item\t";
            print OUT "\'\t";
        print OUT "\n";
    else {
        print( "Error #", int( $! ), ": $!" ) ;

close OUT;

sub wanted {
    if (-d){
        push @folders, "$File::Find::dir/$_";

Comment on Compare Directories/Permissions across all servers
Download Code
Replies are listed 'Best First'.
Re: Compare Directories/Permissions across all servers
by Anonymous Monk on Oct 26, 2002 at 03:57 UTC
    how can this search a hidden share for example d$
      As long as you have admin privs, you can use d\$ as arg[0]. Or you can change the $share variable to d\$, as well.


Back to Code Catacombs

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://66689]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2015-12-01 04:44 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (794 votes), past polls