Update Servers/Automation/Ansible/Enable WinRM on Windows Devices.md

This commit is contained in:
2025-03-13 18:16:23 -06:00
parent 344b67c735
commit a6830ada57

View File

@ -37,7 +37,7 @@ if ($existingListeners | Where-Object { $_.Transport -eq "HTTPS" }) {
# Create a new HTTPS listener # Create a new HTTPS listener
Write-Host "Creating a new HTTPS listener..." Write-Host "Creating a new HTTPS listener..."
$listenerCmd = "winrm create winrm/config/Listener?Address=*+Transport=HTTPS '@{Hostname=`"hyperv-host.local`"; CertificateThumbprint=`"$certThumbprint`"}'" $listenerCmd = "winrm create winrm/config/Listener?Address=*+Transport=HTTPS '@{Hostname=`"$(Get-WmiObject -Class Win32_ComputerSystem).DomainName`"; CertificateThumbprint=`"$certThumbprint`"}'"
Invoke-Expression $listenerCmd Invoke-Expression $listenerCmd
# Set TrustedHosts to allow connections from any IP address (adjust as needed for security) # Set TrustedHosts to allow connections from any IP address (adjust as needed for security)
@ -63,7 +63,7 @@ winrm set winrm/config/service '@{AllowUnencrypted="false"}'
Write-Host "Configuring WinRM client to use Kerberos..." Write-Host "Configuring WinRM client to use Kerberos..."
winrm set winrm/config/client/auth '@{Kerberos="true"}' winrm set winrm/config/client/auth '@{Kerberos="true"}'
# Ensure the PowerShell execution policy is set to allow running scripts # Ensure the PowerShell execution policy is set to allow remotely running scripts
Write-Host "Setting PowerShell execution policy to RemoteSigned..." Write-Host "Setting PowerShell execution policy to RemoteSigned..."
Set-ExecutionPolicy RemoteSigned -Force Set-ExecutionPolicy RemoteSigned -Force