Remote powershell

Allow remote powershell
Enable-PSRemoting -Force 
Enable-WSManCredSSP -Role Server -Force
Get-Service winrm | Start-Service 
Enable-WSManCredSSP -Role Client -DelegateComputer * -Force 
Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowFreshCredentials -Name WSMan -Value WSMAN/* 
Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\Credssp\PolicyDefaults\AllowFreshCredentialsDomain -Name WSMan -Value WSMAN/*  

Test from an other machine: 
Invoke-Command -ComputerName Remote-Server -ScriptBlock {Get-host}


Allow crossdomain:
On remote server do the above and:
New-Itemproperty -name LocalAccountTokenFilterPolicy -path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -propertyType DWord -value 1

On remote and local machine run:
Set-item wsman:localhost\client\trustedhosts -value 'server1,server2,server3'

Test from an other machine: 
$credential = Get-Credential
Invoke-Command -ComputerName RM-SERVER -ScriptBlock {Get-Process} -Credential $credential

Leave a Reply

Your email address will not be published. Required fields are marked *