Inconsistency between get-childitem -include and -exclude parameters

Hi,
Powershell 2.0
Does anyone else consider this a minor design bug in the Get-ChildItem command?  
# create dummy files
"a","b","c" | % {$null | out-file "c:\temp\$_.txt"}
# this "fails", returns nothing
get-childitem c:\temp -include a*,b*
# this "works", returns desired files
get-childitem c:\temp\* -include a*,b*
# this "works", excludes undesired files
get-childitem c:\temp -exclude a*,b*
# this "fails", excludes undesired files BUT RECURSES sub-directories
get-childitem c:\temp\* -exclude a*,b*
I'm writing a wrapper script around the GCI cmdlet, but the inconsistency between the two parameters is problematic.  My end user will surely just type a path for the path parameter, then wonder why -include returned nothing.  I can't unconditionally
add an asterisk to the path parameter, since that messes up the exclude output.
I'm just wondering why Microsoft didn't make the parameter interaction consistent???  
# includes desired files in the specified path
get-childitem -path c:\temp -include a*,b*
# excludes undesired files in the specified path
get-childitem -path c:\temp -exclude a*,b*
# combine both options
get-childitem -path c:\temp -include a*,b* -exclude *.log,*.tmp
# same as above, the asterisk doesn't matter
get-childitem -path c:\temp\* -include a*,b*
get-childitem -path c:\temp\* -exclude a*,b*
get-childitem -path c:\temp\* -include a*,b* -exclude *.log,*.tmp
# same as above, but explicitly recurse if that's what you want
get-childitem -path c:\temp\* -include a*,b* -recurse
get-childitem -path c:\temp\* -exclude a*,b* -recurse
get-childitem -path c:\temp\* -include a*,b* -exclude *.log,*tmp -recurse
If I execute the "naked" get-childitem command, the asterisk doesn't matter...
# same results
get-childitem c:\temp
get-chileitem c:\temp\*
If this isn't considered a bug, can you explain why the inconsistency between the two parameters when combined with the -path parameter?
Thanks,
Scott

The Get-ChildItem cmdlet syntax is horrific for advanced use. It's not a bug in the classic sense, so you shouldn't call it that. However, feel free to call it awful, ugly, disastrous, or any other deprecatory adjective you like - it really is
nasty.
Get-ChildItem's unusual behavior is rooted in one of the more 'intense' dialogues between developers and users in the beta period. Here's how I recall it working out; some details are a bit fuzzy for me at this point.
Get-ChildItem's original design was as a tool for enumerating items in a namespace -
similar to but not equivalent to dir and
ls. The syntax and usage was going to conform to standard PowerShell (Monad at the time) guidelines.
In a nutshell, what this means is that the Path parameter would have truly just meant Path - it would not have been usable as a combination path specification and result filter, which it is now. In other words
(1) dir c:\temp
means you wanted to return children of the container c:\temp
(2) dir c:\temp\*
means you wanted to return children of all containers inside
c:\temp. With (2), you would never get c:\tmp\a.txt returned, since a.txt is not a container.
There are reasons that this was a good idea. The parameter names and filtering behavior was consistent with the evolving PowerShell design standards, and best of all the tool would be straightforward to stub in for use by namespace
providers consistently.
However, this produced a lot of heated discussion. A rational, orthogonal tool would not allow the convenience we get with the dir command for doing things like this:
(3) dir c:\tmp\a*.txt
Possibly more important was the "crash" factor.  It's so instinctive for admins to do things like (3) that our fingers do the typing when we list directories, and the instant failure or worse, weird, dissonant output we would get with a more pure Path
parameter is exactly like slamming into a brick wall.
At this point, I get a little fuzzy about the details, but I believe the Get-ChildItem syntax was settled on as a compromise that wouldn't derail people expecting files when they do (3), but would still allow more complex use.  I think that this
is done essentially by treating all files as though they are containers for themselves. This saves a lot of pain in basic use, but introduces other pain for advanced use.
This may shed some light on why the tool is a bit twisted, but it doesn't do a lot to help with your particular wrapping problem. You'll almost certainly need to do some more complicated things in attempting to wrap up Get-ChildItem. Can you describe some
details of what your intent is with the wrapper? What kind of searches by what kind of users, maybe? With those details, it's likely people can point out some specific approaches that can give more consistent results.

Similar Messages

  • During MRP run unwanted plant and storage location include and exclude

    Hi There,
    During MRP run how to include and exclude the unwanted plant and storage location pls let me know the required configuration settings.
    Thanks in advance.

    HI,
    To control whether a particular storage location will be included or excluded from the MRP run.  (MD02/MD41).
    To exclude it from MRP run :-
    OMIR - Define storage location MRP per plant
    Put the MRP ind. as.         1 - storage location stock excluded for MRP
    To include it from MRP run:-
    OMIR - Define storage location MRP per plant
    Put the MRP ind. as.      space - storage location stock also planned at plant level and save it
    Next go to transaction MM01 - tick only view MRP 2
    Key in Plant and Storage Location
    Look at the Storage Location MRP section
    change the SLoc MRP indicator to space  and save it
    MMD1 - Create MRP Profile - MRP profile is a useful entry aid and makes it easier to manage MRP data.
    You define which fields are filled with values when MRP data is entered in the material master record, which of these values can be overwritten and which not.   You use the information stored in a profile is standard information that is needed again and again in similar constellations when material master records are maintained.
    Regards
    KK

  • Cannot Include and exclude selectiion on hierarchy node in the Filter area

    Hi,
    When i open the query and execute it. and select the filter area for hierarchy nodes. The include and exclude selection is disabled in 3.5x analyzer. We are using BI 7.0 with SP 12. we just upgraded.
    Can you please help. is this functionality not available?
    Regards,
    Gaurav

    Hi Rob, you can do that for the query (the exclude selection) on the Query Designer. But its not recomended on performance point of view.
    hope this helps
    Natalia.

  • Inconsistency between a document field and the prof. segment number

    Hi,
    While processing an invoice in one company code for vendor# XXX with the PO# AAAA line# 10, it is showing below error message while posting. Please advise on the below error or fix the issue to post the invoice in to SAP. The using screen T-code is miro.
    Inconsistency between a document field and the prof. segment number
    *Message no. KE396
    *Diagnosis
    A line item was assigned to a profitability segment (number 0008629207) which has the value 0000101000 for characteristic Profit Center. The original document (FI document, sales order, internal order, etc.), however, contains 0000102020 in this field. It is therefore inconsistent with the profitability segment found.
    System response
    The characteristics in Profitability Analysis (CO-PA) must have the same characteristic values as the original document. For example, you cannot assign a sales order to a different customer or product than the one contained in the original sales order. If you wish to fill the characteristics with different contents, you must change the original fields.
    Procedure
    Enter the correct characteristic values on the CO-PA assignment screen. The system will automatically assign a corresponding profitability segment number. If it is not possible to enter values in some of these fields, delete the entire assignment to a profitability segment number and then enter it again.
    As a rule, you should first enter the fields in the original sender document and then make the assignment to a profitability segment.
    What should I do for the above pl ?
    Regards
    Murali

    Hi,
    While doing PGR at VL32N, we are facing this error. Can someone assist.
    Regards,
    Aruna

  • Difference between GET pernr LATE and GET pernr LAST?

    Hi all,
    does anyone know the difference between GET PERNR LATE and GET PERNR LAST?
    Regards
    Mart

    hi,
    Please refer to this link:
    [http://help.sap.com/saphelp_nw70/helpdata/en/9f/db9abd35c111d1829f0000e829fbfe/frameset.htm]
    Hope this will Help.
    reward if useful.
    Sumit Agarwal

  • How to include and exclude external infoobject values in a hierarchy

    Hello experts,
    I'm working with hierarchies and the problem I have is that I don´t know how to include nor exclude a value in the definition of the hierarchy.
    For example, I want to show in a query some cost elements related to some functional areas, so I've created a hierarchy for md funcional area. But I don't want to show every cost element related to one functional area but only some of them. I've defined 0costelmnt as a external characteristic for 0func_area infoobject so that I can specify in the hierarchy the cost elements I want to show. But it doesn´t work, in the report all cost elements are showed. How can I specify the ones I want to show?
    thank you very much.

    Any ideas please?

  • Regular Expressions, include and exclude xml-files

    Hi!
    I have a javaprogram that should read xml-files from a directory. The program could contain several types of files but it should only read files with a certain pattern.
    The file names will look like this:
    "resultset_27_23.xml"
    where the numbers will change, but the rest of the file name is the same (resultset_XX_XX.xml).
    But in the same directory it will also be files with the following pattern:
    "resultset_27_23_attachment1.xml"
    Here, the numbers could change in the in the same way as the files above, and the number after the text (attachment) could also differ from file to file.Those files should not be read by the program.
    I have tried to write a regular expression pattern that only reads the first file types, and exlcudes the other ones, but it won�t work.
    Does anyone have a solution to my problem? It is possible to use either just one pattern, or two patterns; one for the files that should be included, and one for the files that should be excluded.

    So you only want files that match resultset_XX_XX.xml? Will the numbers always be two digits each? Assuming so:
    "^resultset_\\d\\d_\\d\\d.xml$"Depending which methods you use, the ^ and $ may or may not be necessary.
    If that's not what you meant, please clarify.

  • Duplicity: include and exclude files

    I think I'm missing something about duplicity's include/exclude mechanism.
    1) This might be obvious but still... Where is the difference whether I use --exclude-filelist or --include-filelist? A dry-run showed the exact same size for my backup.
    2) Using --exclude-globbing-filelist and these lines will not backup any txt files:
    + /home/m/exclude/*.txt
    - /home/m/exclude/
    Yet, these lines will backup arch.txt:
    + /home/m/exclude/arch.txt
    - /home/m/exclude/
    Shouldn't "*.txt" expand to "arch.txt"?

    Hi yehiel,
    1. It is clear that the normal sql statement
       won't work in the way we won't.
    2. Thats why, some extra logic needs to be applied.
       As already mentioned,
       The RANGE for EXCLUDE
       must be filled with some DUMMY Data.
      Just write this CODE
      JUST BEFORE CALLING THE SQL.
    IF z_stat_eIS INITIAL.
      z_stat_e-sign = 'I'.
      z_stat_e-option = 'EQ'.
      z_stat_e-low  = 'XXX'.
      z_stat_e-high = 'XXX'.
      APPEND z_stat_e.
    ENDIF.
    HOPE THIS WORKS.
    Regards,
    Amit M.

  • System error: Inconsistency between Credit/debit indicator and amounts

    Hi All,
    I am getting this error as while trying to release a billing document to accounting. The Message no. is  F5693
    Please help!
    Thanks,
    Anupriya

    Dear Kaushik,
    System is triggering this error from following includes.
    LFACIF4T
    LFACIF4Z
    IF ACCCR_FI-WRBTR LT 0
      OR ACCCR_FI-SKFBT LT 0
    OR ACCCR_FI-BUALT LT 0
      OR ACCCR_FI-WSKTO LT 0
      OR ACCCR_FI-KZBTR LT 0
      OR ACCCR_FI-QSFBT LT 0
      OR ACCCR_FI-QSSHB LT 0
      OR ACCCR_FI-WMWST LT 0
      OR ACCCR_FI-GBETR LT 0.
    check whether any of the above field value is less than 0.
    Thanks & Regards,
    Hegal K Charles

  • Include and exclude status

    i need to take all the status of "objnr" but  there are status that i dont want to see exclude
    this is the select that take all the status
    select-option: z_stat_i FOR jest-stat,
                    z_stat_e FOR jest-stat.
    SELECT   stat
        FROM   jest
        INTO mdstat-zs_stat
        WHERE objnr = mdeqp-objnr
        AND   stat  IN z_stat_i
        AND   inact = ' '.
          APPEND  mdstat.
    any ideas?
    thanks

    Hi yehiel,
    1. It is clear that the normal sql statement
       won't work in the way we won't.
    2. Thats why, some extra logic needs to be applied.
       As already mentioned,
       The RANGE for EXCLUDE
       must be filled with some DUMMY Data.
      Just write this CODE
      JUST BEFORE CALLING THE SQL.
    IF z_stat_eIS INITIAL.
      z_stat_e-sign = 'I'.
      z_stat_e-option = 'EQ'.
      z_stat_e-low  = 'XXX'.
      z_stat_e-high = 'XXX'.
      APPEND z_stat_e.
    ENDIF.
    HOPE THIS WORKS.
    Regards,
    Amit M.

  • Inconsistency between capacity online check and CM01/CM02

    Hi All,
    Please help.
    During production order creation (change) capacity availability check online results differ from results in CM01/CM02.
    I've already used capacity basic load report RCCYLOAD and created basic load.
    For the evaluation (CM01/02)  i use overall profile SAPSFC010 (work center basic load). For capacity availability check online- profile recommended by SAP- SAPSFCG013 (SFC:Capacity availability check >= 3.0D).
    Don't know what could it be.
    Thanks,
    Regards, Andrey

    Error found in Capacity leveling profile.

  • Difference between MRP group and plant parameters

    hai friends,
    please let me know, what is the main difference between the MRP group and plant parameters?,
    what are the extra activities or features with one, when compare to the other?.
    Edited by: Mourya.v on Sep 22, 2010 6:36 AM

    Dear Mourya,
    Why to assign MRP group? - If planning for each plant is not specific enough for your purposes and you would like to assign
    control parameters that differ from the control parameters defined for the plant to certain material groups.
    1.For all materials without an MRP group, the system uses the plant parameters that is the settings present in OPPQ, or the
    entries in the initial screen of the planning run.
    2.For all materials with an MRP group, the system uses the parameters recorded in the MRP group that is the settings in OPPR.
    3.The MRP group is an organizational object that can be used to allocate special control parameters for planning to a group of
    materials. You can maintain MRP groups if planning control per plant is not precise enough for your requirements and you want
    to allocate certain material groups different control parameters from the plant parameters. For this purpose, MRP groups are
    defined with these specific control parameters and are assigned to the material in the material master record (MRP 1 screen).
    4.The MRP group, groups material from the material requirements planning point of view to allocate them control parameters for
    planning.The control parameters include the strategy group, the planning horizon and the creation indicator for the planning run.
    Also check this link [Settings in OPPQ & OPPR|oppr and oppq]
    Regards
    Mangalraj.S

  • Package comments and excluded files

    I have an ant target to generate javadoc for a whole package structure minus one sub-package and one class, plus a few classes from another package:
      <target name="doc">
        <mkdir dir="${build}/docs/api"/>
        <javadoc destdir="${build}/docs/api/"
          use="true"
          windowtitle="Public API">
          <classpath>
            <path refid="3rdparty.jar.path"/>
          </classpath>
          <fileset dir="${build}">
            <include name="com/company/pkg1/**"/>
            <exclude name="com/company/pkg1/util/**"/>
            <exclude name="com/company/pkg1/server/ServiceMBean.java"/>
            <include name="com/company/pkg2/CustomerReport.java"/>
            <include name="com/company/pkg2/DeprecatedReport.java"/>
            <include name="com/company/pkg2/Report.java"/>
            <include name="com/company/pkg2/TagReport.java"/>
          </fileset>
        </javadoc>
      </target>This worked fine until I started including package.html files for package documentation. Running this with package.html in com/company/pkg1 gives the following error:
    javadoc: Illegal package name: "C:\abc\def\com\company\pkg1\package.html"
    After playing around, I found that if I shift the 3 <include> and <exclude> lines referring to pkg1 out of the <fileset> tag and into a <packageset> tag, then the package comments work. However, then the exclude for the individual java class (ServiceMBean.java) does not work. Likewise, shifting the file exclude back to the fileset tag still does not exclude it.
    It seems that I must decide whether to have package comments or the ability to exclude individual files, but not both. Is there any way around this?

    Well, it is a known issue. And actually, issue is with DBMS_METADATA, not with DATAPUMP, which simply uses DBMS_METADATA:
    SQL> create or replace package
      2  --comment
      3  MyPkg
      4  is
      5  a number;
      6  end;
      7  /
    Package created.
    SQL> select text from user_source where name = 'MYPKG' order by line;
    TEXT
    package
    --comment
    MyPkg
    is
    a number;
    end;
    6 rows selected.
    SQL> select dbms_metadata.get_ddl('PACKAGE','MYPKG') from dual;
    DBMS_METADATA.GET_DDL('PACKAGE','MYPKG')
      CREATE OR REPLACE PACKAGE "SCOTT"."MYPKG"
    is
    a number;
    end;
    SQL> You should put comments after package name:
    SQL> create or replace package
      2  MyPkg
      3  --comment
      4  is
      5  a number;
      6  end;
      7  /
    Package created.
    SQL> select dbms_metadata.get_ddl('PACKAGE','MYPKG') from dual;
    DBMS_METADATA.GET_DDL('PACKAGE','MYPKG')
      CREATE OR REPLACE PACKAGE "SCOTT"."MYPKG"
    --comment
    is
    a number;
    end;
    SQL> SY.

  • Difference between "return this.var" and only  "return var"

    What is the difference between
    get()
    return variable;
    and
    get()
    return this.variable;
    }

    class Foo {
      int bar = 0;
      public int doStuff(int bar) {
        bar *= 2;   //refers to the parameter bar
        return bar; //also refers to the parameter bar
      public int doStuffToo(int bar) {
        bar *= 2;          //refers to the parameter bar
        return this.bar; //refers to the instance variable bar declared above
      public static void main(String[] args) {
        Foo f = new Foo();
        System.out.println(f.doStuff(5));      //outputs 10
        System.out.println(f.doStuffToo(5)); //outputs 0
    }

  • LabVIEW Touch Panel -- I can not get activesync to connect between the TPC-2012 and my XP workstation. There is no USB client connection on TPC-2012

    How do I get the TPC-2012 to connect to my workstation?  I have read all the hardware manuals, getting started manuals: nothing works.  The remote access using http://x.x.x.x/RemoteAdmin does not work.  I have tried to get the FTP service working using the instructions in "How do I configure the FTP server on tpc-2006 and TPC-2016" .  Active sync seems to want a USB connection only.  I have tried to connect a serial line between com1 on the TPC and com4 on my XP workstation with no results.
    I have been able to use the touch panel module with my iPAQ. It worked flawlessly the first time.  
    Help!
    Louis Prugh
    General Dynamics

    Hi David,
    thank you once again for your help.
    So when viewing your Local Area Connection>>Status
    you're seeing data packets sent but no packets received on your desktop
    machine? - Yes
    Is your desktop configured with a static IP address or is it
    configured to obtain an IP address automatically?I' ve tried both static IP address and that it obtain IP address automatically, I have also done it with the TPC.
    Also, does your TPC
    get a valid IP address when the connection to your desktop is present? - when TPC is set to obtain adress automatically it gets IP address and then after some time it loses it - it is set to 0.0.0.0, and then it obtains the IP adress again and so on.
    Can you provide the address, subnet, and gateway you're getting for
    both machines?- I've done it, but it didn'e help
    Also any firewall settings or exceptions you may have
    active if the firewall is enabled? - firewall is disabled
    I'd also like to know what
    modules and toolkits you do have installed on both the TPC - TPC is new and I haven't installed there anything.
    On my desktop - I have standard Labview 8.2,the real time module is installed. All I know, there are already drivers for TPC2012 in this LabView version. On the included CD I have only drivers for another TPCs.
    Thanks,
    Martin

Maybe you are looking for

  • Error while doing commint from RFC Adapter

    Hi, We have a SOAP-PI-RFC synchronous scenario. Through this Soap request comes to PI and passed on to BAPI via RFC adapter. This BAPI saves the transaction & return the document number. We are using " PI PI parameter u201CCommit Handling for single

  • Very slow boot on MacBook with Mountain Lion

    My MacBook Pro  Core i7 2.7 Ghz and OS X 10.8.4 has been experienced very slow boots, I've tried several things that I read here and there, here I post the console log, PLEASE HELP!!! 18/07/13 21:14:55.000 bootlog[0]: BOOT_TIME 1374200095 0 18/07/13

  • 3.2 - CPU usage high

    Ocaasionally SQL Developer comes in a state where CPU usage is 50% (on a dual core machine) and according to jvisualvm "Background Parser" and InsightThread is using the CPU, and only these two. This continues also after closing all connections. I do

  • Remove serial number profile

    I would like to remove a serial number profile in the material master for a material that does is no longer handled as serialized. During trying to remove the serial number profile in the respecitve material a system-error message occurs telling "Ser

  • I lost all my contact and didnt backup my iphone 4s. Is there anyway i can retrieve them?

    I lost my contacts and there were not backup to my computer, is there any wat to retrieve them? thank you