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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

using Bamboo password variable to connect remote machine via powershell script

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;

  

1 answer

1 accepted

1 vote
Answer accepted
Jimmy Seddon Community Leader Apr 06, 2020

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.

Like Jimmy Seddon likes this
Jimmy Seddon Community Leader Apr 06, 2020

I'm glad you were able to get past that!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 7.2 is here!

I'm happy to announce that Bamboo 7.2 has been released and it’s overflowing with awesome new features. This will be the last major Server release before the launch of Bamboo DC. Bamboo logs We...

489 views 5 7
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