Understanding PowerShell?s object-orientation can be difficult because there?s no real way to see the objects in action. The first step in understanding, however, is to realize that when you?re using PowerShell, you?re not really using PowerShell.
Category: General
PowerShell’s WMI
I know there’s a lot of confusion, with some folks, around WMI in PowerShell.
For example, this is the first type of WMI usage in PoSH that most folks saw:
$wmi = Get-WMIObject Win32_OperatingSystem
$wmi.ServicePackMajorVersion
Cool enough. Of course, in this example, you’re only ever going to get one instance of a WMI class back; with other classes, you might …
Open Sesame
As you develop more and more scripts, you’re bound to find yourself working with files. Often, the easiest thing to do is to hard code a filename that we want to open and use. Or we may provide a run time parameter for a file name. Wouldn’t it be nice to be give the user an option to browse for the file like other Windows apps? If your script is running on Windows XP or Windows 2003, you can use the SAFRCFileDlg object.
PoSH and Logon Scripts
I’d been under the impression – and said so at some recent conferences – that PowerShell can’t be used for logon scripts. Not so, it turns out, although I still don’t think it’s well-suited for the task.
Let me be clear in that I don’t think logon scripts themselves are well-suited to a task. The primary purpose of logon scripts …
Take Title of your CLI
If you have batch files that require a long time to run or would like to have an easy way to monitor the progress, here’s an easy way.By using the TITLE command, you can change the title of the command prompt window. When you minimize the window to the task bar, the title bar is displayed. If you change the title as your script progresses you can easily monitor it’s progress.
Write-What?
Okay… I hope I’m not the last person in the world to have figured this out or I’ll feel dumber than I already do.
I’ve been messing with PowerShell a lot and couldn’t figure out what the difference was between write-output and write-host, two cmdlets that both APPEAR to do the same thing. But now I get it.
My first …
Hearing Voices
I’ve been toying around with text to speech in scripts both in VBScript and PowerShell. I thought I’d share some thoughts and techniques for working with these objects. I’m still trying to find a truly practical need for this in an administrative script, but this is interesting technology to kick around.
CMD ala MODE
I love a nice command prompt window. I typically customize the CMD shortcut so that the window size is set the way I like it. However, this can also be done on the fly and even from a batch file. Should you need to resize the command window, you can do this with the MODE command.
If only life were built on PowerShell
The Get-Culture cmdlet in Windows PowerShell does not actually give you an appreciation for art, fine wine, classical music, or opera. ![]()
Create Time Stamped Logs
In my VBScript work I often create log files, either for debugging or as a main component of the script. In a batch file I could never figure out how to get this same type of result. You can use commands like date /t and time /t to get a date stamp or time stamp but combining the two on one line was practically impossible. Until now.