Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8295845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:45:02+00:00 2026-06-08T14:45:02+00:00

this will sound like a bad joke, but apparently geniuses from MS arent capable

  • 0

this will sound like a bad joke, but apparently geniuses from MS arent capable of making uber complicated -exclude gci parameter work. By “genious” design it only works on files, not on entire path. So how to make it work.
For example how to exclude all files whose path contains “Windows” substring?
naive
gci -exclude "*Windows*" -rec
doesnt work

EDIT: googled/figured out this:

 | where {$_.DirectoryName -notmatch ".*abcdef.*" }

If somebody knows better solution please share. If not will close question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T14:45:10+00:00Added an answer on June 8, 2026 at 2:45 pm

    The solution is this:

     gci ./ |Where{ $_.PSPath -notmatch ".*Windows.*"}
    

    BTW useful thing for guessing solutions to problems like this is to know what methods the current object has, for that I used Get-Member. Example output:

    PS C:\Users\jh> gci ./ | Get-Member
    
    
           TypeName: System.IO.DirectoryInfo
    
        Name                      MemberType     Definition
        ----                      ----------     ----------
        Mode                      CodeProperty   System.String Mode{get=Mode;}
        Create                    Method         void Create(), void Create(System.Security.AccessControl.DirectorySecurity ...
        CreateObjRef              Method         System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
        CreateSubdirectory        Method         System.IO.DirectoryInfo CreateSubdirectory(string path), System.IO.Director...
        Delete                    Method         void Delete(), void Delete(bool recursive)
        EnumerateDirectories      Method         System.Collections.Generic.IEnumerable[System.IO.DirectoryInfo] EnumerateDi...
        EnumerateFiles            Method         System.Collections.Generic.IEnumerable[System.IO.FileInfo] EnumerateFiles()...
        EnumerateFileSystemInfos  Method         System.Collections.Generic.IEnumerable[System.IO.FileSystemInfo] EnumerateF...
        Equals                    Method         bool Equals(System.Object obj)
        GetAccessControl          Method         System.Security.AccessControl.DirectorySecurity GetAccessControl(), System....
        GetDirectories            Method         System.IO.DirectoryInfo[] GetDirectories(), System.IO.DirectoryInfo[] GetDi...
        GetFiles                  Method         System.IO.FileInfo[] GetFiles(string searchPattern), System.IO.FileInfo[] G...
        GetFileSystemInfos        Method         System.IO.FileSystemInfo[] GetFileSystemInfos(string searchPattern), System...
        GetHashCode               Method         int GetHashCode()
        GetLifetimeService        Method         System.Object GetLifetimeService()
        GetObjectData             Method         void GetObjectData(System.Runtime.Serialization.SerializationInfo info, Sys...
        GetType                   Method         type GetType()
        InitializeLifetimeService Method         System.Object InitializeLifetimeService()
        MoveTo                    Method         void MoveTo(string destDirName)
        Refresh                   Method         void Refresh()
        SetAccessControl          Method         void SetAccessControl(System.Security.AccessControl.DirectorySecurity direc...
        ToString                  Method         string ToString()
        PSChildName               NoteProperty   System.String PSChildName=Contacts
        PSDrive                   NoteProperty   System.Management.Automation.PSDriveInfo PSDrive=C
        PSIsContainer             NoteProperty   System.Boolean PSIsContainer=True
        PSParentPath              NoteProperty   System.String PSParentPath=Microsoft.PowerShell.Core\FileSystem::C:\Users\jh
        PSPath                    NoteProperty   System.String PSPath=Microsoft.PowerShell.Core\FileSystem::C:\Users\jh\Cont...
        PSProvider                NoteProperty   System.Management.Automation.ProviderInfo PSProvider=Microsoft.PowerShell.C...
        Attributes                Property       System.IO.FileAttributes Attributes {get;set;}
        CreationTime              Property       datetime CreationTime {get;set;}
        CreationTimeUtc           Property       datetime CreationTimeUtc {get;set;}
        Exists                    Property       bool Exists {get;}
        Extension                 Property       string Extension {get;}
        FullName                  Property       string FullName {get;}
        LastAccessTime            Property       datetime LastAccessTime {get;set;}
        LastAccessTimeUtc         Property       datetime LastAccessTimeUtc {get;set;}
        LastWriteTime             Property       datetime LastWriteTime {get;set;}
        LastWriteTimeUtc          Property       datetime LastWriteTimeUtc {get;set;}
        Name                      Property       string Name {get;}
        Parent                    Property       System.IO.DirectoryInfo Parent {get;}
        Root                      Property       System.IO.DirectoryInfo Root {get;}
        BaseName                  ScriptProperty System.Object BaseName {get=$this.Name;}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question will sound like a newbie but i have gone through all threads
I guess this question will sound familiar, but I am yet another programmer baffled
This will sound silly, but trust me it is for a good (i.e. over-engineered)
I know this will sound odd but stay with me on this. I am
Yes, this might sound like a newbie question but there's a TWIST! ( And
This might sound like a stupid question, but google didn't help me. Is there
Sorry if this question will sound too chaotic, feel free to edit it. I
I don't know much about web development, so probably this question will sound exceptionally
This will probably be obvious but I can't find the best way. I want
This will be probable quite odd question. But i thought I will give it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.