Is it possible to use Comobject Browseforfolder and filter content for output in Powershell?

    General discussion

  • Hi,

    I'm using the comobject shell.application to browse a folder.

    The folder to browse has old and new content and I was wondering if can filter the output to only show the new content.

    New content is recognizable by all subfolder that begin with 'companyname_' where companyname is the name of the company, old folders don't have the '_' after 'Companyname'.

    $object = new-object -comobject shell.application
    $FolderBrowser = $object.BrowseForFolder(0,"Rootfolder location",808,$Sourcefolder)

    Where $sourcefolder is the path to the folder.

    Would be a great help if this is possible, the source folder has a lot of content that cannot be moved or copied.

    • Changed type Bill_Stewart Friday, April 28, 2017 8:04 PM
    • Moved by Bill_Stewart Friday, April 28, 2017 8:04 PM This is not "research solution for me" forum
    Friday, March 17, 2017 9:57 AM

All replies

  • Here is how you can research this:

    Type in BrowseForFolder into a search engine.

    Look at the results and see if there is anything about preventing it from listing certain folders based on an arbitrary criteria.

    -- Bill Stewart [Bill_Stewart]

    Friday, March 17, 2017 4:02 PM
  • You can do it like this:

    Get-ChildItem *.txt -Include '*_' |


    • Edited by jrv Friday, March 17, 2017 8:30 PM
    Friday, March 17, 2017 8:28 PM
  • You can also do this:

    Get-ChildItem | ?{$_.DirectoryName -match '_'} | Out-GridView


    Friday, March 17, 2017 8:32 PM