Инструменты пользователя

Инструменты сайта


windows:ps

Различия

Показаны различия между двумя версиями страницы.

Ссылка на это сравнение

Следующая версия
Предыдущая версия
windows:ps [2022/04/05 11:54]
admin создано
windows:ps [2023/12/01 06:15] (текущий)
admin [Обрезка результатов]
Строка 4: Строка 4:
 ====== Over ====== ====== Over ======
  
-===== Выполнение сценариев отключено в этой системе ====+==== Выполнение сценариев отключено в этой системе ====
-Отключить +
-<code powershell> Set-ExecutionPolicy RemoteSigned </code>+
  
-Включить обратно +<code powershell> 
-<code powershell> Set-ExecutionPolicy Restricted </code>+# Отключить 
 +Set-ExecutionPolicy RemoteSigned 
  
 +# Включить обратно
 +Set-ExecutionPolicy Restricted
 +</code>
  
  
-=====  =====+==== Фильтрация вывода ====
  
-<code powershell> </code>+<code powershell> 
 +# -Property либо ExpandProperty (раскрывает содержимое) #  "Format-Wide" - для вывода значения 
 +get-computerinfo | Select-Object -ExpandProperty <ColumnName>  | Format-Wide 
 +</code>
  
-<code powershell> </code> 
  
 +==== Обрезка результатов ====
  
-=====  =====+<code powershell> 
 +Get-Service -Name win* | Format-Table -AutoSize -AutoSize 
 +get-computerinfo -Property "CsProcessors" | Out-File -Width 2000 -FilePath  out.txt 
 +</code>
  
 <code powershell> </code> <code powershell> </code>
  
-<code powershell> </code> 
  
 +====  ====
  
-=====  =====+<code powershell> 
 +# Create a zip file with the contents of C:\Stuff\ 
 +Compress-Archive -Path C:\Stuff -DestinationPath archive.zip
  
-<code powershell> </code>+# 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
  
-<code powershell> </code>+# 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 
 +</code> 
 + 
 + 
 +<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 
 + 
 +</code>
  
  
-=====  =====+====  ====
  
 <code powershell> </code> <code powershell> </code>
  
 <code powershell> </code> <code powershell> </code>
windows/ps.1649159669.txt.gz · Последнее изменение: 2022/04/05 11:54 — admin