Показаны различия между двумя версиями страницы.
Предыдущая версия справа и слева Предыдущая версия Следующая версия | Предыдущая версия | ||
windows:ps [2022/04/06 12:12] admin |
windows:ps [2023/12/01 06:15] (текущий) admin [Обрезка результатов] |
||
---|---|---|---|
Строка 16: | Строка 16: | ||
==== Фильтрация вывода ==== | ==== Фильтрация вывода ==== | ||
- | |||
<code powershell> | <code powershell> | ||
Строка 23: | Строка 22: | ||
</ | </ | ||
- | ==== Сокращенный вывод ==== | ||
- | Сокращается он по размерам экрана консоли, можно расширить экран | + | ==== Обрезка результатов ==== |
<code powershell> | <code powershell> | ||
+ | Get-Service -Name win* | Format-Table -AutoSize -AutoSize | ||
get-computerinfo -Property " | get-computerinfo -Property " | ||
- | |||
</ | </ | ||
+ | |||
+ | <code powershell> | ||
==== ==== | ==== ==== | ||
- | <code powershell> | + | <code powershell> |
+ | # Create a zip file with the contents of C:\Stuff\ | ||
+ | Compress-Archive -Path C:\Stuff -DestinationPath archive.zip | ||
- | <code powershell> | + | # Add more files to the zip file |
+ | # (Existing files in the zip file with the same name are replaced) | ||
+ | Compress-Archive -Path C: | ||
+ | # Extract the zip file to C: | ||
+ | Expand-Archive -Path archive.zip -DestinationPath C: | ||
+ | |||
+ | # Use the pipeline to archive a directory | ||
+ | Get-ChildItem -Path C:\LogFiles | Compress-Archive -DestinationPath C: | ||
- | ==== ==== | + | # Архивирование с исключением некоторых файлов/ |
+ | Get-ChildItem -Path " | ||
+ | </ | ||
- | <code powershell> | ||
- | <code powershell> | + | <code powershell> |
+ | # Старт процесса и получение его PID | ||
+ | (Start-Process Notepad -passthru).ID | ||
+ | |||
+ | # Либо так еще | ||
+ | $app = Start-Process notepad -passthru | ||
+ | Wait-Process $app.Id | ||
+ | |||
+ | # Запуск Java приложения и сохранение PID в файл | ||
+ | (Start-Process java Main -passthru).ID > proc.pid | ||
+ | |||
+ | </ | ||