====== PowerShell ====== ====== Over ====== ==== Выполнение сценариев отключено в этой системе ==== # Отключить Set-ExecutionPolicy RemoteSigned # Включить обратно Set-ExecutionPolicy Restricted ==== Фильтрация вывода ==== # -Property либо ExpandProperty (раскрывает содержимое) # "Format-Wide" - для вывода значения get-computerinfo | Select-Object -ExpandProperty | Format-Wide ==== Обрезка результатов ==== Get-Service -Name win* | Format-Table -AutoSize -AutoSize get-computerinfo -Property "CsProcessors" | Out-File -Width 2000 -FilePath out.txt ==== ==== # Create a zip file with the contents of C:\Stuff\ Compress-Archive -Path C:\Stuff -DestinationPath archive.zip # Add more files to the zip file # (Existing files in the zip file with the same name are replaced) Compress-Archive -Path C:\OtherStuff\*.txt -Update -DestinationPath archive.zip # Extract the zip file to C:\Destination\ Expand-Archive -Path archive.zip -DestinationPath C:\Destination # Use the pipeline to archive a directory Get-ChildItem -Path C:\LogFiles | Compress-Archive -DestinationPath C:\Archives\PipelineDir.zip # Архивирование с исключением некоторых файлов/папок Get-ChildItem -Path "mypath" -Exclude @("backups", "logs") | Compress-Archive -DestinationPath mypath\\backups\\archive.zip # Старт процесса и получение его 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 ==== ====