Tag Archives: Hounddog

Powershell Script to Determine Active User Count for Microsoft Exchange 2010 and Exchange 2007

A script that I came up with to determine the user load that is being placed on a particular Exchange server so that you can plot the days of the week and times of the day that are busiest. This Powershell Script can be used with GFI Max Remote Management or SpiceWorks to easily identify busy Exchange servers.

$GETMSEXCHISAUC = Get-Counter ‘\MSExchangeIS\Active User Count’
$MSEXCHISAUC = $GETMSEXCHISAUC.CounterSamples |Select-Object CookedValue
Write-Host You have $MSEXCHISAUC.CookedValue Active Exchange User Connection\s to the Exchange Server

Feel free to edit the text part of the output (Last line), this could be simplified if required.

Powershell Script to Determine Number of Connections to your Microsoft Terminal Services Gateway

I’ve put together another script that might be useful for monitoring how busy your Terminal Services Gateway is at various times of the day.  This Powershell Script can be used with GFI Max Remote Management or SpiceWorks to easily identify busy servers.

$GETTSGWCC = Get-Counter ‘\Terminal Service Gateway\Current connections’
$TSGWCC = $GETTSGWCC.CounterSamples |Select-Object CookedValue
Write-Host You have $TSGWCC.CookedValue Current Connection\s to the Terminal Services Gateway

Feel free to edit the text part of the output (Last line), this could be reduced/simplified if required.

Microsoft SharePoint 2010 and Microsoft SharePoint Foundation 2010 – Running PSConfig to Update SharePoint Database after installing Service Packs and Hotfixes

If you read my last post you will already know how to check if Microsoft SharePoint 2010 and Microsoft SharePoint Foundation 2010 needs to have PSConfig run to complete the last step of patching SharePoint 2010.

You will need to open an elevated “Command Prompt”, this can be done by “right clicking” on the “Command Prompt” shortcut (Start Menu, Accessories) and then selecting “Run as administrator”.

Once in the command prompt you need to change to the directory containing PSCONFIG, you can do this by copying and pasting the line below in to the command prompt and then pressing “Enter”

cd C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN

You should now find yourself in the correct directory and can copy and paste in the PSCONFIG command below into the “Command Prompt” window and hit “Enter”.

PSConfig.exe -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures

This command will require around 5-10 minutes to complete, be patient and do not try to quit the command whilst it is running even if the percentage counter does not appear to be going up for a while.  Once it’s complete I would suggest rebooting the server to ensure the changes take effect.

Please note that this command will stop the SharePoint Site from working whilst the upgrade is running and is also likely to temporarily stop Terminal Services Gateway and some other IIS sites from being served up to users.

I would strongly suggest performing this task out of business hours or scheduling in a 60 minute slot during the day where users can logout of any server based applications, web sites or services.  I’d also not recommend trying to initialise the command whilst connected to the server using Remote Web Access/Workplace, this is only really applicable for SBS 2011 users.  Best to be physically infront of the server, use an IP KVM or establish a VPN connection and then RDP to the servers internal address or hostname using the “Microsoft Remote Desktop Client”.

Microsoft SharePoint 2010 and Microsoft SharePoint Foundation 2010 – Powershell Script to identify if PSConfig Update is Required after installing Service Packs and Hotfixes

Installing Hotfixes/Service Packs for Microsoft SharePoint 2010 and Microsoft SharePoint Foundation 2010 is a two step process now.  First you should install the service pack or hotfix and then you need to verify if PSConfig needs to be run. PSConfig normally always needs to be run as this updates the actual SharePoint databases.

Not completing the PSConfig command where required can cause SharePoint search failures and Sharepoint backups may stop working correctly on the server.

To simplify the process of identifying which SharePoint servers require the PSConfig update I have put together a Powershell script that will return a simple answer to the question of do I need to run PSConfig or not.  The example below also includes “Exit 0” and “Exit 1” in the script, this is only really required for GFI Max Remote Management users.  The Exit codes tell the GFI max Remote Management software to either pass or fail the script check so that a red cross appears on the server monitoring dashboard to alert administrators that action is required on that server.

If you do not use GFI Max Remote Management or you only want the script to report the need for a PSConfig upgrade then simply remove the lines with “Exit 0” and “Exit 1” on and then you can just save this is a Powershell script on your server desktop and run it manually.


Add-PSSnapin Microsoft.SharePoint.PowerShell

$NEEDSUPGRADE = (get-spserver $env:computername).NeedsUpgrade

If ($NEEDSUPGRADE | Where {$_ -eq “True”})


Write-Host “SharePoint Upgrade Required”

Exit 1




Write-Host “No Upgrade Required”

Exit 0



My next post will tell you how to run the PSConfig command to update your SharePoint 2010 database if required.