Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

PowerShell Scripting help.....

$
0
0

Folks:

I need help with a PowerShell script. I have the following subfolders under the 'Client' folder (BFA, APHA, MLFE....) and we will be adding more later as and when new clients are added.

\\SERVERNAME1\Clients\BFA\
\\SERVERNAME1\Clients\APHA\
\\SERVERNAME1\Clients\MLFE\
\\SERVERNAME1\Clients\PRUD\
\\SERVERNAME1\Clients\EMG\
\\SERVERNAME1\Clients\BOUG\
\\SERVERNAME1\Clients\MARK\

I have a powershell script to which we provide the path (path is hardcoded) of the folder and then it gets us the permissions on the folders. The script is working great but everytime a new folder is added under \\SERVERNAME1\Clients\ I have to modify the script to include the new folder.

Get-childitem \\SERVERNAME1\Clients\BFA\ | where{$_.psiscontainer} |
Get-Acl | % {
 $path = $_.Path
 $_.Access | % {
 New-Object PSObject -Property @{
 Folder = $path.Replace("Microsoft.PowerShell.Core\FileSystem::","")
 Access = $_.FileSystemRights
 User = $_.IdentityReference
 }
 }
} | ? {-not $_.Inheritance}

What I want is that the sub-folder name under \\SERVERNAME1\Clients\ be passed as a parameter so that whenever a new sub-folder is added under \\SERVERNAME1\Clients\ I don't have to open my script to add a new entry for the sub-folder.

Any help on the script is appreciated.

Thanks !




Viewing all articles
Browse latest Browse all 2562

Trending Articles



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