Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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!

1 answer

@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.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

239 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you