Helpful PowerShell One-Liners

Published 23 March 09 10:16 PM | clinth@microsoft.com 

While doing a BizTalk Health check this week, the customer and I thought it would be cool to try to do as much as possible in an interactive PowerShell session to collect the data we needed. We created a lot of PowerShell one-liners and I thought I’d share it. These one-liners use WMI, so nearly all of them can be ran from a remote workstation, so this means that PowerShell is not needed on the remote BizTalk servers unless otherwise noted.

Be careful of word wrap in this email. All of these commands are *one-liners* – meaning they all go on one line ;-).

# List of BizTalk Servers. This is needed, so that the rest of the commands will execute on each of them per command.

$BizTalkServers = "BizTalkServer1","BizTalkServer2"

# Ping servers (latency check)

$BizTalkServers | foreach-object {"================";$_;"================";ping $_}

# Pathping (packet loss check)

$BizTalkServers | foreach-object {"================";$_;"================";pathping $_}

# Get Total Physical Memory

$BizTalkServers | ForEach-Object {"================";$_;"================";Get-wmiobject -Query "SELECT TotalPhysicalMemory FROM Win32_ComputerSystem" -ComputerName $_} | Format-List TotalPhysicalMemory

# Installed hotfixes (quick)

$BizTalkServers | ForEach-Object {"================";$_;"================";Get-wmiobject -Query "SELECT HotFixID,ServicePackInEffect FROM Win32_QuickFixEngineering" -ComputerName $_} | Format-list HotfixID, ServicePackInEffect

# NumberOfProcessors

$BizTalkServers | ForEach-Object {"================";$_;"================";Get-wmiobject -Query "SELECT NumberOfProcessors FROM Win32_ComputerSystem" -ComputerName $_} | Format-List NumberOfProcessors

# System Information

$BizTalkServers | ForEach-Object {"================";$_;"================";Get-wmiobject -Query "SELECT Caption, CSDVersion, MaxProcessMemorySize, PAEEnabled, ServicePackMajorVersion FROM Win32_OperatingSystem" -ComputerName $_} | Format-List Caption, ServicePackMajorVersion, CSDVersion, MaxProcessMemorySize, PAEEnabled

# Clock Synchronization Check

$BizTalkServers | ForEach-Object {"================";$_;"================";Get-wmiobject -Query "SELECT * FROM Win32_LocalTime" -ComputerName $_} | format-list Year, Month, Day, Hour, Minute, Second

# BizTalk Host Instance information (WMIC) (Must be ran locally) (WMIC is native to the operating system)

wmic /NAMESPACE:"\\root\MicrosoftBizTalkServer" PATH MSBTS_HostInstance GET HostName, HostType, Logon, NTGroupName, RunningServer

# BizTalk Host Instance information (PowerShell) (Must be ran locally) (PowerShell must be installed)

$BizTalkServers | ForEach-Object {"================";$_;"================";Get-wmiobject -Namespace "root\MicrosoftBizTalkServer" -Query "SELECT * FROM MSBTS_Host" -ComputerName $_} | Format-List HostName, HostType, Logon, NTGroupName, RunningServer

Filed under: , ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# dmuscett said on May 31, 2009 1:40 PM:

Hi, I am in PFE too... while I don't know anything about BizTalk, I do use powershell a lot. Actually, not sure if you knew this, but the Operations Manager 2007 Health Check tool is completely built in powershell, as I ranted about here: http://www.muscetta.com/2008/12/30/early-adoptions-health-checks-and-new-year-rants/

Oh, and I am a PAL fan, of course!!!

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

About clinth@microsoft.com

I am originally from Dayton, OH. Worked for the Air Force for 6 years. Joined Microsoft in 1999 and moved to Charlotte, NC. There I was a Support Professional and later worked as a Testing Consultant. After 6 years, my wife, daughter and I moved to Seattle, WA where I took a job as a Microsoft Premier Field Engineering (PFE) supporting BizTalk. Throughout my Microsoft career I've always been very passionate about performance analysis, so I have worked hard to make performance analysis easier for our customers. Oh, and I like PC games like Diablo 2 and Fable, cigars, and a nice Chianti.

Search

This Blog

Syndication

Page view tracker