Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Аватара для sunnykey

Пользователь


Сообщения: 124
Благодарности: 47

Профиль | Отправить PM | Цитировать


Цитата Liquid Ocelot:
sunnykey, D:\log »
Скорее всего у тебя 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
}

-------
cmd умри, powershell живи=)
Powershel 4.0 microsoft.com/ru-ru/download/details.aspx?id=40855

Это сообщение посчитали полезным следующие участники:

Отправлено: 03:36, 05-07-2013 | #10