PowerShell: Get-WinEvent vs. Get-EventLog
Mark Berry April 1, 2011
I’ve been working to write a flexible PowerShell script to retrieve and email warning and error events from computers in a small network. The computers variously run XP, Windows 7, Server 2003, SBS 2008, and Server 2008 R2. I wanted to include the new Applications and Services logs for Vista/2008 and beyond, so for those OSs, I use the new Get-WinEvent cmdlet that is part of PowerShell 2.0.
More...Remote WMI to a Workgroup Server 2008 R2
Mark Berry March 22, 2011
So you’re trying to do a simple PowerShell WMI query from a domain-joined computer to a non-domain-joined (workgroup) Server 2008 R2 computer on the same network, e.g. to check the version of the server’s operating system:
Get-WmiObject -ComputerName "WGSERVER01" -namespace "root\CIMV2" `
-Class win32_OperatingSystem -Property "Version"
But you keep getting nasty messages:
Get-WmiObject : Access denied
I feel your pain. I was beginning to wonder if getting remote WMI working had something to do with planetary alignment.
More...Using Path in Local System Context
Mark Berry March 10, 2011
I’m using GFI MAX Remote Management to deploy some PowerShell scripts to servers. The scripts need access to a new directory I set up, C:\Scripts\PowerShell, so I used a PowerShell command to add that path to the Path environment variable in the machine scope.
More...PowerShell: Remove Blank Lines from Command Output
Mark Berry March 8, 2011
For some reason, when you run some shell commands in a PowerShell script, the output has an extra blank line after each line. It doesn’t seem to affect commands run in the console, but it is evident using the command line in the PowerGUI Script Editor. Examples are ipconfig and tracert.
The thing to keep in mind is that when you run a shell command, you are actually getting back an array of objects, one item per line.
More...Deploying PowerShell Scripts to GFI MAX
Mark Berry February 25, 2011
I’ve been working on some PowerShell scripts that I want to deploy to GFI MAX Remote Management, a monitoring tool I use in the MSP side of the business. I’m still working out the kinks, but here are some tips I’ll want to remember later. Maybe they’ll help you too.
More...