В этом посте я просто буду собирать всё, что надыбал полезного про команды Windows
~
Разрешить выполнение файлов .ps1
Set-ExecutionPolicy Restricted <-- Will not allow any powershell scripts to run. Only individual commands may be run.
Set-ExecutionPolicy AllSigned <-- Will allow signed powershell scripts to run.
Set-ExecutionPolicy RemoteSigned <-- Allows unsigned local script and signed remote powershell scripts to run.
Set-ExecutionPolicy Unrestricted <-- Will allow unsigned powershell scripts to run. Warns before running downloaded scripts.
Set-ExecutionPolicy Bypass <-- Nothing is blocked and there are no warnings or prompts.
gpupdate /force
Ставим курсор в консоли на новую строку.
Создаём файл в директории:
%userprofile%\Documents\WindowsPowerShell
с именем
Microsoft.PowerShell_profile.ps1
И вставляем такой код (НИКАКИХ ТАБОВ И ПРОБЕЛОВ В НАЧАЛЕ КАЖДОЙ СТРОКИ):
function prompt {
$p = Split-Path -leaf -path (Get-Location)
"$p>
"
}
~
Отключение режима Гибернации
powercfg –h off
или
powercfg.exe /hibernate off
~
Проверить контрольную сумму файла
certutil -hashfile <file> MD5
---
Concatenate
Get-ChildItem -Recurse *.sql | ForEach-Object { Get-Content $_ } | Out-File .\all.sql
---
copy /b *.sql all_files.sql
---
Мониторинг открытых TCP/IP подключений с помощью PowerShell
Получить процесс, который занимает порт:
TCP
Get-Process -Id (Get-NetTCPConnection -LocalPort 65501).OwningProcess
UDP
Get-Process -Id (Get-NetUDPEndpoint -LocalPort 53).OwningProcess
---
Какие порты заняты в системе?
netstat -aon
---
Какие порты зарезервированы в системе?
netsh int ipv4 show excludedportrange protocol=tcp
---
Не закрывать файл .ps1 после выполнения
Read-Host -Prompt "Press Enter to exit"
---
Как ОЧЕНЬ быстро удалить папку в Windows
- CMD
del /f/s/q foldername > nul
rmdir /s/q foldername
- PowerShell
powershell -Command "Remove-Item -LiteralPath 'folder' -Force -Recurse"
#тсокрм #ЗапискиБывалых #windows #CLI #cmd #powershell