Help
Help

Reputation: 181

PowerShell 2 - Displaying Share Directory Where Everyone has Full Control

PowerShell Version: 2 (I understand the risks)

The following command outputs all shares where the "everyone" user group has access:

$Found = @()
Get-WmiObject win32_logicalsharesecuritysetting |
    ForEach-Object {$Path = "\\localhost\\" + $_.Name; Get-Acl -Path $Path |
        Select-Object Path -ExpandProperty Access |
            ForEach-Object {If($_.IdentityReference -eq 'Everyone'){$Found += $_.Path}}}
            
Write-Host "Found: $($Found.Count)"
Write-Host "Share locations:"

$Found | ForEach-Object {Write-Host $_.Replace('Microsoft.PowerShell.Core\FileSystem::\\localhost\','')} 

Can the command above be enhanced to only display shares where the "everyone" user group has "full control" only?

If the radio button is not selected, don't display anything in the output, however, if that full control radio button is selected for the user group "everyone", display an output:

enter image description here

Upvotes: 0

Views: 117

Answers (1)

Frenchy
Frenchy

Reputation: 17007

so in my program i use this piece of code:

$Shares = Get-WmiObject -Class Win32_LogicalShareSecuritySetting
foreach($Share in $Shares) {
    foreach($perm in $Permissions.Descriptor.DACL) {
        if($Perm.Trustee.Name -eq "EveryOne" -and $Perm.AccessMask -eq "2032127" -and $Perm.AceType -eq 0) {
                    #EveryOneFullControl is true so do something
                } else {
                    #EveryOneFullControl is false so do something                 
                }
    }
}

Upvotes: 1

Related Questions