我可以远程访问Windows Server 2016上的IIS吗?

问题描述 投票:-1回答:1

我必须在网站自动更新后启动和停止网站。现在,这需要我远程桌面连接到服务器并手动启动和停止它们。我希望能够通过命令提示符连接到服务器并启动和停止特定站点。我相信AppCmd可以轻松启动和停止网站,但我应该如何连接到服务器?

windows iis server
1个回答
0
投票

根据你的描述,我建议你可以使用powershell WinRM来达到你的要求。

您可以使用WinRM远程访问服务器,您可以运行powershell命令来管理IIS应用程序。

您应首先使用以下powershell命令启用WinRM以允许在服务器端进行远程管理:

#Get the winrm service status
Get-Service WinRM
#Allow remote access
Enable-PSRemoting –Force 
#Quick config the winrm
winrm quickconfig
#Add all clients to trustedhosts
Set-Item wsman:\localhost\client\trustedhosts *
Restart-Service WinRM

在客户端服务器中,您可以运行以下命令:

#Connect to remote server 
Enter-PSSession -ComputerName {yourremoteserver ip address or computer name} -Credential {accont name}

如果成功,您将看到powershell窗口如下:

enter image description here

然后您可以使用以下命令来停止或启动应用程序池:

import-module WebAdministration
Stop-WebAppPool -Name 'DefaultAppPool'

要么

import-module WebAdministration
Start-WebAppPool -Name 'DefaultAppPool'
© www.soinside.com 2019 - 2024. All rights reserved.