If you want the latest file in the directory and you are using only the
LastWriteTime to determine the latest file, you can do something like below:
gci path | sort LastWriteTime | select -last 1
On the other hand, if you want to only rely on the names that have the dates in them, you should be able to something similar
gci path | select -last 1
Also, if there are directories in the directory, you might want to add a
- Powershell executable isn’t outputting to STDOUT
- Determine installed PowerShell version
- What Library for Powershell 6 contains the get-wmiobject command?
- How can I replace every occurrence of a String in a file with PowerShell?
- Use PowerShell to run virus scan on multiple servers
- Replace CRLF using powershell
- Save hash table in PowerShell object notation (PSON)
- Running a powershell command using full path and arguments from command line [duplicate]
- How do I capture the output into a variable from an external process in PowerShell?
- Powershell Custom Object Confusion
- How to get disk capacity and free space of remote computer
- Try/catch does not seem to have an effect
- PowerShell script to check an application that’s locking a file?
- What does $($variableName) mean in expandable strings in PowerShell?
- The ‘
- DateTime subtraction not working in PowerShell – assignment vs. equality operator
- Get remote registry value
- How to exit from ForEach-Object in PowerShell
- Running PowerShell as another user, and launching a script
- Why does ‘continue’ behave like ‘break’ in a Foreach-Object?
- Difference between ForEach and ForEach-Object in powershell
- Parameter interpretation when running jobs
- Scheduled Task Powershell Script – Runs OK as user account, but not as SYSTEM
- PowerShell Script to Find and Replace for all Files with a Specific Extension
- Modify Local Security Policy using Powershell
- How to speed up Powershell Get-Childitem over UNC
- Specifying *.xls filter in Get-ChildItem also returns *.xlsx results
- PowerShell for Software Inventory
- Parsing a Powershell variable
- How to run an application as “run as administrator” from the command prompt? [closed]
- Using Invoke-Command -ScriptBlock on a function with arguments
- Forcing PowerShell errors output in English on localized systems
- How do I compress files using powershell that are over 2 GB?
- Editing shortcut (.lnk) properties with Powershell
- PowerShell – Decode System.Security.SecureString to readable password
- ConvertTo-Csv Output without quotes
- Function Get-IniContent is not recognized – INI file support inPowerShell
- Powershell string variable with UTF-8 encoding
- Arrays and -contains – test for substrings in the elements of an array
- Echo equivalent in PowerShell for script testing
- Running CMD command in PowerShell
- How do I find the CPU and RAM usage using PowerShell?
- How to get Powershell Invoke-Restmethod to return body of http 500 code response
- Get target of shortcut (.lnk) file with powershell
- Get-ADGroupMember : The size limit for this request was exceeded
- Why is the output format changed when running two PowerShell commands in one line?
- How to print environment variables to the console in PowerShell?
- ConvertTo-JSON an array with a single item
- Can I use a single quote in a PowerShell ‘string’?
- Gracefully stopping in Powershell