Registry Windows

From UVOO Tech Wiki
Revision as of 16:31, 2 November 2023 by Busk (talk | contribs)
Jump to navigation Jump to search

Export & Import via Registry even Non-Exportable

Get existing

Get-ChildItem -Path Cert:LocalMachine\MY | select subject

Migrate

$DST_HOST = "foo.example.com"
$CN="CN=foo, OU=bar"
$TP=(Get-ChildItem -Path Cert:LocalMachine\MY | where Subject -eq "$CN").Thumbprint
reg export "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\MY\Certificates\$TP"  $env:TEMP\cert.$TP.reg

$Session = New-PSSession -ComputerName $DST_HOST
Copy-Item -Path $env:TEMP\cert.$TP.reg -ToSession $Session -Destination "$env:TEMP\"
invoke-command $DST_HOST -ScriptBlock { reg.exe import "$env:TEMP\cert.$Using:TP.reg" }

Other

$regFile = @"
 Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters]
"MaxUserPort"=dword:00005000
"TcpTimedWaitDelay"=dword:0000001e
"@

Invoke-Command -ComputerName computerName -ScriptBlock {param($regFile) $regFile | out-file $env:temp\a.reg; 
    reg.exe import $env:temp\a.reg } -ArgumentList $regFile