我将尝试使用SharePoint脚本部署SharePoint解决方案,步骤如下:
首先,在Windows PowerShell控制台中测试环境。
首先,在Windows PowerShell控制台中测试环境。
New-PSSession -ComputerName developmentserver01
Enter-PSSession -computername developmentserver01
d:
cd d:\deploymentscripts
.\deploysharepoint.ps1
然后我开始自动化:
1.- TFS运行一个构建,最后调用本地的"deploy.ps1" --->这个步骤已经完成。
2.- deploy1.ps1将拷贝的文件复制到开发环境developmentserver01的共享文件夹中。
3.- 文件复制后,deploy1.ps1通过powershell远程连接命令连接到开发环境机器developmentserver01 --->这个步骤已经完成。
4.- 这一步失败了,在这一步中,我尝试执行在第二步中复制到开发环境机器上的部署脚本deploySharepoint.ps1。首先使用脚本内部的命令,就像在powershell控制台中一样,但我发现这些命令在TFS构建机器而不是我用远程连接连接的机器上运行。
d:
cd d:\deploymentscripts
.\deploysharepoint.ps1
后来使用不同的选项(invoke-command,...)只有这个选项起作用:
Invoke-Command -computername developmentserver01 -scriptblock{d:\DeploymentScripts\deploysharepoint.ps1 -solutionNames @("parameter1")}
问题在于我认为invoke-command不能像使用powershell控制台的命令那样工作,因为脚本显示错误,即用户没有权限访问sharepoint Farm。
如果我在power shell控制台中使用远程会话运行脚本,所有事情都很好。
如何从脚本desploy.ps1中使用远程会话运行远程脚本deploysharepoint.ps1,就像使用powershell控制台一样?