Winrm https basic auth with pywinrm

From UVOO Tech Wiki
Revision as of 05:13, 14 February 2024 by Busk (talk | contribs) (Created page with "``` # Configure WinRM to use HTTPS and enable basic authentication Enable-PSRemoting -Force -SkipNetworkProfileCheck Set-Item WSMan:\localhost\Service\Auth\Basic -Value $true...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
# Configure WinRM to use HTTPS and enable basic authentication
Enable-PSRemoting -Force -SkipNetworkProfileCheck
Set-Item WSMan:\localhost\Service\Auth\Basic -Value $true
Set-Item WSMan:\localhost\Service\AllowUnencrypted -Value $false

# Create a self-signed certificate (replace with a valid certificate in production)
$cert = New-SelfSignedCertificate -DnsName "localhost" -CertStoreLocation cert:\LocalMachine\My
$thumbprint = $cert.Thumbprint

# Configure WinRM listener to use HTTPS and the created certificate
New-Item -Path WSMan:\localhost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $thumbprint -Force

# Restart WinRM service to apply changes
Restart-Service WinRM