Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Pipe to connect to Powershell

Has anyone been able to connect to powershell via bitbucket pipelines? I have some simple SharePoint code that I house in my bitbucket repo and would like to start deploying those updates via pipelines.

I'm unable to find any documentation on this and was wondering if anyone else has had any experience doing this.  

Not much here, but this is what I have so far...

memory: 2048
- step: &connect-to-powershell
name: Connect to Powershell
- CMD [ "Connect-SPOService", "-Url", $psURL ]

- step: *connect-to-powershell

 ...and this is the error message I recieve.

+ CMD [ "Connect-SPOService", "-Url", $psURL ]
bash: CMD: command not found

 Any help or guidance here would be greatly apprecaited.


Thank you!

2 answers

How to execute multiple lines 

like this one??
New-AzVm `
-ResourceGroupName 'myResourceGroup' `
-Name 'myVM' `
-Location 'East US' `
-VirtualNetworkName 'myVnet' `
-SubnetName 'mySubnet' `
-SecurityGroupName 'myNetworkSecurityGroup' `
-PublicIpAddressName 'myPublicIpAddress' `
-OpenPorts 80,3389

Hi @Vishal Singh ,

Try something like this:


0 votes
Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Aug 28, 2020 • edited

@John Issa you can see 'bash' in error log.

It means by default pipeline supports bash commands.

But you can try execute in a script  powershell commands you need via pwsh tool.

For example:

name: powershell
- pwsh -Command {Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable}


Also, looks like powershell does not have sharepoint installed. You can do something for this.

If you don't succeed with that, you can try going with Custom pipe. Look how you can create your custom pipe here . Because I see, that executing this just in pipeline seems quite complex.

Regards, Galyna

... or a little easier on the eyes + multiline support. 

name: Gotta have pwsh
- >-
pwsh -Command "& {
Write-Host 'Hello Powershell'
Like Dmytro Shchepak likes this

@Halyna Berezovska @Cronje van Heerden 

Could you please suggest how to execute pwsh command on the remote server?
Want to:
- make a backup,
- stop IIS,
- copy a new site,
- launch IIS.

I'll be appreciated for any help.

I have tried a few ways but still can't solve how to do this.


#2nd step to deploy to server

- step:

name: Deploy to server

deployment: staging


- pipe: atlassian/scp-deploy:1.1.0


USER: 'deploy' # $USER



LOCAL_PATH: 'release/*'

# DEBUG: 'true'

EXTRA_ARGS: ["-P", "8022"] #port

#3rd step runs script on server

- step:

#name: powershell



- pwsh -Command {Enter-PSSession -HostName '' -UserName 'deploy'}

- pwsh -Command {Invoke-Command -ComputerName '' -ScriptBlock {Get-UICulture}}

- pwsh -Command {cmd /c ver}

- pwsh -Command {Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable}

- pwsh -Command {Copy-Item -Path "c:\inetpub\GS 2.0_SM" -Destination "d:\ttt\site backup\*" -Recurse}

I haven't considered that use case before .. my guess would be that the permissions and port forwarding requirements for remote Powershell would be a problem if you're running this from Atlassian Cloud build runners.

If it's an option to run docker containers on the target server I'd try running a self-hosted build runner on the target server with a volume mapped to the target IIS folder only. 

Thanks for the so fast answer.

We don't use Docker, maybe it'll be in the future.

Previously I sought to try to use some batch script but PowerShell looks smarter.

Maybe it has sense make some research , I hope it can help reach the aim.
I'll try to look.

@Dmytro Shchepak 


I am working on similar kind of requirement, did you find a solution for this? please suggest.

- make a backup,
- stop IIS,
- copy a new site,
- launch IIS.

Thanks in advance.

[PowerShell Remoting Over SSH - PowerShell | Microsoft Docs]( may be a way to technically achieving this, but the security implications of a allowing Powershell access from a Bitbucket-Pipelines cloud agent sounds very scary.

In my environment we use Octopus Deploy, Intune or Azure Automation to run Powershell in automation.

Azure Pipelines runner would also be an option - you can run one free one I think, and it would be possible to trigger it from a Bitbucket Pipeline.

I'd also be very interested if anyone knows about a secure and simple way to run Powershell from a Bitbucket-Pipeline directly.

@Sharath Chakalifinally decided to move to Azure DevOps. :)

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events