Trying to find all files or folders with a specific owner recursively

I'm trying to find any file with a specific owner, let's call that owner "domain\account1" I've placed 2 files and a folder at various levels in a directory structure and when I run the following code from the folder those files (or folder) exist
in, it works fine:
gci | Select fullname,@{n='Owner';e={(Get-Acl $_).Owner}} | Where {$_.Owner -eq 'DOMAIN\account1'}
But when I try to go to a common root of those files (and folder) and add -recurse to the gci, it shows only the folder. Is there something secret/hidden about gci that I need it to force-show, or am I doing something else wrong?
Thanks
[email protected]

No.  They look roughly equivalent but the expression I used may be more flexible.  You also can shorten yours more like thsi:
Get-ChildItemC:\Temp -Rec
| Get-ACL 
| ?
{$_.Owner
-eq 'Domain\Admin'}
No need to wrap it in the pipeline.
This is exactly what mine is but I added a select with a calcculated property.
¯\_(ツ)_/¯

Similar Messages

  • How to delete all files and folders (with files) in IsolatedStorage.

    Hi awesome programmer:-) The code I have to clean up the local folder doesn't work properly so I won't even bother posting it here. I basically want to have a "master reset" option to remove all new created files and folder in the local folder.
    Can you give me simple code to remove all files/folder so the app goes back to the state it was when the user installed it for the first time? Thanks in advance. ps I were able to delete a directory(-ies) with this method:
    private async void DeleteDirectory(string directoryName)
    try
    var folder = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFolderAsync(directoryName);
    if (folder != null)
    await folder.DeleteAsync();
    this.Dispatcher.BeginInvoke(delegate()
    txtUpdateFeed.Text = "Folder < " + directoryName + " > deleted.";
    catch (Exception ex)
    this.Dispatcher.BeginInvoke(delegate()
    txtUpdateFeed.Text = "Delete Directory << " + directoryName + " >> Error: " + ex.GetBaseException().Message.ToString();
    It seems to work, I have not tested with all conditions though. Anyway let me put up the code so you can see I have been trying: This is to delete everything but not all files are deleted:
    private void WipeAllData(bool bln)
    try
    txtUpdateFeed.Text = "Removing files...";
    if (bln)
    txtUpdateFeed.Text = "Removing folders...";
    //Delete videos directory
    DeleteDirectory("videos");
    //Delete pictures directory
    DeleteDirectory("pictures");
    txtUpdateFeed.Text = "Folders removed.";
    //Delete the rest of the files
    var iso = IsolatedStorageFile.GetUserStoreForApplication();
    foreach (string name in iso.GetFileNames())
    iso.DeleteFile(name);
    BtnWipeAllData.Content = "Wipe All Data";
    VideoCameraPowerValue = "on";
    BtnVideoCameraPower.Content = "Video Camera: ON";
    PhotoCameraPowerValue = "on";
    BtnPhotoCameraPower.Content = "Photo Camera: ON";
    txtUpdateFeed.Text = "Files removed successfully.";
    catch (Exception ex)
    MessageBox.Show("Wipe All Data Error:\n" + ex.Message.ToString());
    Why isn't all files being deleted?

    Hi Clint William Theron,
    Based on your descriptions, I know that when you run the above code, it does not delete all the files, then have you checked that which kinds of files or in which folder the files can not been deleted?
    Besides, if you want to let the app go back to the state it was when the user installed it for the first time, then an easy way is to uninstall and reinstall it.
    Best Regards,
    Amy Peng
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Easy way to rename all files and folders in a specific directory

    hy all,
    i want to rename all files&folders in a specified folder... i only want to replace all "_'_" with an"-" in all file names...
    example:
    TCHK1_B4194W01PF7_NMOSi_D_B__3_50ohm-500ohm_03-29-07_10'46'23_AM.tst
    TCHK1_B4194W01PF7_NMOSi_D_B__3_50ohm-500ohm_03-29-07_10-46-23_AM.tst
    i cant change the timeformat because this are automatically generated files from an external program...
    this is my program(attached as JPG) but it doesnt work...i get allways "error 10-duplicate path" or "error1 -   An input parameter is invalid"
    could sombody please help me... i think its an easy VI but i cant get it working
    THANKS in advance!!!!
    greets
    Andreas
    Attachments:
    renamefolder.JPG ‏20 KB

    Well, the one problem you have is that for the "Move" function, the source file input should be wired to the output of the "Build Path" function, not to the duplicate path out of the "List" function. Also, you need to pass the error cluster around with a shift register. Otherwise you will not catch an error that may have occurred during one of the file rename operations.

  • My computer has some serious problems, my iphoto only shows thumb size pics when I try to open them, i tried to rebuild my files from folders that had the pics in them. originally all the photos has a large delta with a question mark. also I can't back up

    my computer has some serious problems, my iphoto only shows  only shows thumb size pics when I try to open them, i tried to rebuild my files from folders that had the pics in them. originally all the photos had a large delta with a question mark. also I can't back up the library file because its not there. I went to time machune and tried to find the file but I can't find it or I am looking in the wrong place. I also lost my Idvd file, only have broken chain showing.

    Details please
    What version of iPhoto and of the OS?
    i tried to rebuild my files from folders that had the pics in them.
    Exactly what did you do and how did you do it? this ay be the cause of your issue but without details we can n=ony guess
    my iphoto only shows  only shows thumb size pics when I try to open them,
    where do you see htis? In the iPhoto window? what does "try to pen them" exactly mean?
    originally all the photos had a large delta with a question mark.
    Ok - this usually has a simple solution - do you still have a copy of the library that has this problem?
    also I can't back up the library file because its not there.
    This makes no sense at all - all of your previous statements indicate that you do have an iPhoto library but have some problems with it
    By default your iPHoto library is located in your Pictures folder and is named iPhtoo library - if tha tis not the case the you have moved or renamed it and only you know what you did until you tell us the details
    I went to time machune and tried to find the file but I can't find it or I am looking in the wrong place.
    Again unless you actually share what and how you are doing thing but continue to simply state abstract problems it is no possible to assist you - details on using Time Machine are here  --  http://support.apple.com/kb/HT1427?viewlocale=en_US&locale=en_US   --     and   --    http://pondini.org/TM/FAQ.html   ---
    I also lost my Idvd file, only have broken chain showing.
    This would be better addressed in the iDVD forum - but again unlesss yu share detailed information no one can assist
    LN

  • Aim to process all files in folders on desktop to run through photoshop and save in multiple locations

    Aim to process all files in folders on desktop to run through photoshop and save in multiple locations
    Part one:-
    Gather information from desktop to get brand names and week numbers from the folders
    Excluding folders on desktop beginning with "2" or "Hot"
    Not sure about the list of folders
    but I have got this bit to work with
    set folderPath to "Hal 9000:Users:matthew:Desktop:DIVA_WK30_PSD" --<<this would be gained from the items on the desktop
    set {oldTID, my text item delimiters} to {my text item delimiters, ":"}
    set folderName to last text item of folderPath
    set my text item delimiters to "_WK"
    set FolderEndName to last text item of folderName
    set brandName to first text item of folderName
    set my text item delimiters to "_PSD"
    set weekNumber to first text item of FolderEndName
    set my text item delimiters to oldTID
    After running this I have enough information to create folders in multiple locations, (i need to know where they are so that photoshop can later save them in those multiple locations
    So I need the following folders created
    Locally
    Hal 9000:Users:matthew:Pictures:2011-2012:"WK" + weekNumber
    Hal 9000:Users:matthew:Pictures:2011-2012:"WK" + weekNumber: brandName
    Hal 9000:Users:matthew:Pictures:2011-2012:"WK" + weekNumber: brandName: brandName + "_WK" + weekNumber + "_LR" --(Set path for Later)PathA
    Hal 9000:Users:matthew:Pictures:2011-2012:"WK" + weekNumber: brandName: brandName + "_WK" + weekNumber + "_HR"--(Set path for Later)PathB
    Network
    Volumes:GEN:Brands:Zoom:Brands - Zoom:Upload Photos:2012:"Week" + weekNumber
    Volumes:GEN:Brands:Zoom:Brands - Zoom:Upload Photos:2012:"Week" + weekNumber:brandName + "_WK" + weekNumber + "_LR"  --(Set path for Later)PathC
    Volumes:GEN:Website_Images --(no need to create folder just set path)PathD
    FTP (Still as a normal Volume) So like another Network
    Volumes:impulse:"Week" + weekNumber
    Volumes:impulse:"Week" + weekNumber:Brand
    Volumes:impulse:"Week" + weekNumber:Brand:brandName + "_WK" + weekNumber + "_LR"  --(Set path for Later)PathE
    Volumes:impulse:"Week" + weekNumber:Brand:brandName + "_WK" + weekNumber + "_HR"  --(Set path for Later)PathF
    I like to think that is end of Part 1
    Part 2
    Take the images  (PSD's) from those folders relevant to the Brand then possibly run more applescript that opens flattens and then saves it in the locations above.
    For example….
    An image in folder DIVA_WK30_PSD will then run an applescript in Photoshop, lets call it DivaProcessImages within this we then save to PathA, PathB, PathC, PathD, PathE, PathF the folder path of C should therefore look like this
    Volumes:GEN:Brands:Zoom:Brands - Zoom:Upload Photos:2012:Week30:DIVA_WK30_LR and of course save the image as original filename.
    Then from the next folder
    An image in folder Free_WK30_PSD will then run an applescript in Photoshop, lets call it FreeProcessImages within this we then save to PathA, PathB, PathC, PathD, PathE, PathF the folder path of C should therefore look like this
    Volumes:GEN:Brands:Zoom:Brands - Zoom:Upload Photos:2012:Week30:Free_WK30_LR and of course save the image as original filename.
    The photoshop applescript i'm hoping will be easier as it should be a clearer step by step process without any if's and but's
    Now for the coffee!!

    Hi,
    MattJayC wrote:
    Now to the other part, where each folder was created (and those that already existed) how do I set them as varibles?
    For example,
    set localBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", localBrandFolder)
    This line was used to create more than one folder as it ran though the folders on the desktop. The next part is I will need to reference them to save files to them.
    You can use a records
    Examples
    if you want the path of localBrandFolder_High_Res  of "Diva", if "Diva" is the second folder of the Desktop
    You get the path with this : localBrandFolder_High_Res of record 2 of myRecords
    if you want the path of localWeekFolder  in the first folder of the Desktop
    You get the path with this : localWeekFolder of record 1 of myRecords
    Here is the script
    set myRecords to {}
    set dtF to paragraphs of (do shell script "ls -F ~/Desktop | grep '/' | cut -d'/' -f1")
    repeat with i from 1 to number of items in dtF
        set this_item to item i of dtF
        if this_item does not start with "2_" and this_item does not start with "Hot" then
            try
                set folderPath to this_item
                set {oldTID, my text item delimiters} to {my text item delimiters, ":"}
                set folderName to last text item of folderPath
                set my text item delimiters to "_WK"
                set FolderEndName to last text item of folderName
                set brandName to first text item of folderName
                set my text item delimiters to "_PSD"
                set weekNumber to first text item of FolderEndName
                set my text item delimiters to oldTID
            end try
            try
                set this_local_folder to "Hal 9000:Users:matthew:Pictures:2011-2012"
                set var1 to my getFolderPath("WK" & weekNumber, this_local_folder)
                set var2 to my getFolderPath(brandName, var1)
                set var3 to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", var2)
                set var4 to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", var2)
                --set up names to destination folders and create over Netwrok including an already exisiting folder
                set this_Network_folder to "DCKGEN:Brands:Zoom:Brand - Zoom:Upload Photos:2012:"
                set var5 to my getFolderPath("WK" & weekNumber, this_Network_folder)
                set var6 to my getFolderPath(brandName, var5)
                set var7 to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", var6)
                set website_images to "DCKGEN:Website_Images:"
                --set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
                set this_ftp_folder to "Impulse:"
                set var8 to my getFolderPath("Week" & weekNumber, this_ftp_folder)
                set var9 to my getFolderPath(brandName, var8)
                set var10 to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", var9)
                set var11 to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", var9)
                set end of myRecords to ¬
      {localWeekFolder:var1, localBrandFolder:var2, localBrandFolder_Low_Res:var3, localBrandFolder_High_Res:var4, networkWeekFolder:var5, networkBrandFolder:var6, networkBrandFolder_Low_Res:var7, ftpWeekFolder:var8, ftpBrandFolder:var9, ftpBrandFolder_Low_Res:var10, ftpBrandFolder_High_Res:var11}
            end try
        end if
    end repeat
    localBrandFolder_High_Res of record 2 of myRecords -- get full path of localBrandFolder_High_Res in the second folder of Desktop
    on getFolderPath(tName, folderPath)
        tell application "Finder" to tell folder folderPath
            if not (exists folder tName) then
                return (make new folder at it with properties {name:tName}) as string
            else
                return (folder tName) as string
            end if
        end tell
    end getFolderPath

  • HT1923 This article contains the only thing that worked for me.  I also had to sign out of iCloud and uninstall it.  Then I had to delete all files and folders from all of those applications that were under Program Files, Program Files x86, and Users.

    This article contains the only thing that worked for me.  I also had to sign out of iCloud and uninstall it.  Then I had to delete all files and folders from all of those applications that were under Program Files, Program Files x86, Program Data and Users.  My iPhone 4 will now sync with iTunes both in its USB-connected  mini dock and over Wi-Fi.  It's unfortunate (negligent programming on the part of Apple?) that the upgrade to iTunes 11 did not remove all of those files as part of the upgrade process. 

    I am having the same issue....Same address for years - same as USPS - I tried 5 times (3 macs and 2 iPhones) and now i have 5 CHARGES for 1.00 each on my credit card. I took the credit card info off so they don't charge me anymore. How can they charge me yet still not allow me to download free updates and say I have an invalid address? I'm sure I will spend weeks or months trying to get a credit out of these incompetent idiots.

  • Snow Leopard cannot read Files or Folders with Accents written by Windows 7

    I upgraded to snow leopard on launch date in the process of ripping all my music to ALAC in OSX.
    I brought it over to windows to encode it in the batch encoder in DV poweramp using Windows 7 RC1.
    When I tried to copy the files back to OSX it could not read any files or folders with an accent in their name if they were written by windows. It thought the folders were aliases and kept trying to figure out what was wrong and mp3s it just continually tried to load.
    It cannot read them on both FAT32 and NTFS partitions however plugging the FAT32 drive in a Vista computer it was perfectly able to read the files. Any ideas why this might be? I may try writing a file with an accent in the name via Vista later.

    Whats odd, accents aren't giving me a problem but a little square unicode character is.
    http://www.fileformat.info/info/unicode/char/25a0/index.htm
    That is sorta what it looks like, maybe a bit smaller, windows can't open folders with that in it.
    Mac chokes on your a accents e and all other varieties.

  • Spent some time trying to find a Safari download site with no success.  Where is the iMac Safari download site?

    Spent some time trying to find a Safari download site with no success.  I found lots of Safari sites but no Safari download site.  Where is the iMac Safari download site?

    (The following does not apply to users of Lion OS 10.7 or later)
    If your Safari keeps crashing, or if you are updating Safari (or just have) and it is misbehaving:
    N.B. Never delete Safari, never run it under Rosetta, don't use proxy settings, and don't change the application's name or move it from the top level of the Applications Folder to a sub-folder.
    (If you prefer to download updates via Software Update in the Apple menu (which would ensure that the correct version for your Mac was being downloaded), it is not recommended to allow SU to install major (or even minor) updates automatically. Set Software Update to just download the updater without immediately installing it. There is always the possibility that the combined download and install (which can be a lengthy process) might be interrupted by a power outage or your cat walking across the keyboard, and an interrupted install will almost certainly cause havoc. Once it is downloaded, you can install at a time that suits you. You should make a backup copy of the updater on a CD in case you ever need a reinstall. Alternatively you can download Safari directly:
    Safari 4.1.3 for Tiger can be downloaded here:
    http://support.apple.com/kb/DL1069
    Safari 5.0.6 for Leopard can be downloaded from here:
    http://support.apple.com/kb/DL1422
    Safari 5.1 for Snow Leopard can be downloaded from here:
    http://support.apple.com/kb/DL1070
    Make sure you download the correct version for your system.
    Also, observe the recommended procedure for installing software: repair permissions and close all applications, install, then repair permissions again.)
    Input Managers and other plug-ins from third parties can do as much harm as good. They use a security loophole to reach right into your applications' code and change that code as the application starts up.  If Safari is crashing, the very first thing to do is clear out your InputManagers folders (both in your own Library and in the top-level Library), log out and log back in, and try again.
    So, disable all third party add-ons before updating Safari, as they may not have been updated yet for the new version. Add them back one by one. If something goes awry, remove it again and check on the software manufacturer's website for news of an update to match your version of Safari. Remember: Tiger up to 10.4.10 used Safari 2.0.4, Tiger 10.4.11 uses Safari 4.1.3, Leopard uses Safari 5.0.6,  and Snow Leopard uses Safari 5.1.x. If these latest versions of Safari are not the fastest browser you have ever used, then something is wrong!
    (Trying to revert to a previous version of Safari  can have repercussions, as previous versions of Safari used a completely different webkit on which other applications like iChat, Mail, Dashboard Widgets etc also rely, but if you really want to do this post back for instructions on the safe way to do so.)
    Most errors reported here after an update are due to an unrepaired or undetected inherent fault in the system, and/or a third party ad-on. Add-ons that have been frequently mentioned here, among others, for causing such problems are Piclens, Saft, AcidSearch and Pithhelmet, and the dreaded CT Toolbar. If you have them, trash them, and go the developer's sites to see if new versions are available for the latest version of Safari on your current operating system.
    You must also ensure that you have downloaded and installed all the correct version for your Mac of Security Updates. These require a restart and a permission repair.
    To reiterate, Input Managers reach right into an application and alter its code. This puts the behavior of the affected application outside the control and responsibility of its developers: a recipe for  problems. That's not to say that issues absolutely will ensue as a result of Input Managers, but you, as a user, must decide. If the functionality of a specific Input Manager or set thereof is really important to you, you may well choose to assume the associated risk.
    Again, the advice is to remove all Input Managers from the following directories:
    Hard Disk/Library/InputManagers
    Home/Library/InputManagers
    especially prior to system updates and updates to Safari (they can always be added back one-by-one later).
    Lastly, the Safari updates require a restart of your Mac, and sometimes even a double restart is required.

  • How can I sort all files and folders by size?

    Due to lack of space I need to find the biggest files and folders on my Mac OSX Mountain Lion, but "Size" is not in the Find options.
    And I don't know the wildcard to sort all files and folders by size in Easyfind.
    Thanks
    Sarah

    There are applications out there which are designed to show you files and the space they use.  Some of these applications and some strategies for making more room on your disk are given below.
    Freeing Up Hard Disk Space
    Freeing space on your Mac OS X startup disk
    Clearing Disk Space on Your Mac
    Seven ways to free up drive space

  • I am trying to animate a file in photoshop with vanishing point. And when I "Return 3D layer to photoshop", I'll get a cube with dimensions. It´s not what I can see in tutorials, aperfect 3D space. Using win7.

    I am trying to animate a file in photoshop with vanishing point. And when I "Return 3D layer to photoshop", I'll get a cube with dimensions. It´s not what I can see in tutorials, a perfect 3D space. Using win7.

    An update -
    The libraries appear to all be in tact, now.
    The error I am getting,
    Parms are; 800/S80/5069660
    ERROR -  detected an exception: Unexpected database connector error
    is a connection issue.
    Any ideas??

  • MS word keeps crashing on my macbook air. it tries to recover all files when I try to open it then immediately crashes or freezes. It's ms word 2011 and I'm running OS X 10.7.5

    MS word keeps crashing on my macbook air. it tries to recover all files when I try to open it then immediately crashes or freezes. It's ms word 2011 and I'm running OS X 10.7.5

    I am having the same problem. When I save a document in word, particularly with track changes and comments, it freezes and crashes. I fould this forum as I was reading help posted in a previous forum and the "helping" comments were saying this must be a problem on the user end - but that can't be right as so many people are posting this problem. Its clearly an incompatibility between the software from two competing companies. Figure it out Apple!

  • Contribute tries to open all file types

    Contribute 3 tries to open all file types, in addition to the
    designated application. You click on "file.doc" and contribute AND
    word try to open the file. You have to cancel the open process for
    contribute at least three times to make it go away. Then the file
    open as usual in word. I have checked the preferences and removed
    all "MS Office" file types from the dialog. I have checked the
    folder options and verified that Contribute is NOT the assigned
    application in Windows to open the file.
    Help this is very annoying!
    PaulW

    I'm glad to know there are other people out there with the
    same problem... but has anyone found a solution yet?

  • The specified file or folder name is too long,the url path for all files and folders

    The specified file or folder name is too long,the url path for all files and folders must be 260 character or less
    can we increase this limit?
    MCTS,ITIL

    Hi,
    As I understand, you want to increase the length of URL path in SharePoint 2010.
    Per my knowledge, this limit cannot be increased. SharePoint limits URL length because all relative URL links are stored in the clear forms on the SharePoint content DB and often this links are used as primary keys to link one table with another. Fields
    which are used to store these links (for instance tp_DirName from the AllUserData table) allow storing only 256 characters.
    There are several ways that you can resolve or mitigate URL length problems in the SharePoint Server 2010 environment. The following list provides suggestions:
    1. Upgrade all the end-user browsers to Internet Explorer 8, which has a longer URL length limit.
    2. Use shorter names for sites, folders, and documents and control the depth of the site and folder structures to reduce the lengths of URLs.
    3. If possible or allowed, use ASCII names for sites, folders, and documents. This will avoid situations where the URL will be lengthened by being encoded.
    4. To reduce the risk that the SharePoint Server 2010 end-users will encounter problems because of URL length limitations, we recommend that you apply the following effective limits in the deployment:
    256 Unicode (UTF-16) Code units - the effective file path length limitation, including a domain/server name
    128 Unicode (UTF-16) Code units - the path component length limitation
    More reference:
    http://technet.microsoft.com/en-us/library/ff919564(v=office.14).aspx
    http://sharepointknowledgebase.blogspot.in/2013/04/url-path-length-restrictions-in.html#.VKJN53BJA
    Best regards,
    Sara Fan

  • Trying to find a file that is not showing up on Computer!!!

    I am trying to delete a file that i found on cleanmymac. I am trying to find the file on my computer, but it doesnt work!!! On CleanMyMac it even says the location of where the file is, But i cant find it!!!!

    If the file is in your user Library, it's hidden by default in Mountain Lion.  You can reach it on the Finder's menubar, Finder > Go > Hold the Option key down > Select Library.
    Make sure you know what the file is before you delete it.

  • Lost all files and folders on the desktop and also in time machine

    All files and folders on the desktop disappeared, I checked time machine and even there are no longer present, even going back months.
    How is it possible?

    After update osx yosemite 10.10.1

Maybe you are looking for