Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8128523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:55:02+00:00 2026-06-06T07:55:02+00:00

In the below powershell script I am passing three string parameters. The $ComputerName parameter

  • 0

In the below powershell script I am passing three string parameters. The $ComputerName parameter line works as expected. I am able to remote into the machine that I specify.

Issue 1
On the line $latestbuildfolder I am using $builddefinition parameter to specify build definition. It appends the name of the builddefinition but does not list folder inside that folder. If I replace $BuildDefinition parameter by “TeamBuild” our build definition name then it is able to list all the folders and get the latest folder. Some how I feel the join is not working. I have tried using Join-Path too and still not working.

Issue 2
On the line $deploycmdlocation when I try to specify $Configuration in that string it is not working. It outputs a blank between that path. I checked using Write-Host and the parameters is passed to the script.

param(
[System.String] $ComputerName,
[System.String] $Configuration,
[System.String] $BuildDefinition
)
$session = New-PSSession -ComputerName $ComputerName 
Invoke-Command -Session $session -ScriptBlock {
$latestbuildfolder = Get-ChildItem "C:\procmon\procmonBuilds\$BuildDefinition" | Sort-Object LastWriteTime -Descending | SELECT-Object -First 1
$deploycmdlocation = "\procmon\procmonWebProject\$Configuration\_PublishedWebsites\procmonWebProject_Package\procmonWebProject.zip"
$finalstring = $latestbuildfolder.FullName + $deploycmdlocation
$finalstring
}
Remove-PSSession $session

I have tried lots of options and still no luck so far.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T07:55:03+00:00Added an answer on June 6, 2026 at 7:55 am

    The solution that worked for me just felt like Inception movie. It turns out that I have to declare param at two places. Thanks to my co-worker friend for this solution.

    Here is the final script that works for me. This is a script that runs on build machine and then does a new-pssession on remote computer get web packages from latest build drops folder. Those parameters are passed through process template activity Invoke-Process used to invoke powershell scripts.

    param(
    [System.String] $ComputerName,
    [System.String] $Config,
    [System.String] $BuildDef
    )
    $session = New-PSSession -ComputerName $ComputerName 
    Invoke-Command -Session $session -ScriptBlock {
    param(
    [string] $ComputerName,
    [string] $Configuration,
    [string] $BuildDefinition
    $latestbuildfolder = Get-ChildItem "C:\procmon\procmonBuilds\$BuildDefinition" | Sort-Object LastWriteTime -Descending | SELECT-Object -First 1
    $deploycmdlocation = "\procmon\procmonWebProject\$Configuration\_PublishedWebsites\procmonWebProject_Package\procmonWebProject.zip"
    $finalstring = $latestbuildfolder.FullName + $deploycmdlocation
    $finalstring
    } -args $ComputerName, $Config, $BuildDef
    Remove-PSSession $session
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the PowerShell script below to set anonymous user identity and authentication methods
i Have an arguments like the one below which i pass to powershell script
What should I use to accomplish the task desribed below? CMD.exe? PowerShell? Windows Script
The below script puts database backup details into a nicely formatted table with borders
I am inserting rows into a table from a Powershell script. I loop through
I have a powershell script (below) which seems to work but prints an error
I'm trying to execute a powershell script located at a remote machine using the
I'm a newbie to PowerShell. What's wrong with my script below? It's not wanting
I have a powershell script below which takes a config file and deletes files
I'm writing a powershell v2 script that I'd like to run against a remote

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.