I have a few file server clusters with a bunch of shares on them and I need to add permissions for a security group to all the shares. The first step is getting all the shares. I can do this with gwmi -class win32_share so I wrote a powershell script to do this across all the file servers. It works as expected with one issue, it gives me the share paths plus the path to the drive letters (i.e. \\FileServer\J$). I am thinking I can put some kind of IF statement to exclude anything with *$* but I don't know how to go about this. Any thoughts?
Import-Module activedirectory
$ErrorActionPreference = "SilentlyContinue"
$ComputerName=Get-ADComputer -Filter {name -like "FS*"} | %{$_.dnshostName}
$Computers=gwmi -class win32_share -computername $ComputerName
ForEach ($Computer in $Computers){
Write-Host $Computer.Name
}