Touch
New-Item powershell-notes.txt -ItemType File
mk
New-Item test-dir -Type Directory
mv
Move-Item test.txt test1.txt
cp
Copy-Item test1.txt test2.txt
rm
Remove-Item -Recurse .\test1.txt
Add SSH Keys to SSH Agent
Get-Service -Name ssh-agent | Set-Service -StartupType Manual
Start-Service ssh-agent
ssh-add c:/Users/YOU/.ssh/id_ed25519
tail -f
Get-Content .\powershell.md -Wait
Display the first 10 lines of a file
Get-Content -Path "C:\path\to\file.txt" -Head 10
Display the last 10 lines of a file
Get-Content -Path "C:\path\to\file.txt" -Tail 10
Display the contents of a file one page at a time
Get-Content -Path "C:\path\to\file.txt" | Out-Host -Paging
List open files and the processes using them (NOT TESTED)
Get-Process | ForEach-Object {
$_.Modules | Select-Object @{Name="ProcessName";Expression={$_.ProcessName}}, @{Name="ModuleName";Expression={$_.ModuleName}}
}
Display a list of running processes with resource usage
Get-Process | Sort-Object -Property CPU -Descending | Select-Object -First 10
Get-Content largefile.txt | more
Get-Help Get-Process -Detailed | Out-Host -Paging
Get-Content largefile.txt | more
Query Registry Key
Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoControlPanel"
Share!
comments powered by