?
Solved

List Folder Owners

Posted on 2013-12-18
2
Medium Priority
?
400 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 2000 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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

801 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