Posts Tagged ‘function’
I needed a demonstration for one of my last online PowerShell classes on using COM objects in PowerShell. I took an old VBScript that used Microsoft Word to get document statistics such as word and page count and transformed it into PowerShell. I quickly realized I could flesh out the demo into a larger function that I can actually use. Given that I generate a lot of Word docs, being able to get some document statistics is helpful. So I created a function called Get-DocStatistic.   More »
PowerShell InputBox
Wednesday, August 13th, 2008 by Jeffery Hicks
The other day I gave you a function to create a VBScript style message box in PowerShell. If you find yourself needing MsgBox in PowerShell, you're likely going to want InputBox.   More »
PowerShell MsgBox
Tuesday, August 12th, 2008 by Jeffery Hicks
if you came from the VBScript world you may be missing a few old friends in PowerShell. Because Powershell is a management console, it lacks a GUI unless you create one using Windows forms. Things will change a bit in PowerShell v2.0 but for now let's stick with what we have. If you really need a message box, ala VBScript, then simply call it from PowerShell. All you need to do is use the [microsoft.visualbasic.interaction] class and the MsgBox method.   More »
PowerShell: DriveUtilization
Friday, August 1st, 2008 by Jeffery Hicks
The other day I posted a VBS function for getting drive utilization. It seems only fair to give PowerShell a chance to play.   More »
VBScript: Drive Utilization
Wednesday, July 30th, 2008 by Jeffery Hicks
Here's another recent topic from the ScriptingAnswers.com forums which I thought I'd share. The forum members wanted to delete files if the drive utilization exceeded a certain threshold. Using Windows Management Instrumentation (WMI) with VBScript I came up with something like this...   More »
Fun with Debug Messages
Wednesday, July 23rd, 2008 by Jeffery Hicks
In my script and function development, I often add the line $DebugPreference="SilentlyContinue" to the beginning of my code. Throughout the script I add lines using Write-Debug that tell me what the script is doing or the value of a particular variable. This has been very helpful. When I want to see the debug messages, I set $DebugPreference to "Continue" and voila!. In PrimalScript all the messages are written to the debug panel. But I wanted more .   More »
Clean Temp With PowerShell
Friday, July 18th, 2008 by Jeffery Hicks
You would think that by now Windows and Windows applications would be much better about cleaning up temporary files. But no. It is amazing how many files I still see in my %TEMP% directory. I've always operated under the assumption that any file in %TEMP% that was created or earlier than the time I last booted up is fair game for deletion. I finally got around to using PowerShell for this management task.   More »
Get-Tweet
Friday, June 27th, 2008 by Jeffery Hicks
Since I find myself spending so much time in a PowerShell console, I'm always trying to find ways to stay. I recently posted my version of a PowerShell script to send a message to Twitter. But that's only half the story. If I want to check for recent tweets I have to switch to Firefox and the use the Twitterfox addon. But since everything in Twitter comes via a web page or RSS feed, it is pretty simple to use the System.Net.Webclient class in a PowerShell script to get what I want. To that end I wrote a function called Get-Tweet to return recent tweets.   More »







