Author Posts

October 16, 2015 at 8:12 pm

Dear Community
I need help with my script. I wrote a small script to retrive acl information about network share drive. I wanted to output this result to a text file using the same share drive name .

Example :- if my network share drive is \\server.example.db.com\test\myshare

Then i want the output file name like myshare.txt

I have tried some stirng manuplation techniques like trim,replace but i could not get the results what i am looking for .
Or
If there is any other way this can be achieved i am glad to hear that as well 🙂 . Thanks.

$share = Read-Host " Enter full share drive path"

$acl = Get-Acl -Path $share

Write-Host "Retriving ACL List for the share"

$acl.Access | select IdentityReference,FileSystemRights | Format-Table -AutoSize | out-file result.txt 

October 16, 2015 at 8:59 pm

You can use split-path to get the "leaf" of the path.

$share = Read-Host " Enter full share drive path"
$outfile = "$(Split-Path $share -Leaf).txt"

$acl = Get-Acl -Path $share

Write-Host "Retriving ACL List for the share"

$acl.Access | select IdentityReference,FileSystemRights | Format-Table -AutoSize | out-file $outfile

October 16, 2015 at 9:12 pm

Thank you so much Curtis for taking your valuable time to reply . It worked 🙂 . Thanks again ..