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

Master-Level Microsoft Stack Training with John Savill

Get 30 hours of comprehensive training covering the complete Microsoft solution stack. Invest a few hours each week and become the #1 Microsoft expert in your organization.

Past Sessions Available for Instant Access!
Semester 2: January 22nd to February 19th
Access to Recordings through May 20, 2015

John Savill will cover topics including:

* Deploying, Managing, and Maintaining Windows
* Key Features of Active Directory from Windows 2000 to Windows Server 2012
* Key elements of System Center 2012 and System Center 2012 R2
* Deploying, Migrating to and Managing Hyper-V in Your Organization
* Implementing a Private Cloud
* Using PowerShell to Automate Common Tasks
* PLUS a preview of Windows 10


Windows Forums

The Windows IT Pro forums are moving to! Get answers to questions, share tips, and engage with the IT professional community.

Sponsored Introduction Continue on to (or wait seconds) ×