Avatar of CaussyR
CaussyR
 asked on

List Folder Owners

Hi everyone,

I am reading in a text file, folder.txt, which has 2 folder names entered.  This is then read into a variable called $Homefolders.

I have tried the below, but for some reason it reads the second folder in and I get something like :

Get-Item : Cannot find path '\\nas01\personal$\folder1 folder2' because it does not exist.


All I need to do is list the folder owners and find out which folders have an owner of 'BUILTIN\Administrators. Below is the script I am trying to work on...

$HomeFolders = get-content 'C:\_PSScripts\FindFolderOwner\Folder.txt'

$Path =  "\\nas01\personal$\" + $HomeFolders

Foreach ($homefolder in $Path)
{

    Get-Item $Path | foreach-object {Get-Acl $_.Fullname}

    if ($homefolder -ne 'BUILTIN\Administrators')
    {
        $df = $Path

    }

}
PowershellWindows OS

Avatar of undefined
Last Comment
CaussyR

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Recept

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
CaussyR

ASKER
Thanks PeterRecz, that's exactly what I wanted....
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes