Solved

List Folder Owners

Posted on 2013-12-18
2
399 Views
Last Modified: 2013-12-18
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

    }

}
0
Comment
Question by:CaussyR
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
Recept earned 500 total points
ID: 39728008
If I've understood you correctly you want to identify all folders which are owned by the 'BUILTIN\Administrators' local group. This script will output the identified folders to a text file.

$HomeFolders = get-content 'C:\_PSScripts\FindFolderOwner\Folder.txt'
Foreach ($Folder in $HomeFolders)

{
    $Path =  "\\nas01\personal$\" + $Folder
    $owner = (Get-Acl $Path).owner
    if ($owner -eq 'BUILTIN\Administrators')
        {
        $path | Out-File .\ownedbyadministrator.txt -Append
        }

}

Open in new window

0
 

Author Closing Comment

by:CaussyR
ID: 39728101
Thanks PeterRecz, that's exactly what I wanted....
0

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When asking a question in a forum or creating documentation, screenshots are vital tools that can convey a lot more information and save you and your reader a lot of time
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question