Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tutorial:adm:configuration_-_winrm [2024/02/05 05:17] – erbenr | tutorial:adm:configuration_-_winrm [2024/11/21 09:04] (current) – [Check if Winrm is running] erbenr | ||
---|---|---|---|
Line 16: | Line 16: | ||
If you get some error then you need to do the [[https:// | If you get some error then you need to do the [[https:// | ||
+ | < | ||
+ | |||
+ | winrm quickconfig | ||
+ | |||
+ | </ | ||
Now execute the first command again and it should without error now. | Now execute the first command again and it should without error now. | ||
+ | |||
===== Show current configuration ===== | ===== Show current configuration ===== | ||
Line 25: | Line 31: | ||
<code powershell> | <code powershell> | ||
winrm e winrm/ | winrm e winrm/ | ||
- | |||
</ | </ | ||
Line 63: | Line 68: | ||
<code powershell> | <code powershell> | ||
winrm set winrm/ | winrm set winrm/ | ||
- | |||
</ | </ | ||
Line 74: | Line 78: | ||
winrm set winrm/ | winrm set winrm/ | ||
winrm set winrm/ | winrm set winrm/ | ||
- | |||
</ | </ | ||
Line 82: | Line 85: | ||
<code powershell> | <code powershell> | ||
winrm set winrm/ | winrm set winrm/ | ||
- | |||
</ | </ | ||
Line 90: | Line 92: | ||
<code powershell> | <code powershell> | ||
winrm set winrm/ | winrm set winrm/ | ||
- | |||
</ | </ | ||
Line 98: | Line 99: | ||
<code powershell> | <code powershell> | ||
- | winrm set winrm/ | + | winrm set winrm/ |
- | {{.: | + | |
winrm set winrm/ | winrm set winrm/ | ||
Enable-WSManCredSSP -Role Server | Enable-WSManCredSSP -Role Server | ||
- | |||
- | |||
</ | </ | ||
- | |||
===== Permission configuration ===== | ===== Permission configuration ===== | ||
Line 114: | Line 111: | ||
Assign user into group Set WMI access for group. | Assign user into group Set WMI access for group. | ||
- | * Computer Management → Services and Application → right click WMI Control → Properties * In new dialog window → tab Security → Root → CIMV2 and click button Security * Next dialog window will appear - you need to add group (WinRMRemoteWMIUsers\_\_ or Remote Management Users) here * You need to select these options in the checkboxes - Execute Methods, Enable Account and Remote Enable * Click on Advanced - select and edit group → Set " | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
{{.: | {{.: | ||
Line 122: | Line 124: | ||
<code powershell> | <code powershell> | ||
winrm configSDDL default | winrm configSDDL default | ||
- | |||
</ | </ | ||
- | {{.: | + | {{.: |
+ | | ||
+ | | ||
<code powershell> | <code powershell> | ||
Restart-Service winrm | Restart-Service winrm | ||
- | |||
</ | </ | ||
Line 142: | Line 144: | ||
<code shell> | <code shell> | ||
nc -vz HOST PORT | nc -vz HOST PORT | ||
- | |||
</ | </ | ||
Line 150: | Line 151: | ||
<code powershell> | <code powershell> | ||
Test-WSMan -ComputerName HOST or Test-netConnection HOST -Port PORT | Test-WSMan -ComputerName HOST or Test-netConnection HOST -Port PORT | ||
- | |||
</ | </ | ||
Line 156: | Line 156: | ||
Now we know if we are able to connect to the WinRM port. In case the port is not accessible it can be probably blocked in firewall. Next we want to try to connect to WinRM. Install [[: | Now we know if we are able to connect to the WinRM port. In case the port is not accessible it can be probably blocked in firewall. Next we want to try to connect to WinRM. Install [[: | ||
- | python>> | + | < |
- | + | >>> | |
- | < | + | |
- | import winrm>>> | + | |
>>> | >>> | ||
>>> | >>> | ||
- | |||
</ | </ | ||
Line 168: | Line 165: | ||
For connecting via HTTPS use this lane. The difference is in URL where we need to use https and port 5986. Then we are using one more argument where we specify path to trust store | For connecting via HTTPS use this lane. The difference is in URL where we need to use https and port 5986. Then we are using one more argument where we specify path to trust store | ||
- | s = winrm.Session('', | + | <code python>>>> |
- | + | ||
- | <code python>>>>> | + | |
</ | </ | ||
Line 179: | Line 173: | ||
<code python> | <code python> | ||
r = s.run_ps(' | r = s.run_ps(' | ||
- | |||
</ | </ | ||
Line 232: | Line 225: | ||
</ | </ | ||
- | To turn the credentials delegation on. Open Group policy setting and navigate to Computer | + | To turn the credentials delegation on. Open Group policy setting and navigate to Computer |
The Allow Delegating Fresh Credentials (AllowFreshCredentials) policy setting must be enabled. If it's enabled validate if correct value (values) are added to this policy. The correct value is WSMAN/SPN of your server. For example | The Allow Delegating Fresh Credentials (AllowFreshCredentials) policy setting must be enabled. If it's enabled validate if correct value (values) are added to this policy. The correct value is WSMAN/SPN of your server. For example | ||
Line 299: | Line 292: | ||
print " | print " | ||
print " | print " | ||
- | |||
</ | </ | ||
Line 332: | Line 324: | ||
Create and export self signed certificate with powershell: | Create and export self signed certificate with powershell: | ||
- | |||
<code powershell> | <code powershell> | ||
$pathToCertificate=" | $pathToCertificate=" | ||
- | $hostname=' | + | $hostname=' |
$params = @{ | $params = @{ | ||
Subject = " | Subject = " | ||
- | DnsName = 'bear.zoo.bcv' | + | DnsName = 'ad.idstory.idm' |
CertStoreLocation = ' | CertStoreLocation = ' | ||
- | KeyExportPolicy =' | + | KeyExportPolicy =' |
- | KeySpec =' | + | KeySpec =' |
KeyLength =' | KeyLength =' | ||
KeyAlgorithm = ' | KeyAlgorithm = ' | ||
Line 347: | Line 338: | ||
} | } | ||
- | #$cert = New-SelfSignedCertificate -Subject " | ||
$cert = New-SelfSignedCertificate @params | $cert = New-SelfSignedCertificate @params | ||
- | Export-Certificate -Cert $cert -FilePath " | + | Export-Certificate -Cert $cert -FilePath " |
$mypwd = ConvertTo-SecureString -String " | $mypwd = ConvertTo-SecureString -String " | ||
Export-PfxCertificate -Cert $cert -FilePath " | Export-PfxCertificate -Cert $cert -FilePath " | ||
- | |||
</ | </ | ||
List certificate in windows certificate storage: | List certificate in windows certificate storage: | ||
- | |||
<code powershell> | <code powershell> | ||
Get-ChildItem -Path Cert: | Get-ChildItem -Path Cert: | ||
- | |||
</ | </ | ||
Configure WinRM listener with HTTPS certficate: | Configure WinRM listener with HTTPS certficate: | ||
- | |||
<code powershell> | <code powershell> | ||
winrm create winrm/ | winrm create winrm/ | ||
for deleting | for deleting | ||
winrm delete winrm/ | winrm delete winrm/ | ||
- | |||
</ | </ | ||
Create firewall rule for WinRM HTTPS: | Create firewall rule for WinRM HTTPS: | ||
- | |||
<code powershell> | <code powershell> | ||
New-NetFirewallRule -Displayname 'WinRM - Powershell remoting HTTPS-In' | New-NetFirewallRule -Displayname 'WinRM - Powershell remoting HTTPS-In' | ||
- | |||
</ | </ | ||
Restart WinRM | Restart WinRM | ||
- | |||
<code powershell> | <code powershell> | ||
Restart-Service winrm | Restart-Service winrm | ||
- | |||
</ | </ | ||
Line 388: | Line 369: | ||
+ | ===== Powershell 7 support ===== | ||
+ | |||
+ | Install powershell 7: https:// | ||
+ | |||
+ | Run app '' | ||
+ | <code powershell> | ||
+ | Enable-PSRemoting | ||
+ | </ | ||