I want to remove everyone from shared permission on all non-default shares

D Vijayakumar VLR 126 Reputation points
2020-12-04T00:38:19.54+00:00

I want to remove everyone from all non-default shares on shared permissions exclude default shares as it is only non-default shares we need to remove everyone through power shell on multiple remote servers

can any one help me on this do you have any idea about this or having any power shell script for this it will be very help for us.

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,205 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 30,376 Reputation points Microsoft Vendor
    2020-12-04T12:50:12.783+00:00

    Hi,

    See if this works for you

    $servers = "server1","server2","server3"  
    Invoke-Command -ComputerName $servers -ScriptBlock{Get-SmbShare | Where-Object {$_.Name  -notmatch ".+\$"} | Get-SmbShareAccess | Where-Object {$_.AccountName -eq "Everyone"} | ForEach-Object {  
        Revoke-SmbShareAccess -name $_.name -AccountName $_.AccountName -Force}  
    }  
    

    Best Regards,
    Ian

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful