Skip to content
> 💻 🧠 Codice 1001 > 📑 Schede Riassuntive > 📚 Schede di riferimento PowerShell > ⚡ PowerShell Cheat Sheet — Base

⚡ PowerShell Cheat Sheet — Base

🔹 Basi

ComandoDescrizioneEsempio
Get-CommandMostra tutti i comandi disponibiliGet-Command *service*
Get-HelpAiuto su un comandoGet-Help Get-Process -Examples
Get-AliasElenco alias (nomi brevi)Get-Alias ls
Get-HistoryCronologia dei comandiGet-History
Start-TranscriptSalva la sessione in un fileStart-Transcript -Path log.txt

🔹 Lavorare con oggetti

ComandoDescrizioneEsempio
Get-MemberVisualizza proprietà e metodi di un oggetto`Get-Service
Select-ObjectSelezione di campi`Get-Process
Where-ObjectFiltraggio`Get-Service
Sort-ObjectOrdinamento`Get-Process
Measure-ObjectConteggio valori`Get-ChildItem

🔹 File e cartelle

ComandoDescrizioneEsempio
Get-ChildItem (ls)Elenco di file/cartelleGet-ChildItem C:Temp
New-ItemCrea file/cartellaNew-Item file.txt -ItemType File
Remove-Item (rm)Elimina file/cartellaRemove-Item file.txt
Copy-Item (cp)CopiaCopy-Item file.txt file2.txt
Move-Item (mv)SpostaMove-Item file.txt C:Backup
Set-Location (cd)Vai alla cartellaSet-Location C:Windows

🔹 Processi e servizi

ComandoDescrizioneEsempio
Get-ProcessElenco processiGet-Process chrome
Stop-ProcessTermina processoStop-Process -Name notepad
Start-ProcessAvvia processoStart-Process notepad.exe
Get-ServiceElenco serviziGet-Service
Start-ServiceAvvia servizioStart-Service Spooler
Stop-ServiceArresta servizioStop-Service Spooler

🔹 Rete

ComandoDescrizioneEsempio
Test-ConnectionTest pingTest-Connection google.com -Count 4
Test-NetConnectionTest portaTest-NetConnection google.com -Port 443
Invoke-WebRequest (wget)Scarica file/HTMLInvoke-WebRequest https://example.com -OutFile page.html
Get-NetAdapterSchede di reteGet-NetAdapter
Get-NetIPAddressIndirizzi IPGet-NetIPAddress

🔹 Sistema

ComandoDescrizioneEsempio
Get-DateData e oraGet-Date -Format "yyyy-MM-dd HH:mm:ss"
Get-EventLogLog eventiGet-EventLog -LogName System -Newest 20
Restart-ComputerRiavvia computerRestart-Computer -Force
Get-ComputerInfoInformazioni sistemaGet-ComputerInfo
Get-LocalUserElenco utenti localiGet-LocalUser

🔹 Variabili e script

ComandoDescrizioneEsempio
$var = "Hello"Crea variabile$name = "User"
Write-OutputStampa testoWrite-Output "Hello $name"
Read-HostInput utente$x = Read-Host "Enter value"
If (...) { } Else { }CondizioneIf ($x -gt 10) { "Big" } Else { "Small" }
ForEach-ObjectCiclo sugli oggetti`1..5
FunctionDefinizione funzioneFunction Say-Hello { param($n) "Hello $n" }

🔹 Moduli

ComandoDescrizioneEsempio
Get-ModuleElenco moduliGet-Module -ListAvailable
Import-ModuleImporta moduloImport-Module ActiveDirectory
Install-ModuleInstalla moduloInstall-Module Az
Update-ModuleAggiorna moduloUpdate-Module Az

Leave a Reply

Your email address will not be published. Required fields are marked *