Out-CSV Revised

A while ago I published a short function to create CSV strings. While working on another task I came across $OFS, which is something I know about but never really think about. $OFS is an intrinsic PowerShell variable that controls the output field separator for arrays. You can modify this variable which made me realize there was a better way to handle my Out-CSV function. Here’s the revised function.

Read More

Registering PrimalPad as your default editor

Associating a file type with a specific application has always been fairly easy to do under the various incarnations of Windows. Basically, you can right-click on a file of the type you wish to use, select the Open With | Choose Program context menu option, then select the program like PrimalPad from the list or […]

Read More

A PowerShell Port Scan

I recently guest-hosted Episode 69 the PowerScripting Podcast. One of the items we discussed was a port scanning script from TheAdminGuy blog. Here’s the original script: http://theadminguy.wordpress.com/2009/04/30/portscan-with-powershell/. As written, there’s nothing technically wrong with it. The script gets the job done and tells the user which ports are open. However, I thought this was an opportunity to demonstrate an even more PowerShell-like approach. Even the author admits there are limitations to his script.

Whenever I see a script like this, the first thing I try to do is separate the functionality. In the VBScript days we would write monolithic scripts to do everything. Sure, we might write a function or subroutine, but based on my forum experiences, even that was not a common occurrence. In PowerShell, we want to use smaller, cmdlet-like tools that leverage the pipeline.

Read More

Sometimes an Apple is an Orange

I was helping a member out in the PowerShell forum at ScriptingAnswers.com. He was trying to create a multistring registry entry on a remote computer using the .NET registry classes. Creating registry values is really not that complicated. Here’s a short example.

Read More

May PowerShell Oneliner

In case you missed this recent SAPIEN newsletter, here’s my one liner for this month. I have a quick one-liner that will create a random filename with a preferred file extension in a folder that you specify. By default the GetRandomFileName() method will return a short 8.3 string with a random file name and extension. […]

Read More

Cool Config Creation

In my recent Special Forces PowerShell class, one of the students brought up a challenge he was facing when we were talking about the -f replacement operator. This is a handy way to build strings.

PS C:\> “Hello, {0}. It is now {1} and you have {2} processes running.” -f $env:username,(get-date).ToShortDateString(),
(get-process | measure-object).count
Hello, Jeff. It is now 5/5/2009 and you have 82 processes running.

Paul needed to build configuration files and was looking for an easy way, perhaps using a here string as a template. We tossed around a few ideas. When I got home I decided to see what I could come up with. What I have is a proof of concept really, but it might get you started.

Read More

Managing for VMWare now Printing

Hal Rottenberg’s Managing VMWare Infrastructure with Windows PowerShell: TFM if finally PRINTING!!! An initial order has been placed to fulfill all of the pre-orders so yours should be coming soon. The book is on sales at ScriptingOutpost.com. The page may still say pre-orders only but the book is being printed.  We’ll also be offering an […]

Read More

Managing VMWare Infrastructure with Windows PowerShell:TFM Sample

Hal Rottenberg‘s new book Managing VMWare Infrastructure with Windows PowerShell: TFM is getting very close to hitting the shelves. We’re in the very final stages of production. But in the mean time you can visit SAPIEN Press and download a sample chapter from the book. You’ll also find a zip file with all of Hal’s […]

Read More

The Mission Will Start Without You

I’ll be in Boston next week running our Special Forces PowerShell training course. There’s still room for a few recruits on this mission, but you absolutely must register by April 24th.  Sooner is actually better to make sure your training equipment arrives in time. Don’t put this off any longer.  Register online at http://www.scriptingoutpost.com/p-81-special-forces-training-windows-powershell.aspx.

Read More

Search

Enter any query and press enter
Advanced search operators:
+ ⟶ Term must appear
- ⟶ Term must not appear
"" ⟶ Exact string must appear
How do I use these?

Join our mailing list

Enter your email address to subscribe to our mailing lists for Monthly Blog Digests, Product Announcements and more (you can choose which you receive once you sign-up!)

Tags

Categories

Archives

Dashboard