# Open powershell as System Administrator
# Enable Remote access on bought servers
Enable-PSRemoting -Force
# Set trusted hosts of each other on on bought servers
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "ip1, ip2, ip3, ipN" or *
Restart-Service WinRM
# Test remote connection
Test-WsMan serverIP
#Try run scripts
Invoke-Command -ComputerName $serverIP -ScriptBlock { echo "qwe" } -credential user
# If Scripts doesnt run try
#Check execution policy
Get-ExecutionPolicy
#if its not unrestricted - check will you accept this mode for your needs?
set-executionpolicy -executionpolicy unrestricted
If you are getting Access denied add next policy
New-ItemProperty -Name LocalAccountTokenFilterPolicy `
#Check Trusted Hosts
$a=Get-Item WSMan:\localhost\Client\TrustedHosts
$a.Value
Enable Remote Scheduler Tasks Service in Firewall
If you got next error:
# Enable Remote access on bought servers
Enable-PSRemoting -Force
# Set trusted hosts of each other on on bought servers
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "ip1, ip2, ip3, ipN" or *
Restart-Service WinRM
# Test remote connection
Test-WsMan serverIP
#Try run scripts
Invoke-Command -ComputerName $serverIP -ScriptBlock { echo "qwe" } -credential user
# If Scripts doesnt run try
#Check execution policy
Get-ExecutionPolicy
#if its not unrestricted - check will you accept this mode for your needs?
set-executionpolicy -executionpolicy unrestricted
If you are getting Access denied add next policy
New-ItemProperty -Name LocalAccountTokenFilterPolicy `
-Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System `
-PropertyType DWord -Value 1
The LocalAccountTokenFilterPolicy entry disables user account control (UAC) remote restrictions for all users of all affected computers. Consider the implications of this setting carefully before changing the policy.
#Check Trusted Hosts
$a=Get-Item WSMan:\localhost\Client\TrustedHosts
$a.Value
Enable Remote Scheduler Tasks Service in Firewall
If you got next error:
Connecting to remote server $servername failed with the following error message : WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles limits access to remote computers within the same local subnet. For more information, see the about_Remote_Troubleshooting Help topic.
Enable Discovery network!
Комментариев нет:
Отправить комментарий