How can I get the full month name in PowerShell (i.e. December) from the lastwritetime of a file I just retrieved?
$Dt = (c:\folder\transactionfile.txt).lastwritetime
From $Dt I need to get the month name.
Technology Tips and News
How can I get the full month name in PowerShell (i.e. December) from the lastwritetime of a file I just retrieved?
$Dt = (c:\folder\transactionfile.txt).lastwritetime
From $Dt I need to get the month name.
Get-Date $Dt -Format 'MMMM'
or
$Dt.ToString('MMMM')
Both of Leif-Arne's examples will get the full month name; however, the way you're setting your $Dt variable doesn't work for me. Is it possible you forgot the Get-ChildItem, or Get-Item, cmdlet? Should it have been $Dt = (Get-ChildItem c:\folder\transactionfile.txt).LastWriteTime?
Get-Date $Dt -Format 'MMMM'
or
$Dt.ToString('MMMM')
Both of Leif-Arne's examples will get the full month name; however, the way you're setting your $Dt variable doesn't work for me. Is it possible you forgot the Get-ChildItem, or Get-Item, cmdlet? Should it have been $Dt = (Get-ChildItem c:\folder\transactionfile.txt).LastWriteTime?