PowerShell

วิธีการเปิด PSRemoting บน Windows 8.1

วิธีการเปิด PSRemoting บน Windows 8.1

วิธีการเปิด PSRemoting บน Windows 8.1

ขั้นตอนแรก เป็นการ Enable ให้ Windows Server เปิดการใช้งาน PowerShell Remote ได้ เริ่มจาก Logon ไปที่ Server เพื่อ Configure WinRM โดยให้เปิด PowerShell ด้วย runas administrator แล้ว run Enable-PSRemoting –force

ขั้นตอนดำเนินการ

1.กด Windows Key + Q พิมพ์  Windows PowerShell จากนั้นคลิก Windows PowerShell ส่วนในกรณีที่ต้องการรันภายใต้สิทธิ์ผู้ดูแลระบบให้คลิกขวาบน Windows PowerShell แล้วเลือก Run as administrator

 

PS C:\Windows\system32> Get-ExecutionPolicy   เรียกตรวจสอบโหมด Power Shell ที่ใช้ในขณะนี้ (Default:Restricted)
Restricted
PS C:\Windows\system32> Set-ExecutionPolicy  กดหนดโหมด PowerShell เป็น  RemoteSigned

cmdlet Set-ExecutionPolicy at command pipeline position 1
Supply values for the following parameters:
ExecutionPolicy: RemoteSigned  
PS C:\Windows\system32> Get-Service WinRM  ตรวจสอบสถานะเซอร์วิส WinRM

Status Name DisplayName
—— —- ———–
Running WinRM Windows Remote Management (WS-Manag…

PS C:\Windows\system32> Enable-PSRemoting  เปิด เซอร์วิส PoserShell Remoting

WinRM Quick Configuration
Running command “Set-WSManQuickConfig” to enable remote management of this
computer by using the Windows Remote Management (WinRM) service.
This includes:
1. Starting or restarting (if already started) the WinRM service
2. Setting the WinRM service startup type to Automatic
3. Creating a listener to accept requests on any IP address
4. Enabling Windows Firewall inbound rule exceptions for WS-Management
traffic (for http only).

Do you want to continue?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is “Y”):Y  กด Y แล้ว Enter
WinRM is already set up to receive requests on this computer.
Set-WSManQuickConfig : <f:WSManFault
xmlns:f=”http://schemas.microsoft.com/wbem/wsman/1/wsmanfault”
Code=”2150859113″ Machine=”localhost”><f:Message><f:ProviderFault
provider=”Config provider”
path=”%systemroot%\system32\WsmSvc.dll”><f:WSManFault
xmlns:f=”http://schemas.microsoft.com/wbem/wsman/1/wsmanfault”
Code=”2150859113″ Machine=”ACC-OFF-03″><f:Message>WinRM firewall exception
will not work since one of the network connection types on this machine is set
to Public. Change the network connection type to either Domain or Private and
try again.
</f:Message></f:WSManFault></f:ProviderFault></f:Message></f:WSManFault>
At line:69 char:17
+ Set-WSManQuickConfig -force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Set-WSManQuickConfig], In
validOperationException
+ FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.SetWSManQu
ickConfigCommand

เกิดจากปัญหา การ์ด Lan ถูกเซ็ต Network type เป็นแบบ Public

2.ตรวจสอบได้โดยใช้คำสั่ง PS C:\Windows\system32> secpol.msc เพื่อเรียกใช้โปรแกรม Local Security Policy เลือกที่ Network 4 คลิกขวากด Properties ไปที่ Tab Network Location พบ Location type: Public

3.ปรับ Location type: Private

4.ปรับ User permissions: User can change location กดปุ่ม Apply และ OK

5. ทำการเปิดเซอร์วิส Power Shell Remoting ใหม่

PS C:\Windows\system32> Enable-PSRemoting

WinRM Quick Configuration
Running command “Set-WSManQuickConfig” to enable remote management of this
computer by using the Windows Remote Management (WinRM) service.
This includes:
1. Starting or restarting (if already started) the WinRM service
2. Setting the WinRM service startup type to Automatic
3. Creating a listener to accept requests on any IP address
4. Enabling Windows Firewall inbound rule exceptions for WS-Management
traffic (for http only).

Do you want to continue?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is “Y”):Y
WinRM is already set up to receive requests on this computer.
WinRM is already set up for remote management on this computer.

Confirm
Are you sure you want to perform this action?
Performing the operation “Set-PSSessionConfiguration” on target “Name:
microsoft.powershell SDDL:
O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;RM)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This
lets selected users remotely run Windows PowerShell commands on this
computer.”.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is “Y”):Y

Confirm
Are you sure you want to perform this action?
Performing the operation “Set-PSSessionConfiguration” on target “Name:
microsoft.powershell.workflow SDDL:
O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;RM)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This
lets selected users remotely run Windows PowerShell commands on this
computer.”.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is “Y”):Y

Confirm
Are you sure you want to perform this action?
Performing the operation “Set-PSSessionConfiguration” on target “Name:
microsoft.powershell32 SDDL:
O:NSG:BAD:P(A;;GA;;;BA)(A;;GA;;;RM)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD). This
lets selected users remotely run Windows PowerShell commands on this
computer.”.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is “Y”):
PS C:\Windows\system32> Set-Item wsman:\localhost\client\trustedhosts *  เซ็ต wsman

WinRM Security Configuration.
This command modifies the TrustedHosts list for the WinRM client. The computers
in the TrustedHosts list might not be authenticated. The client might send
credential information to these computers. Are you sure that you want to modify
this list?
[Y] Yes [N] No [S] Suspend [?] Help (default is “Y”): Y
PS C:\Windows\system32> Restart-Service WinRM   รีสตาร์ทเซอร์วิส WinRM
PS C:\Windows\system32> Enter-PSSession -ComputerName W2K8-SRV -Credential ad
ministrator  ทดสอบ Remote ไปยังเครื่องอื่น
[W2K8-SRV]: PS C:\Users\Administrator\Documents>

 

Tags

Related Articles

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close