Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Powershell: powershell gets the newly created files in the current directory

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

PS C:\ Users\ Administrator > dir

Directory: C:\ Users\ Administrator

Mode LastWriteTime Length Name

Dmurmuri-2019-1-16 14:00. Android

DmurmurWhile-2019-2-20 17:24. BigNox

Dmurmuri-2017-12-13 11:53. Idlerc

Dmurmuri-2018-10-9 15:38. LdVirtualBox

Dmurmuri-2018-11-13 9:00. Matplotlib

Dmurmuri-2018-10-15 9:22. PyCharmCE2018.2

Dmurmuri-2017-11-30 9:34. VirtualBox

Dmurr Contacts-2017-9-30 11:19

Dmurr Desktop-2019-3-11 17:34

Dmurr Documents-2019-1-11 14:32

Dmurr Downloads-2019-3-5 9:20

Dmurr Favorites-2019-2-20 17:56

Dmurr Links-2017-9-30 11:19

Dmurmuri-2018-5-30 11:26 ncftp

Dmurmuri-2018-10-10 9:12 Nox_share

Dmurr Pictures-2018-10-9 15:37

Dmurr Saved Games-2017-9-30 11:19

Dmurr Searches-2017-9-30 11:19

Dmurmuri-2019-1-8 9:40 UIDowner

Dmurr Videos-2018-10-9 15:37

Dmurr Virtual Machines-2017-11-30 9:59

Dmurmuri-2017-11-30 9:34 VirtualBox VMs

Dmurmuri-2019-2-20 17:24 vmlogs

Dmurmuri-2018-9-26 15:13 New folder

-a murmuri-2019-2-27 9:10 216962 a.html

-a murmuri-2019-3-8 15:02 0 a.txt

-a murmuri-2018-10-10 9:12 66 inittk.ini

-a murmuri-2018-10-10 9:12 41 inst.ini

-a murmuri-2018-10-10 9:12 45 nuuid.ini

-a murmuri-2018-12-18 10:37 616 SciTE.session

PS C:\ Users\ Administrator > dir | where {$_ .Mode-like "* a*"} | Sort-Object LastWriteTime-Descending

Directory: C:\ Users\ Administrator

Mode LastWriteTime Length Name

-a murmuri-2019-3-8 15:02 0 a.txt

-a murmuri-2019-2-27 9:10 216962 a.html

-a murmuri-2018-12-18 10:37 616 SciTE.session

-a murmuri-2018-10-10 9:12 66 inittk.ini

-a murmuri-2018-10-10 9:12 45 nuuid.ini

-a murmuri-2018-10-10 9:12 41 inst.ini

PS C:\ Users\ Administrator > dir | where {$_ .Mode-like "* a*"} | Sort-Object LastWriteTime-Descending | select-first 1

Directory: C:\ Users\ Administrator

Mode LastWriteTime Length Name

-a murmuri-2019-3-8 15:02 0 a.txt

PS C:\ Users\ Administrator > dir | where {$_ .Mode-like "* a*"} | Sort-Object LastWriteTime-Descending | select-first 1 | fl

Directory: C:\ Users\ Administrator

Name: a.txt

Length: 0

CreationTime: 2019-3-8 15:02:27

LastWriteTime: 2019-3-8 15:02:27

LastAccessTime: 2019-3-8 15:02:27

VersionInfo: File: C:\ Users\ Administrator\ a.txt

InternalName:

OriginalFilename:

FileVersion:

FileDescription:

Product:

ProductVersion:

Debug: False

Patched: False

PreRelease: False

PrivateBuild: False

SpecialBuild: False

Language:

PS C:\ Users\ Administrator > dir | where {$_ .Mode-like "* a*"} | Sort-Object LastWriteTime-Descending | select-first 1 | fl Name

Name: a.txt

PS C:\ Users\ Administrator > dir | where {$_ .Mode-like "* a*"} | Sort-Object LastWriteTime-Descending | select-first 1 | fl Name | out-string

Name: a.txt

-- so the final complete statement is:--

PS C:\ Users\ Administrator > (dir | where {$_ .Mode-like "* a*"} | Sort-Object LastWriteTime-Descending | select-first 1 | fl Name | out-string) .split (":") [- 1]

A.txt

PS: I have just come into contact with POWERSHELL and know that this is not the most concise and accurate way to write. I just made a note and forgot my master's advice. Thank you!

-updated on March 13-

Today's test found that the following command is also possible, much simpler.

(dir | where {$_ .Mode-like "* a *"} | Sort-Object LastWriteTime-Descending) .name [0]

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report