Open a folder in powershell

Vikas,
Welcome to the forum. :wave:t4:

When you post code or sample data or console output please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thanks in advance

Since your date is in the format yyyy.MM.dd you could simply sort it by name and use the last found to find the folder wirh the latest date.

$Path = 'C:\Ps\degtf-ithuju'

Get-ChildItem -Path $Path -Directory |
    Sort-Object -Property Name |
        Select-Object -Last 1

If you want to go with the date time string you have several options … like this for example:

$DateTimeString = Get-Date -Format 'yyyy.MM.dd-*'
$DateTimeString = (Get-Date).ToString('yyyy.MM.dd-*')

And at the end you should enclose your path in quotes.

2 Likes