PowerShell

Base64 Encode DLL

$Path = "$PSScriptRoot\TotallyNotMalware.dll"
$bytes = [System.IO.File]::ReadAllBytes($Path)
$string = [System.Convert]::ToBase64String($bytes)

Copy something to clipboard

$string | Set-Clipboard

Load Base64 Encoded DLL

$dll = 'TVqQAAMAAAAEAAAA//8AALgAAAAA...'
$bytes = [System.Convert]::FromBase64String($dll)
[System.Reflection.Assembly]::Load($bytes)

Easy way to create an object

function Add2Obj {
    param (
        $FirstName,
        $LastName
    )
    return (New-Object psobject -Property @{FirstName=$FirstName;LastName=$LastName;})
}

$Names  = @()
$Names += Add2Obj -FirstName "Justin" -LastName "Perdok"

<#
PS> $Names

LastName FirstName
-------- ---------
Perdok   Justin
#>

Search NETLOGON/SYSVOL for cpassword

Get-ChildItem | Where-Object {$_.name -ne 'Policydefinitions'} | Get-ChildItem -Recurse -File | ForEach-Object {$_.fullname; Get-Content $_.fullname | Select-String cpassword}

Alternative

https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Get-GPPPassword.ps1

Ensure PowerShell uses TLS1.2

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Ignore invalid certs

add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem) {
            return true;
        }
    }
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

Also see

N/A