name = 'winrm-config'
description = 'set default winrm config'
ps = '''
#netsh advfirewall firewall add rule name="WinRM HTTP" dir=in localport=5985 protocol=TCP action=allow
#netsh advfirewall firewall add rule name=winexe1 dir=in action=allow protocol=TCP localport=139
#netsh advfirewall firewall add rule name=winexe2 dir=in action=allow protocol=TCP localport=445
#winrm quickconfig -q
#sc config winrm start= auto
#Restart-Service winrm

#Enable-PSRemoting -Force

Enable-WSManCredSSP -Role Server -Force
Enable-WSManCredSSP -Role Client -DelegateComputer * -Force

Set-Item -Path "wsman:\localhost\service\\auth\credSSP" -Value $True -Force
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force
New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation -Name AllowFreshCredentialsWhenNTLMOnly -Force
New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation\AllowFreshCredentialsWhenNTLMOnly -Name 1 -Value * -PropertyType String -Force

winrm set winrm/config '@{MaxTimeoutms="7200000"}'
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="0"}'
winrm set winrm/config/winrs '@{MaxProcessesPerShell="0"}'
winrm set winrm/config/winrs '@{MaxShellsPerUser="0"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
winrm set winrm/config/client/auth '@{Basic="true"}'
winrm set winrm/config/client '@{TrustedHosts="*"}'

#Restart-Computer -Force
'''
