Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command similar to "ls -lart" (UNIX) in Powershell

Status
Not open for further replies.

nvhuser

Programmer
Apr 10, 2015
48
DE


Hello,

I am looking for the analogous command of "ls -lart" in Powershell.
Anybody knows? By the way, if I am using MSDOS, the analogous command of "ls " is "dir ", so how we can do "ls -lart" in MSDOS? Thank you
 
ls works in PowerShell. It is an alias for Get-ChildItem just like dir is as well.

What does -lart do?

I suspect what you are looking for is

Code:
Get-ChildItem -Recursive | Sort LastWriteTime
 
Hello markdmac,

sorry, but the attribute "Lastwritetime" does not exist (at least, in my Windows powershell).
Making "man sort", I get the following attributes available for "sort" command:

Sort-Object [[-property] <Object[]>] [-inputObject <psobject>] [-culture <string>] [-caseSensitive] [-unique] [-des
cending] [<CommonParameters>]

Also, "recursive" is not available, but "recurse", is it what you meant, right?

Code:
Get-ChildItem -Recurse | sort

Thank you
 
My apologies, yes I meant Recurse.

Code:
Get-ChildItem -Recurse | Sort LastWriteTime

I'd recommend that you upgrade your version of PowerShell to version 4. When I execute the above command this is my output:

[pre] Directory: C:\Users\b121700\Desktop\Scripts


Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 5/6/2015 2:12 PM 4877 DecomStage2.ps1
-a--- 5/6/2015 2:55 PM 3641 DecomStage1.ps1[/pre]

As you can see, the LastWriteTime property does exist.




I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at
Work SMARTER not HARDER.
 
Thank you for your reply Mark,

Yes, I believed you, the command "LastWriteTime" exists, but it is not available in the version v1.0.
I talked with the administrator and he told me that is not possible to install another version.

So, any ideas how to do it in version 1.0 of Powershell?
Thank you in advance.
 
Wow, you are many versions behind. Is your admin claiming there are technical reasons they cannot upgrade or compatibility issues with other programs?

Can you execute the commands from another computer that is upgraded? You could use a remote PSSession.

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at
Work SMARTER not HARDER.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top