如何从 server1 执行 powershell 脚本以在 server2 中部署 wsp
How to execute powershell script from server1 for deploying wsp in server2
我正在尝试通过 运行在服务器 1 中使用 powershell 脚本来远程部署服务器 2 中存在的 wsp 文件。
我可以使用以下命令通过服务器 1 成功登录到服务器 2:
$password = ConvertTo-SecureString "password" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("username",$password)
但我无法部署 wsp 文件。这是我试过的代码:
Enter-PSSession -ComputerName server2 -Credential $cred
Add-PSSnapin Microsoft.Sharepoint.Powershell –EA 0
Update-SPSolution -Identity TechSoup.Web.wsp -LiteralPath "C:\Program Files ...Debug\Some.wsp" -GacDeployment
我也试过将上面的代码放在脚本中,保存并远程 运行 脚本。
这是我遇到的错误。我相信这是因为我没有管理员权限,我可以这样说,因为当我 运行 来自 server2 的部署代码作为管理员时,wsp 文件正在部署。那么,我怎样才能远程获得管理员权限。用户具有管理员权限,我需要做的就是 运行 它具有提升的权限(如右键单击和 运行 作为管理员,但以编程方式)
Update-SPSolution : Cannot access the local farm. Verify that the
local farm is properly configured, currently available, and that you
have the appropriate permissions to access the database before trying
again
编辑
我已经在 powershell 的管理员模式下尝试了以下脚本代码:
$password = ConvertTo-SecureString "serverpassword" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("userName",$password)
Enable-PSRemoting
Enable-WSmanCredSSP -Role Server
winrm set winrm/config/winrs '@{MaxShellsPerUser="25"}'
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="600"}'
Enter-PSSession -ComputerName Server2 -Credential $cred -Authentication credssp
但是,我不断收到此错误:
Enter-PSSession : Connecting to remote server Server2 failed
with the following error message : The WinRM client cannot process
the request. CredSSP authentication is currently disabled in the
client configuration. Change the client configuration and try the
request again. CredSSP authentication must also be enabled in the
server configuration. Also, Group Policy must be edited to allow
credential delegation to the target computer. Use gpedit.msc and look
at the following policy: Computer Configuration -> Administrative
Templates -> System -> Credentials Delegation -> Allow Delegating
Fresh Credentials. Verify that it is enabled and configured with an
SPN appropriate for the target computer. For example, for a target
computer name "myserver.domain.com", the SPN can be one of the
following: WSMAN/myserver.domain.com or WSMAN/*.domain.com For more
information, see the about_Remote_Troubleshooting Help topic
无论我尝试什么,我都会收到此错误。我尝试过这些技巧:
- 允许在 GPEdit 中委派新凭据以及 NTLM 新凭据。
- 我试过 This link
中的脚本
- 我在 compmgmt.msc 添加了用户权限
远程桌面用户
WinRMRemoteWMIUsers__
WSS_ADMIN_WPG
远程管理用户
任何人都可以提出任何建议吗??
为了 运行 SharePoint 远程命令,请按照下列步骤操作:Remote PowerShell to Manage SharePoint on-premises
本质上,启用远程处理后,您必须启用 CredSSP 访问权限,以便将您的凭据发送到远程和本地计算机,以便您执行 运行 提升的命令。
在服务器上:
Enable-PSRemoting
Enable-WSmanCredSSP -Role Server
winrm set winrm/config/winrs '@{MaxShellsPerUser="25"}'
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="600"}'
在客户端:
Enable-PSRemoting
Enable-WSmanCredSSP -Role Client -DelegateComputer "server2.contoso.com"
然后在客户端就可以进入session了:
Enter-PSSession -ComputerName server2 -Credential $cred -Authentication Credssp
我正在尝试通过 运行在服务器 1 中使用 powershell 脚本来远程部署服务器 2 中存在的 wsp 文件。
我可以使用以下命令通过服务器 1 成功登录到服务器 2:
$password = ConvertTo-SecureString "password" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("username",$password)
但我无法部署 wsp 文件。这是我试过的代码:
Enter-PSSession -ComputerName server2 -Credential $cred
Add-PSSnapin Microsoft.Sharepoint.Powershell –EA 0
Update-SPSolution -Identity TechSoup.Web.wsp -LiteralPath "C:\Program Files ...Debug\Some.wsp" -GacDeployment
我也试过将上面的代码放在脚本中,保存并远程 运行 脚本。
这是我遇到的错误。我相信这是因为我没有管理员权限,我可以这样说,因为当我 运行 来自 server2 的部署代码作为管理员时,wsp 文件正在部署。那么,我怎样才能远程获得管理员权限。用户具有管理员权限,我需要做的就是 运行 它具有提升的权限(如右键单击和 运行 作为管理员,但以编程方式)
Update-SPSolution : Cannot access the local farm. Verify that the local farm is properly configured, currently available, and that you have the appropriate permissions to access the database before trying again
编辑
我已经在 powershell 的管理员模式下尝试了以下脚本代码:
$password = ConvertTo-SecureString "serverpassword" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("userName",$password)
Enable-PSRemoting
Enable-WSmanCredSSP -Role Server
winrm set winrm/config/winrs '@{MaxShellsPerUser="25"}'
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="600"}'
Enter-PSSession -ComputerName Server2 -Credential $cred -Authentication credssp
但是,我不断收到此错误:
Enter-PSSession : Connecting to remote server Server2 failed with the following error message : The WinRM client cannot process the request. CredSSP authentication is currently disabled in the client configuration. Change the client configuration and try the request again. CredSSP authentication must also be enabled in the server configuration. Also, Group Policy must be edited to allow credential delegation to the target computer. Use gpedit.msc and look at the following policy: Computer Configuration -> Administrative Templates -> System -> Credentials Delegation -> Allow Delegating Fresh Credentials. Verify that it is enabled and configured with an SPN appropriate for the target computer. For example, for a target computer name "myserver.domain.com", the SPN can be one of the following: WSMAN/myserver.domain.com or WSMAN/*.domain.com For more information, see the about_Remote_Troubleshooting Help topic
无论我尝试什么,我都会收到此错误。我尝试过这些技巧:
- 允许在 GPEdit 中委派新凭据以及 NTLM 新凭据。
- 我试过 This link 中的脚本
- 我在 compmgmt.msc 添加了用户权限 远程桌面用户 WinRMRemoteWMIUsers__ WSS_ADMIN_WPG 远程管理用户
任何人都可以提出任何建议吗??
为了 运行 SharePoint 远程命令,请按照下列步骤操作:Remote PowerShell to Manage SharePoint on-premises
本质上,启用远程处理后,您必须启用 CredSSP 访问权限,以便将您的凭据发送到远程和本地计算机,以便您执行 运行 提升的命令。
在服务器上:
Enable-PSRemoting
Enable-WSmanCredSSP -Role Server
winrm set winrm/config/winrs '@{MaxShellsPerUser="25"}'
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="600"}'
在客户端:
Enable-PSRemoting
Enable-WSmanCredSSP -Role Client -DelegateComputer "server2.contoso.com"
然后在客户端就可以进入session了:
Enter-PSSession -ComputerName server2 -Credential $cred -Authentication Credssp