output a list of file directories on a file server that will show users (Home Drives)

MTS 26 Reputation points
2022-06-14T10:54:40.543+00:00

i would like to use powershell to output a list of file directories on a file server that will show users (Home Drives) what would be the best method for this basically i want to output all the Folder Directories on a file server to cross reference against AD to chedk before a migration

Windows Server Migration
Windows Server Migration
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Migration: The process of making existing applications and data work on a different computer or operating system.
437 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,607 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Newbie Jones 1,366 Reputation points
    2022-06-14T11:32:06.18+00:00

    The following function will get a list of folders that have specific permissions set if that is what you need. (Warning, it can take a long time to run)

    function Get-AclAccess {  
    param ($folder='.', $outfile='aces.csv')  
      
       dir $folder -recurse | Where{$_.PSIsContainer} |  
       ForEach {get-acl $_.pspath}| ForEach {  
           $Path=$_.pspath  
           $_.access | Where {$_.IsInherited -eq $False} |  
           Add-Member -MemberType noteproperty -name path -value $path -passthru  
       } | Export-Csv $outfile -Notype  
    }   
    
    0 comments No comments

  2. Newbie Jones 1,366 Reputation points
    2022-06-14T13:12:58.863+00:00

    Or if you just want the folders. (Although this will also report on all subfolders in users home drives).
    You may want to remove the -recurse attribute if all of the home drives are at the same level.

    function Get-Folder {  
    param ($folder='.', $outfile='folders.csv')  
      
       $results=@()   
      
       dir $folder -recurse | Where {$_.PSIsContainer} |  
       ForEach {  
            $props=@{Path=$_.FullName}  
            $results +=  New-Object -TypeName PSObject -property $props  
          
       }   
         
       $results | Export-Csv $outfile -NoTypeInformation  
      
    }   
    

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.