Last active
January 9, 2019 11:38
-
-
Save tech-zombie/466d8d6ca0e4f84cd68448ad8445ce42 to your computer and use it in GitHub Desktop.
Powershell to get newest file in folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-NewestFile | |
{ | |
param($PathToDirectory) | |
$NewestFile = Get-ChildItem $PathToDirectory | sort LastWriteTime | select -last 1 | |
$PathToNewestFile = $PathToDirectory + "\" + $NewestFile | |
$PathToNewestFile | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment