Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Share auditing for single server and shares

$
0
0

Powershell Noob. 

I have a minimal programming experience but enough to understand certain workflows. 

After a long time of searching the internet for a way to get the user and groups in a share I yet to find the right script for what I need. But along the way I found some that can do what I want I just dont know how to join the scripts and create the final output. Anyone have any advice?

#ask for server name
$Server = Read-Host -Prompt "server name"

#this provides a clean list of shares located on the desired server. 
(net view $Server | Where-Object { $_ -match '\sDisk\s' }) -replace '\s\s+', ',' | ForEach-Object{ ($_ -split ',')[0] }

#I would like to take the outputs from above and have it run with the line below. making the outputs the $ShareName Value. I dont know how to link these 2 commands. 


#This gives you the list of accounts that have access to the share. To test replace \\$Server\$ShareName with actual path. 
((get-item \\$Server\$ShareName).GetAccessControl('access')).Access |select identityreference

#The output I would like to get is a csv with the following columns Share name, User or Group Access. 
#Share Name, User Or Group Access
#Share1,User1
#Share1,group1
#Share2,User1
#Share2,User2
#share2,Group2




Viewing all articles
Browse latest Browse all 15028

Trending Articles



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