With 2,300 cmdlets and counting, PowerShell can automate a lot of tasks and free up valuable time for admins. But as admins begin to tackle learning PowerShell, lots of questions come up about specific tasks and actions PowerShell can take care of.
Don Jones, PowerShell expert, answers some of the questions he's heard from administrators learning to harness the features of PowerShell. This short FAQ highlights some of the questions he's answered about specific PowerShell capabilities.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
How can I use PowerShell to read XML files?
PowerShell can load XML contents because XML is essentially just text, but admins will have to create a command that not only loads content, but also forces PowerShell to parse it if you want the XML contents read. The command may look something like this:
[xml]$xml = Get-Content MyXML.xml
Admins will most likely have to experiment in PowerShell to get exactly what they want, but there are many options to add and remove attributes and nodes to eventually create a text file. Admins may also want to consider learning XPath, a XML query language that can search and process specific attributes and nodes within an XML file.
How do I know if I should use PowerShell workflow?
PowerShell workflows are one of the most talked about features, but they're also one of the most confusing features. Similar to a PowerShell function, they can support features not necessarily found in PowerShell itself.
The reason why workflows can be confusing? Workflows lack features found in PowerShell because they are processed through Windows Workflow Foundation (WinWF), which means they follow WinWF rules even though you're using PowerShell syntax.
It has a steep learning curve, but the benefits can make it worth your while. There are many built-in parameters that are useful, plus it has the distinct ability to interrupt and resume, which can accommodate temporary failures like outages.
What are some ways I can make my PowerShell format look better?
Unfortunately, there isn't a simple answer to this question, but there are a few options admins can look into to make it happen.
If admins are willing to do a little extra reading, there are a few free e-books available that specifically address this question. Admins can learn how to create HTML-based reports with visual formatting, as well as learn how to use SQL Server Reporting Services to create a heavily formatted report.