Скорее всего у тебя PS 2.0, а там нет атрибута
-File. Переделал
Код:
#Powershell script.
#Don't forget unlock script executing by
#using command "Set-ExecutionPolicy RemoteSigned" or "Set-ExecutionPolicy Unrestricted"
#Save this file with ".ps1" extension
$LogDir='D:\google_drive'
$LogPath="$LogDir\log.txt"
filter AddUserName ([string]$uname){
if ($_ -ne $null) {
$uname.TrimEnd(".txt")+" -- "+$_
}
}
if ( -not (Test-Path -Path $LogPath)) {
New-Item -ItemType File -Path $LogPath
}
Set-Location -Path $LogDir
$FileList=Get-ChildItem -Path ".\*" -Include "*.txt" -Exclude "log.txt" | `
where {$_.Attributes -ne [System.IO.FileAttributes]::Directory}
foreach ($el in $FileList) {
$CurStr=Get-Content -Path $el | Select-String -Pattern `
"Продукт: Lotus Notes 8.5.3 ru -- Операция установки успешно завершена." | `
Select-Object -Last 1
if ($CurStr -eq $null) {
$CurStr=" "
}
$CurStr | AddUserName -uname $el.Name | Out-File -FilePath $LogPath -Append
}