Helpful PowerShell One-Liners
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
Comments
- Anonymous
January 01, 2003
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!!!