Попробуйте это -
Add-Content -path C:\...\outlog.txt -Value("$Date; $Time; Checked; $strFileName")
Если вы посмотрите на get-help Add-Content -full
и посмотрите на параметр -value
, вы увидите -
-Value <Object[]>
Specifies the content to be added. Type a quoted string, such as "This data is for internal use only", or
specify an object that contains content, such as the DateTime object that Get-Date generates.
You cannot specify the contents of a file by typing its path, because the path is just a string, but you can
use a Get-Content command to get the content and pass it to the Value parameter.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByPropertyName, ByValue)
Accept wildcard characters? false
Он говорит, что ожидает quoted string
или object that contains content
. В вашем случае он отсутствовал, и поэтому оператор +
пытался добавить $date
и time
.