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 for business | Windows Server | User experience | PowerShell
Windows for business | Windows Server | User experience | Other
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.