Kai,

I'm copying this to the microsoft.public.windows.powershell newsgroup
to see if someone there can offer you an answer.

Since this post is going to both newsgroups, hopefully you can access
the answer via Google groups.

Andrew Watt MVP

On 10 Aug 2006 03:29:47 -0700, "Kai Iske" <kai.iske@web.de> wrote:

>Hi Andrew,
>
>funny thing is, when I use your sample (wildcarding), sorting is OK.
>However, when you issue a simple get-childitem on the shell,
>directories will come out last in the list, at least for me.
>
>Thanks for the pointer to the new newsgroup. However I'm browsing
>through google groups as I don't have direct access to news:// through
>our corporate firewall and google groups doesn't have the newsgroup
>indexed, yet.
>
>Kai
>
>Andrew Watt [MVP] wrote:
>> Hi Kai,
>>
>> I'm using PowerShell RC1 too.
>>
>> If I type
>>
>> get-childitem s*
>>
>> in a folder where I have folders and files beginning with s I get what
>> you want by default.
>>
>> I'm not sure why you are seeing a different sort order. Maybe somebody
>> else knows a reason for that difference.
>>
>> BTW most PowerShell discussion is now on the
>> microsoft.public.windows.powershell newsgroup. If nobody else dives in
>> to this thread here you might be better asking your question again
>> over there.
>>
>> Andrew Watt MVP
>>
>> On 9 Aug 2006 15:06:23 -0700, "Kai Iske" <kai.iske@web.de> wrote:
>>
>> >Andrew, sorry for not making that clear.
>> >
>> >The RC1 that I am running shows the files first and then directories. I
>> >want to have directories first followed by files. Within each of the
>> >two possible groups, I want to have the sorting based on name.
>> >
>> >Thus I sort by PSIsContainer (Could sort by Type as well) descending to
>> >get the directories on top and then I sort by Name ascending.
>> >
>> >Thanks for your help
>> >
>> >Kai
>> >
>> >Andrew Watt [MVP] wrote:
>> >> I am unclear as to what you're trying to do.
>> >>
>> >> The sort order that you create seems to me to *be* the default sort
>> >> order.
>> >>
>> >> Can you explain again what your objective is?
>> >>
>> >> Thanks
>> >>
>> >> Andrew Watt MVP
>> >>
>> >> On 9 Aug 2006 13:05:32 -0700, "Kai Iske" <kai.iske@web.de> wrote:
>> >>
>> >> >Hi,
>> >> >
>> >> >I'm rather new to PSH, but I wanted to change the default sort order of
>> >> >get-childitem to show containers first and then sort by name. So I
>> >> >thought I'd simply set up a function like
>> >> >
>> >> >function Get-ChilditemExt
>> >> >{
>> >> > Get-ChildItem $args | Sort-Object
>> >> >@{Expression="PSIsContainer";Descending=$true},@{Expression="Name";Ascending=$true}
>> >> >}
>> >> >
>> >> >And change the alias of dir to be using
>> >> >
>> >> >Set-Alias -name dir -value Get-ChildItemExt -option AllScope
>> >> >
>> >> >This works pretty OK unless I try to pass in arguments to Get-ChildItem
>> >> >(-recurse for example). In this case the cmdlet attempts to get items
>> >> >of the folder "-recurse".
>> >> >
>> >> >Is there any easy / other way to accomplish what I wand?
>> >> >
>> >> >Thanks in advance
>> >> >
>> >> >Regards
>> >> >
>> >> >Kai