Get un-existing user list and remove their shares

Welcome Forums General PowerShell Q&A Get un-existing user list and remove their shares

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years, 2 months ago.

  • Author
  • #6254

    Points: 0
    Rank: Member

    by stanger at 2013-01-11 05:23:49

    Hi All,

    I am new here and quite new to powershell. Thing is that I have ~50 servers with their shares for users, shares names are exact usernames+$ f.e. ABCD user has share \\abcdserver1\ABCD$

    My issue is that now I have to find and delete all unneeded shares for un-existing users.

    What I have:

    list of all servers and each server share name

    What I need:

    1. script or PS command to find out all unexisting users shares on separate server from user-list in txt file;
    2. script to delete all folders for unexisting users from remote servers.

    I would appreciate any help.

    by Klaas at 2013-01-11 07:40:35

    Depending on the structure of the shares.txt files you can decide to use Get-Content and some string manipulation to compose an array of strings or Import-Csv to collect shares as objects.
    The same goes for the users.txt.
    Loop through the share collection and check for each one if it exists in the user collection. If not, delete the folder with Remove-Item.
    Or you could collect the shares 'live' from your servers instead of using a .txt.

    It might help if you post a sample of your files and the code you have managed to write so far.

The topic ‘Get un-existing user list and remove their shares’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort