简体   繁体   English

从Team Foundation Build调用的Powershell脚本远程执行

[英]Remote Execution from Powershell Script called from Team Foundation Build

I am trying to deploy a sharepoint solution with a sharepoint script, with this approach: 我正在尝试使用sharepoint脚本部署sharepoint解决方案,使用以下方法:

First i test the environment, using windows powershell console 首先,我使用Windows PowerShell控制台测试环境

New-PSSession -ComputerName developmentserver01
Enter-PSSession -computername developmentserver01
d:
cd d:\deploymentscripts
.\deploysharepoint.ps1

Then i start the automation: 然后我开始自动化:

1.- TFS runs a build that call at the end to "deploy.ps1" locally in the build server. 1.- TFS运行一个构建,在构建服务器本地调用“deploy.ps1”。 ---> this is working. --->这是有效的。

2.- desploy1.ps1 copy the drop files to the development environment developmentserver01 shared folder. 2.- desploy1.ps1将drop文件复制到开发环境developmentserver01共享文件夹。

3.- after copy the files, deploy1.ps1 connet with the development environment machine developmentserver01 using remote connection commands from powershell -->this is working. 3.-复制文件后,使用来自powershell的远程连接命令将deploy1.ps1 connet与开发环境机器developmentserver01连接 - >这是有效的。

4.- this step fails, in this step i try to execute the deployment script deploySharepoint.ps1 that has copied in the development environment machine in the step 2. First using commands inside the script like in the powershell console, but i see that the commands are running inside the TFS build machine not in the machine that i connected whit remote connection 4.-此步骤失败,在此步骤中,我尝试执行已在步骤2中在开发环境机器中复制的部署脚本deploySharepoint.ps1。首先在PowerShell控制台中使用脚本内的命令,但我看到命令在TFS构建机器内运行,而不是在我连接的远程连接机器上运行

d:
cd d:\deploymentscripts
.\deploysharepoint.ps1

Later using different options (invoke-command, ...) only this optionk works: 稍后使用不同的选项(invoke-command,...)只有这个optionk工作:

Invoke-Command -computername developmentserver01 -scriptblock{d:\DeploymentScripts\deploysharepoint.ps1 -solutionNames @("parameter1")}

The problem it´s that i think that invoke-command don´t work like the commands using powershell console , because the script show the error that the user don´t haver permissions for accesing the Farm of sharepoint. 问题在于我认为invoke-command不像使用powershell控制台的命令那样工作,因为脚本显示用户没有访问Sharepoint的权限的错误。

If i run the script with remote session in a power shell console as show at the beginning of the post, all things work fine. 如果我在电源shell控制台中运行带有远程会话的脚本,如帖子开头所示,一切正常。

How can i run the remote script deploysharepoint.ps1 with remote session from the script desploy.ps1, like using powershell console? 如何使用来自脚本desploy.ps1的远程会话运行远程脚本deploysharepoint.ps1,就像使用powershell控制台一样?

invoke-command is the right answer. invoke-command是正确的答案。 But: 但:

the script show the error that the user don´t haver permissions for accesing the Farm of sharepoint. 该脚本显示用户没有访问Share of Farm的权限的错误。

If the3 script is being invoked (locally or remotely) by the TFS Build's user account, then that account is used to determine permissions. 如果TFS Build的用户帐户(本地或远程)调用3脚本,则该帐户用于确定权限。

So either change the account used to run the build to one that has the right SharePoint permissions, or give the TFS Build account the necessary permission. 因此,要么将用于运行构建的帐户更改为具有正确SharePoint权限的帐户,要么为TFS构建帐户授予必要的权限。

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

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