Listen:
In This Episode
Tonight on the PowerScripting Podcast, we talk to Chris Harris from Microsoft about System Center Operations Manager 2012!
News
At Quest we are passionate about Windows PowerShell. PowerGUI Pro enables organizations to harness the power of PowerShell without the expense of training and custom scripts and applications. PowerGUI Pro solves issues regardless of the time and place by using MobileShell to remotely manage your infrastructure. Ensure scripting best practices by leveraging integration with popular Version Control systems. Automate against thousands of computers using Easy Remote Script Execution. Get PowerGUI Pro at quest.com/powerguipro
- James Brundage is blogging over at http://blog.start-automating.com/
- Hal’s new PowerCLI TrainSignal course is out!
- User group news:
- Dmitry did an interview with Sean Kearney about PowerShell at the MVP Summit
- The Scripting Games 2011 are here!
- Episode 22 of the Get-Scripting Podcast has Travis Jones on talking about the PowerShell Deep Dive
- Jonathan Medd is giving away a copy of the new PowerCLI book
- Take the PowerShell Quiz!
Interview
Â
Â
Â
Chatroom Buzz:
21:47 <Start-Automating> ## are you deprecating or removing your old commands?
Â
- Tobias posted a one-hour Getting Started with PowerShell video
- Marco Shaw blogged about the VMM changes from 2008 R2 to 2012 Beta 1
- Tome’s presentation to the UK PSUG was recorded and is now available online
- Making the most of the 2011 Scripting Games
- Ravi posted a very cool PowerShell ISE Addon: Get-History GUI
Â
This segment brought to you by ServerFault.com
Feedback
This one is from Aaron Nelson aka SQLVariant:
I have a PowerShell question for you gurus. I know precisely how to do this in SQL, but I’m only kinda-sure how to do this in PowerShell.
My question is how do you contain an OR to only a certain portion of a Where-Object? In SQL all you have to do is put parens around the clauses and that will make their results act as one ‘where’ clause. In PowerShell all I could think to do is to break it up into multiple Where-Object statements. There has to be a better way to do this right?
SQL Example:
WHEREÂ (NAMEÂ LIKEÂ ‘%SQL%’
       OR NAME LIKE ‘Reporting%’)
   AND StartMode = ‘Auto’
   AND Started != ‘True’
PowerShell Example (that doesn’t work)
Get-WmiObject win32_service -ComputerName AARON |
Where {$_.name -match “^*SQL*” -or $_.name -match “Report”} |
Where {$_.StartMode -eq “Auto” -and $_.Started -ne “True”} |
Select SystemName, Name, StartName, Started, StartMode | Ft -a
Review the Operator Precedence help page, you’ll see that -and -or are near the bottom, so you need parentheses to make this work. For example:
get-stuff | ? { ($_ -gt $x) -and ($_ -ne $y) }