r/PowerShell • u/Hour-Bat7014 • Jan 29 '26
Question Doesn't work from the command line
$InputFile = "E:\turnOffCharge.txt"
$OutputFile = "E:\sendOFF.txt"
$TodayDate = Get-Date -Format "yyyy-M-dd"
We read the file, filter the lines containing today's date, and save it.Get-Content -Path $InputFile | Where-Object { $_ -like "*$TodayDate*" } | Set-Content -Path $OutputFile
0
Upvotes
View all comments
Show parent comment
2
u/sid351 Jan 29 '26
Or a VS Code, with PowerShell enabled, session.
That will be v7 though, so need to bear that in mind for some (rare) stuff that has to be v5 or below.