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 6889305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:08:21+00:00 2026-05-27T06:08:21+00:00

I was looking over what’s coming with the next WinRM and PowerShell 3 and

  • 0

I was looking over what’s coming with the next WinRM and PowerShell 3 and I was looking through the list of breaking changes and saw something that I’d never seen before.

The example was:

$server = "msp42"
$status = "online"
"$server: $status"

The resulting output was:

online

OK, I’d never encountered that before and have no clue why the colon caused an issue.
A solution suggested in the document was to put a space (which is silly because then you change the output):

"$server : $status"

Another suggestion was to use this format (new to me!):

"${server}: $status"

The final suggestion was to make an expression, which I am familiar with and use all the time:

"$($server): $status"

So, my questions to you PowerShell gurus out there are:

  1. What the heck is up with that colon? Does it do something?

  2. What the heck is the ${variable} syntax? Is it strictly to deal with the colon or does it have some neat features?

  • 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-05-27T06:08:22+00:00Added an answer on May 27, 2026 at 6:08 am

    The colon is a valid character for variable names, e.g. in $Env:PATH, etc.

    You can use the following option, too

    $server`: $status
    

    or, for some cases a format string is more readable:

    '{0}: {1}' -f $server, $status
    

    Back to the colon. There is a special case for variable names that correspond to an item on a PSDrive:

    $Env:Foo           # equivalent to the contents of Env:\Foo
    $Function:C:       # equivalent to the contents of Function:\C:
    ${C:\autoexec.bat} # ... you get the picture
    

    The syntax ${} exists to be able to specify variable names that otherwise use characters reserved for other parts of the syntax. You could see it as being similar (but more powerful) to C#’s @ in front of identifiers. See above where a \ is used in the variable name, since $Drive:Item only works for the current container on a drive (or the root for non-hierarchic ones like Env, Alias or Function).

    Another example where the variable name would be normally invalid syntax:

    PS> $+
    The term '$+' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
    spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:1
    + $+
    + ~~
        + CategoryInfo          : ObjectNotFound: ($+:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    
    PS> ${+} = 5
    PS> ${+}
    5
    PS> Get-Variable +
    
    Name                           Value
    ----                           -----
    +                              5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was looking over the list of functions that were exported from a dll
I was looking over some of our JavaScript compression and noticed that no strings
I am looking over someone Else's code and noticed that some of the user
I am looking over some code that has heavy use of Java's instanceof operator.
I was looking over some code that another developer wrote and found this: Private
I'm looking over some code and I came across some syntax that I don't
I never used Java, but I'm looking over a big server project writting in
From looking over the documentation, it seems that the form clean() method is only
I've been looking over the jQuery docs and it indicates that .load is a
While looking over some code, I found a function that seems to do exactly

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.