gpt4 book ai didi

powershell - 通过 PowerShell 远程处理访问 Azure 云服务 PaaS 实例

转载 作者:行者123 更新时间:2023-12-03 00:19:46 26 4
gpt4 key购买 nike

我有一个带有 2 个实例的 Azure Web 角色(注意 PaaS 角色,*不是 Azure 虚拟机)。我可以通过远程桌面连接到它们,但我不知道如何在 Powershell 中进行远程处理(PowerShell Remoting),因为与 Azure 虚拟机云服务不同,无法为每个实例定义端点和端口:每个工作角色没有单独的地址。

如何通过 Powershell Remoting 连接到单个 PaaS 工作角色实例? IOW我该如何使用:

Enter-PSSession –ComputerName PC1 –Credential User

针对云服务辅助角色 (PaaS) 实例?

最佳答案

使用 PowerShell 远程处理(不要与 RDP 混淆)对于 Azure VM 来说似乎是完全可能的:

PowerShell Remoting needs the correct network configuration to allow for remote connectivity. Since we will be accessing the VM over the web we are required to use HTTPS to secure the communication channel. Skipping over the details of Windows Remote Management which is used by PowerShell Remoting, I will just say the default HTTPS port is 5986.

To allow connectivity to the VM this endpoint must be added to the ServiceDefinition.csdef:

<endpoints>
<inputendpoint localport="5986" port="5986" protocol="tcp" name="WinRM" />
</endpoints>

With the proper port open it is just a matter of enabling PowerShell Remoting. Two issues need to be resolved before enabling it.

The first is using the correct user account to setup Remoting. You must use the account previously created to run the script to setup Remoting[1]. With these commands the user you previously created will execute the script e:\approot\StartRemotingListener.ps1:

schtasks /CREATE /TN "StartRemotingListener" /SC ONCE /SD 01/01/2020 /ST 00:00:00 
/RL HIGHEST /RU <username> /RP <password>
/TR "powershell -ExecutionPolicy unrestricted
-Command e:\approot\StartRemotingListener.ps1 -Force" /F
schtasks /RUN /TN "StartRemotingListener"

The second issue is configuring the certificate needed for the HTTPS connection. Acquiring a certificate might not be a problem for a production environment. You might already have one for your service and could reuse it. It can be a problem if your service doesn’t require a certificate for normal operation or for non-production environments.

来自:http://blogs.msdn.com/b/mariok/archive/2011/08/08/command-line-access-to-azure-vms-powershell-remoting.aspx

关于powershell - 通过 PowerShell 远程处理访问 Azure 云服务 PaaS 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15787768/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com