If you copy the following to PowerShell, the script will run without any problems.
If you put a space between ★, the screen will drop without processing when you run it in powershell.
Even if you put pause in ●, it will fall off without stopping.
$TargetLogFolder="C:\copy"
★
if (-not(Test-Path$TargetLogFolder)){
Add-Type-Assembly System.Windows.Forms
System.Windows.Forms.MessageBox::Show("The file does not exist., "Caution", "OK", "Warning", "Button 3")
pause●
EXIT
}
★
$g = "C:\hoge"
$o = Get-Date-format "yyyyMMdd_HHmmss"
New-Item$g\"$o.txt"
I was able to solve this question. The solution is to save the script itself from UTF-8 to ANSI and run Powershell to ensure it works.
© 2024 OneMinuteCode. All rights reserved.