You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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...
definitions:
services:
docker:
memory: 2048
steps:
- step: &connect-to-powershell
name: Connect to Powershell
image: mcr.microsoft.com/powershell
script:
- CMD [ "Connect-SPOService", "-Url", $psURL ]
pipelines:
branches:
master:
- 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!
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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:
step:
name: powershell
image: mcr.microsoft.com/powershell
script:
- 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
... or a little easier on the eyes + multiline support.
name: Gotta have pwsh
image: mcr.microsoft.com/powershell
script:
- >-
pwsh -Command "& {
Write-Host 'Hello Powershell'
}"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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
script:
- pipe: atlassian/scp-deploy:1.1.0
variables:
USER: 'deploy' # $USER
SERVER: '1.1.1.1' # $SERVER
REMOTE_PATH: 'D:/ttt/' # $REMOTE_PATH
LOCAL_PATH: 'release/*'
# DEBUG: 'true'
EXTRA_ARGS: ["-P", "8022"] #port
#3rd step runs script on server
- step:
#name: powershell
image: mcr.microsoft.com/powershell
script:
- pwsh -Command {Enter-PSSession -HostName '1.1.1.1' -UserName 'deploy'}
- pwsh -Command {Invoke-Command -ComputerName '1.1.1.1' -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}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 http://techdiksha.com/run-powershell-scripts-remote-machine-azure-release-pipeline/ , I hope it can help reach the aim.
I'll try to look.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
[PowerShell Remoting Over SSH - PowerShell | Microsoft Docs](https://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/ssh-remoting-in-powershell-core?view=powershell-7.2) 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.