I have a PowerShell script (Name: Get-OrphanHomeFolder.ps1 -- Author: Jaap Brasser -- http://www.jaapbrasser.com/new-script-find-orphaned-home-folders/) I downloaded and modified for locating and deleting orphaned home folders on our file server.
Due to the large number of users in the company, along with the slow performance of our restore software when enumerating folders to select for possible restorations, we have modified our home folder structure from the traditional layout of:
D:
|
|--Home
|
|--100000
|--102001
|--115000
etc.
To a structure like this:
D:
|
|--Home
|
|--100xxx
| |
| |--100000
| |--100001
| |--100002
| etc.
|--102xxx
| |
| |--102000
| |--102001
| |--102002
| etc.
|--115xxx
| |
| |--115000
| |--115001
| etc.
If I run the script using this command-line format (.\Get-OrphanHomeFolder.ps1 -HomeFolderPath \\fileserver\homeshare\100xxx) it works great, but requires me to manually run it for each subfolder (100xxx, 101xxx, etc) containing a group of user home folders. Is there some way to have PowerShell enumerate all the subfolders that exist directly inside D:\Home, no deeper levels, and then use that to create a list/array of 100xxx, 101xxx, etc to run the main code against?
Get-Childitemshould do what you want