3

I am trying to deploy a sharepoint solution with a sharepoint script, with this approach:

First i test the environment, using windows powershell console

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. ---> this is working.

2.- desploy1.ps1 copy the drop files to the development environment developmentserver01 shared folder.

3.- after copy the files, deploy1.ps1 connet with the development environment machine developmentserver01 using remote connection commands from powershell -->this is working.

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

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

Later using different options (invoke-command, ...) only this optionk works:

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.

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.

How can i run the remote script deploysharepoint.ps1 with remote session from the script desploy.ps1, like using powershell console?

1 Answer 1

1

invoke-command is the right answer. But:

the script show the error that the user don´t haver permissions for accesing the Farm of sharepoint.

If the3 script is being invoked (locally or remotely) by the TFS Build's user account, then that account is used to determine permissions.

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.

Sign up to request clarification or add additional context in comments.

5 Comments

Yes, i think the same, but if i enter with remote desktop connection to the tfs build server, and execute the steps with powershell console, it´s works fine. It´s like the user that execute the script is not the tfs build account. do you know some command to view the user that it´s connected in the poweshell remote session?. i connect without credentials because i think the build server use the tfs build´s user account, but perhaps the server is connecting to the remote machine with other account.
- i connect with remote desktop to tfs machine using the tfs build´s user account - using powershell console. it´s works fine - launch the script in the remote server fails i think: 1.- Perhaps using the script without credentials, power shell don´t use the credentials of the logged user with remote desktop 2.- the build process works like 1 if you know some command to view the user that it´s connected in the remote powershell session can be helpful
Confirmed it´s a Security problen on the Sharepoint Farm, because if i use other user it´s works fine. It´s time to review the problem with the user in the Farm Administrators group of sharepoint, because i can see that the tfs build´s user, it´s already added. Thanks
@JavierValero: comment #2: that's the testing you need. Using your account proves nothing, you need to use the same account the automated build is using. If working with interactive session but not with batch then add logging to find the first fail and focus on fixing that (work one issue at a time).
The problem was related to the permisions on the Sharepoint config DB, the Tfs-Build and the powershell scripts were OK.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.