I don’t know about your neck of the woods, but it is downright Arctic here. So I thought I’d polish up my PowerShell function to get weather data. #requires -version 3.0 Function Get-MyWeather { <# .Synopsis Get the weather for a US zip code .Description This command will query the Yahoo weather service and return…
Category: Powershell 3.0
Friday Fun: Read Me a Story
A few days ago, someone on Twitter humorously lamented the fact that I expected them to actually read a blog post. After the laughter subsided I thought, well why does he have to? Perhaps I can make it easier for him. Plus I needed something fun for today. So I put together a PowerShell function…
Pimp your Prompt
If you are like me and live in PowerShell, then you spend a great deal of your day looking at your PowerShell prompt. That little indicator in the console and ISE that usually shows where you are. That little part of your PowerShell world is defined by a built-in function called Prompt. You can easily…
Friday Fun: A Random PowerShell Console
This week I thought we’d have a little fun with the PowerShell console and maybe pick up a few scripting techniques along the way. Today I have a function that changes the foreground and background colors of your PowerShell console to random values. But because you might want to go back to your original settings…
More PowerShell Laziness
A few days ago I posted an article on using Update-TypeData to provide shortcuts to object properties. These shortcuts might save a few keystrokes typing, especially if you use tab completion. They can also give you more meaningful output. But you can take this even further and save yourself even more typing. How many of…
Scraping Sysinternals
Recently I was conversing with someone about my PowerShell code that downloads tools from the live Sysinternals site. If you search the Internet, you’ll find plenty of ways to achieve the same goal. But we were running into a problem where PowerShell was failing to get information from the site. From my testing and research…
Test Subnet with PowerShell
A few years ago I published a PowerShell function to test IP addresses on a given subnet. I had an email the other day about it and I decided to refresh it. My new version adds a few bells and whistles that I think you might like. For example, you can now run it from…
Find and Replace Text with PowerShell
I’ve just finished up a series of tweets with a follower who had a question about finding and replacing a bit of data in a text file. In his case it was a web.config file but it really could be any text file that you can view in PowerShell. In PowerShell 3.0 and later this…
Friday Fun: The Measure of a Folder
Last week, I demonstrated how to measure a file with PowerShell. This week let’s go a step further and measure a folder. I’m going to continue to use Measure-Object although this time I will need to use it to measure numeric property values. Here’s the complete function after which I’ll point out a few key…
Convert Text to Object with PowerShell and Regular Expressions
A few weeks ago I was getting more familiar with named captures in regular expressions. With a named capture, you can give your matches meaningful names which makes it easier to access specific captures. The capture is done by prefixing your regular expression pattern with a name. PS C:\> “UNC is \\server01\public” -match “\\\\(?<servername>\w+)\\(?<sharename>\w+)” True…
Creating CIM Scripts without Scripting
When Windows 8 and Windows Server 2012 came out, along with PowerShell 3.0, we got our hands on some terrific technology in the form of the CIM cmdlets. Actually, we got much more than people realize. One of the reasons there was a big bump in the number of shipping modules and cmdlets was CDXML….
Updated Console Graphing in PowerShell
The other day Distinguished Engineer and PowerShell Godfather Jeffrey Snover posted a blog article about the evils of Write-Host. His take, which many agree with, is that Write-Host is a special case cmdlet. In his article he mentions console graphing as an example. I wrote such a script earlier this year. Mr. Snover’s post drove…
PowerShell Clean Up Tools
A few years ago I think I posted some PowerShell clean up tools. These were functions designed to help clear out old files, especially for folders like TEMP. Recently I decided to upgrade them to at least PowerShell 3.0 to take advantage of v3 cmdlets and features. I use these periodically to clean out my…
Turn On PowerShell Help Window
Here’s a little suggestion for today that might make it easier for you to use PowerShell. In PowerShell 3.0, the Get-Help cmdlet includes a terrific new parameter called -ShowWindow. When you ask for help with this parameter, you get complete help in a new window. The window is re-sizable, searchable and customizable. I love this…
Friday Fun: Create a PowerShell Trace Window
Way back in the day, it was all VBScript and HTAs for me. I built a number of HTA tools for other people to use. As you might expect they didn’t always work and troubleshooting something I couldn’t see was difficult. So I came up with a solution to use an Internet Explorer window as…