Don Jones

Don Jones has more than 15 years of IT experience, is the author of more than 35 books, and is a speaker at technology conferences such as Microsoft TechEd and Windows Connections. He's a multiple-year recipient of Microsoft's MVP award and is a technical guide for PowerShell for Windows IT Pro.

6 small penguins on the ice
Q. How can I have my PowerShell script display output in a table?
Let's say you want your script to retrieve and display two pieces of information—the BIOS serial number and Windows version—it in a table.
screenshot of PowerShell script on blue screen
Q. Is PowerShell a scripting language?
Someone's going to get mad at me no matter which way I answer this, so I'll say "yes and no."
Pen on a paper with a chart on it
Q. Should I ever use Write-Host in PowerShell? 2
You should rarely use the Write-Host cmdlet. Write-Host puts content directly on the screen. If that's all you need to do, then you can use it.
PowerShell logo on light blue background with vertical lines
Q. How can I display output in Windows PowerShell?
This is a common question from folks who are used to using something like VBScript's WScript.Popup or WScript.Echo. There are a few choices.
Plane flying across blue sky with cloud trail
Q. Can I declare constants in Windows PowerShell?
To declare constants, you use the New-Variable cmdlet. It includes a switch that lets you define the new variable as a constant, meaning its value can't be changed.
laptop screen showing a line of black folders with one red folder
Q. How can I get just the first entry from a list of entries?
If you've saved the objects in a variable, as in these examples, you could also use syntax such as $services[0] to access the first object in the collection.
ski tracks on a snowy landscape
Q. How can I make a PowerShell script or function have mandatory parameters?
There are a couple of ways to have mandatory parameters. The best way is to use the [CmdletBinding()] parameter syntax, as described in PowerShell's about_functions_advanced_parameters Help topic.
Lava lamp with yellow blob on blue background
Q. How can I query processor cores or sockets using PowerShell? 1
To query processor cores or sockets, you run a script and follow specific procedures.
swimmer in pool lane view from above
Q. How can I run a PowerShell cmdlet against a remote computer?
If the cmdlet has a -computerName parameter, then just use that. Otherwise, you'll need to use remoting.
blue abstract shell on white background
Q. How do I make a PowerShell function support ShouldProcess?
To support support ShouldProcess, your function must include the [CmdletBinding(SupportsShouldProcess=$true)] attribute.
Laptop screen showing a laptop showing a laptop with birds
Q. How can I use a PowerShell cmdlet that's in a module on another computer?
You can use a PowerShell cmdlet that's in a module on another computer by using a feature called implicit remoting. Start by establishing a remoting session to the computer that contains the module you want.
Q. How do I enable PowerShell remoting in a domain environment? 2

A. You can enable PowerShell routing two ways. The first way is to run

Q. Why can't Invoke-Command accept computer names from the pipeline?

A. The Help file for the Invoke-Command cmdlet indicates that the -computerName parameter accepts pipeline input through ByPropertyName. This suggests that you can pipe in an object that contains a "computername" property and have that property "attach" to the -computerName parameter. Sadly, as near as I can figure out, it doesn't actually work, which seems to be an oversight on Microsoft's part. The -inputObject parameter of Invoke-Command binds any pipeline input of type "object" ByValue.

Q. How can I add syntax help to my PowerShell scripts or functions?

A. I've seen a number of folks spend a lot of effort adding a -help parameter to their scripts or functions—and there's no need! You can add help simply by creating specially formatted comments, as described in PowerShell's own online help. Run

Q. What is CmdletBinding()?

A. In PowerShell, you can run

Azure Master Class

Azure Master Class with John Savill
Live Online Training: Thursdays August 10th to August 31st
Register by August 3rd and Save 20%!

Every organization is currently evaluating how they can utilize the public cloud, what it means, and how to actually get started. This 12 session Master Class will equip you with everything you need to understand, evaluate, deploy and maintain environments that utilize Microsoft Azure including hybrid scenarios.


Join the Conversation

Sponsored Introduction Continue on to (or wait seconds) ×