繁体   English   中英

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

[英]Can I access IIS on a Windows Server 2016 remotely?

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

根据您的描述,我建议您可以使用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 窗口:

在此处输入图片说明

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

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

或者

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM