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
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I am trying to connect to remote machine using powershell to copy files/ install app on the remote server from bamboo agent. It works fine when I hard-code the password in the PS script but when I use bamboo variable it doesn't work as expected. Can someone point me in the right direction ?
I am using script to set up pipeline
Script
$username = "domain\Account";
$stringpassword = "Password"; # Works as expected
#$stringpassword = ${bamboo.Password}; #Doesn't connect to remote machine
$password=ConvertTo-SecureString -String $stringpassword -AsPlainText -Force;
New-Item -Force -Path "D:\Apps\TestFile.txt"
Add-Content "D:\Apps\TestFile.txt" -value "test_plain";
$pscred = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $password;
$Session = New-PSSession -Name "Test" -ComputerName "Remote Server" -Credential $pscred;
$File = [System.IO.File]::ReadAllBytes("D:\Apps\TestFile.txt");
Invoke-Command -Session $Session -ArgumentList $File -ScriptBlock{[System.IO.File]::WriteAllBytes("E:\Apps\test1.txt", $args)};
Get-PSSession -ComputerName "Remote Server"|Where-Object{$_.Name -eq "Test"} | Remove-PSSession;
Hi @Premlme,
I would be wrapping the Bamboo variable in in quotes the same way you were when hard-coding the password. Bamboo does some weird things when passing strings around in variables.
$stringpassword = "${bamboo.Password}"; #Doesn't connect to remote machine
Give that a try and see if it helps.
-Jimmy
@Jimmy Seddon , It's working, its working !!! Thanks a lot, have been stuck here for a day or so. Thanks a ton for your prompt reply , cheers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm glad you were able to get past that!
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.