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

  • SEARCH
  • Home
  • 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 8515675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:12:52+00:00 2026-06-11T05:12:52+00:00

On a whim, in order to learn PowerShell, which I know I’m woefully behind

  • 0

On a whim, in order to learn PowerShell, which I know I’m woefully behind on, I decided to write a super simple script to use MSBuild to clean a bunch of solutions in code, then build them with a certain set of arguments. Here’s the script:

$sourceDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$cleanArgs = '/t:clean /verbosity:q /nologo /P:Configuration=Debug'
$buildArgs = '/verbosity:q /nologo /P:Platform="Any CPU";Configuration=Debug'
$solutions = @("asdf.sln","qwer.sln","zxcv.sln","yuio.sln","hjkl.sln","nm.sln")

function buildWithArgs([string[]]$solutionsToBuild = @(), [string]$args = 'default')
{
    Write-Host args: $args
    foreach($sln in $solutionsToBuild)
    {
        & $env:WINDIR\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe "$sourceDir\$sln $args" | Out-Default
    }
}

buildWithArgs $solutions $buildArgs
buildWithArgs $solutions $cleanArgs

Now, my problem is that the function “buildWithArgs” doesn’t respect the $args parameter, which is always empty when I run or debug the script, no matter what I pass in. The $solutionsToBuild parameter works flawlessly, however. Do I have improper syntax? Even if it were the case that my $cleanArgs string was somehow improperly formatted or not escaped, I can’t even make the function work with simple strings like “asdf”, as $args is always empty when I run it. Thanks for any help you can provide to what is assuredly some small, silly error!

  • 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-11T05:12:53+00:00Added an answer on June 11, 2026 at 5:12 am

    First, $args is a special, built-in parameter in PowerShell, which represents all the arguments to a function. One of the side-effects to this is you can’t see its value in the ISE debugger. Try changing its name to MSBuildArgs.

    Make sure you define, buildArgs and cleanArgs as arrays. You’re defining them as one single string. You do this so you can use PowerShell’s splat operator (@ instead of $ when referencing a variable), which sends each argument in an array as a parameter to a command.

    Lastly, you don’t need to quote parameters that are stored in variables. PowerShell will do any quoting for you.

    After making these changes, you’ll have something like this:

    $sourceDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
    $cleanArgs = @('/t:clean','/verbosity:q','/nologo','/P:Configuration=Debug')
    $buildArgs = @('/verbosity:q','/nologo','/P:Platform="Any CPU";Configuration=Debug')
    $solutions = @("asdf.sln","qwer.sln","zxcv.sln","yuio.sln","hjkl.sln","nm.sln")
    
    function buildWithArgs([string[]]$solutionsToBuild = @(), [string[]]$MSBuildArgs= 'default')
    {
        Write-Host args: $args
        foreach($sln in $solutionsToBuild)
        {
            $msbuildPath = Join-Path $env:WINDIR Microsoft.NET\Framework64\v4.0.30319\msbuild.exe -Resolve
            & $msbuildPath (Join-Path $sourceDir $sln -Resolve) @MSBuildArgs | `
                Out-Default
        }
    }
    
    buildWithArgs $solutions $buildArgs
    buildWithArgs $solutions $cleanArgs
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On a whim, I've decided to go back and seek certification, starting with 98-361,
UDPATE On a whim, I decided to upload the 4 fonts files to an
I'm making a very simple ad button system using ASP.NET 2.0 The advertisment is
On a whim, I tried to define the main function as a template function
Ok, I really don't know how to frame the question properly because I barely
I'm writing an application which has to be configurable to connect to Oracle, SQL
I'm a longtime Java guy, and know that the way to run a JAR
Quick question, of which the quickest and easiest answer may well be to rearrange
I have the following code: <html> <head> <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js></script> <script> $(document).ready(function() { // hides
I've got the following Perl code which makes a DBI call: my $artsql =

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.