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.

Articles by Don Jones
Getting Started with PowerShell 2
Why are so many admins afraid of little old PowerShell? Probably because they don't understand it. Don't let common misconceptions stand in your way -- get to know the power of PowerShell and increase your value in the workforce.
Creating Remote Sessions in PowerShell 2.0
Whether you want to connect to one or many remote computers, PowerShell 2.0's remoting capabilities make it easy.
A Concentrated Guide to PowerShell Functions 5
Windows PowerShell 2.0 offers several ways to modularize a set of commands, with solutions ranging from easy to complex.
Q. Where can I find out about books, add-ons, and other PowerShell resources?

A. You're in the right place—PowerShell FAQs and my blogs are accessible from windowsitpro.com/go/DonJonesPowerShell, and they're a great place to start. I also have my own site, ShellHub.com, which is nothing but a directory of hand-selected resources, including free and commercial PowerShell add-ons.

 

Q. Can binary modules be imported from network shares?

A. Yes, but it can be tricky. I recommend reviewing "Importing Binary Modules from Network Shares", which has a pretty thorough explanation.

 

Q. Do normal Windows commands run in PowerShell? 1

A. Generally, yes. There are times, however, when PowerShell's parsing of commands results in unexpected and confusing errors. Sometimes, you'll need to enclose your entire command string within quotation marks and use the shell's invoke operator to run the command:

&"SC.EXE STOP WUAUSERV"

That's a good example because it uses the external Sc.exe command rather than PowerShell's internal SC alias. If you just run

Debugging in Windows PowerShell
Bugs are an inevitable part of life when you write PowerShell scripts. Here are some basic techniques for hunting down and squashing bugs and some practices that can help keep bugs at bay.
Q. Are 64-bit and 32-bit PowerShell the same?

A. Nope. For the most part, you won't encounter any differences, but each version of the shell can only load matching snap-ins in some cases, meaning you'll have to be careful to download the correct 64- or 32-bit edition of any add-ons you want to use. Apart from add-on compatibility, there aren't any major functional differences between the two versions.

 

Q. Can PowerShell scripts run under alternate credentials?

A. The short answer is no, not easily. You can certainly schedule a script to run under alternate credentials, using Task Scheduler's ability to specify the credentials. You can also use a script packager.

Q. Can PowerShell read and parse XML files?

A. Yes, although the means isn't very obvious. If you have an XML file named Mine.xml, do this:

\\[xml\\]$xml = Get-Content Mine.xml

That'll read the file, parse the XML, and construct within the $xml variable an object tree based on the XML structure. Run

Q. How can I map a network drive in PowerShell?

A. To use strictly within PowerShell, use the New-PSDrive cmdlet. The resulting drive won't be visible in Explorer. If you want to map a more traditional systemwide network drive, use good ol' NET USE, just like you would have done in Cmd.exe.

 

Q. How do I use Test-Connection in PowerShell?

A. This cmdlet basically uses WMI's Win32_PingStatus under the hood. It returns, by default, four "result" objects, each of which contains various properties, including a StatusCode, which will be 0 for successful pings. Sometimes, you just want to know if it worked or not, without all that extra information. In those cases, use:

Test-Connection remotehost -quiet

And you'll get back a simple True or False, which can be used in an If construct:

Q. Can I create custom table views in PowerShell?

A. Yes, although it's complicated and not well-documented. You can find examples to copy and paste in PowerShell's installation folder. Within the shell, run

Q. Can I access databases from within PowerShell?

A. Absolutely. I wrote a quick blog tutorial on this exact topic: "Database Access within PowerShell". It shows you how to use both SQL Server and non-SQL Server databases. You'll basically be using elements of the .NET Framework rather than normal PowerShell cmdlets.

 

Q. Why can't I pipe a formatted table to a CSV file?

A. You can, but the CSV file will contain the output of the Format-Table cmdlet, which probably isn't what you want. Format cmdlets produce objects that tell the shell how to construct an on-screen display, which is why this produces such ugly output, as this example shows:

IT/Dev Connections

Las Vegas
September 30th - October 4th

Paul ThurottYou'll have the opportunity to experience:
• The Microsoft
Technology Roadmap
• Office 365 Implementation
• Hyper-V Optimizing
• Windows 8 Deployment
and much more!

Come See Paul Thurrott & Rod Trent in Person!

Early Registration Now Open

Upcoming Training

Mastering SharePoint 2013: Succeeding, Not Just Surviving

Building on the success of the “Mastering SharePoint 2010” seminars, the presenters have updated the content to cover the latest and greatest SharePoint product: SharePoint 2013. While SharePoint 2013 is relatively new on the marketplace, the presenters have been working with SharePoint 2013 for well over a year, and have implemented it with a number of clients in production environments.

Register Now

Current Issue

May 2013 - The NameTranslate object is useful when you need to translate Active Directory object names between different formats, but it's awkward to use from PowerShell. Here's a PowerShell script that eliminates the awkwardness.

CURRENT ISSUE / ARCHIVE / SUBSCRIBE

Windows Forums

Get answers to questions, share tips, and engage with the Windows Community in our Forums.