Exchange 2013 current connections formattng issue

Firstly sorry I'm new at Powerscript

I need a few reports that shows the current connections

Get-Counter\MSExchange RpcClientAccess\User Count,\MSExchange OWA\Current Unique Users,\RPC/HTTP Proxy\Current Number of Unique Users"-ComputerNameblabla|ft

this works fine but I have been trying to format it in HTML and remove default heading and change it to something better

when is use | ConvertTo-HTML |out-file c:\xyx..htm the format is unreadable

thanks


January 22nd, 2014 7:25pm

Remove FT and try again.

$counters='\MSExchange RpcClientAccess\User Count','\MSExchange OWA\Current Unique Users','\RPC/HTTP Proxy\Current Number of Unique Users'
Get-Counter $counters -ComputerName labla | 
     ConvertTo-Html |
     out-file c:\xyx.htm 

Free Windows Admin Tool Kit Click here and download it now
January 22nd, 2014 7:46pm

Of course the HTML will not be able to format the counters.  You will have to do this manually into some kind of flat object.
January 22nd, 2014 7:50pm

This is a little more useful but still needs help:

$counters='\MSExchange RpcClientAccess\User Count','\MSExchange OWA\Current Unique Users','\RPC/HTTP Proxy\Current Number of Unique Users'
Get-Counter $counters | 
     select -expand CounterSamples |
     Select Path, CookedValue |
     ConvertTo-Html |
     out-file c:\scripts\xyx.htm 
Free Windows Admin Tool Kit Click here and download it now
January 22nd, 2014 7:54pm

Thanks
January 22nd, 2014 10:04pm

$CASServers = Get-ClientAccessServer | select name

Foreach ($srv in $CASServers){
 $RPC = Get-Counter "\MSExchange RpcClientAccess\User Count" -ComputerName $srv.name
 $OWA = Get-Counter "\MSExchange OWA\Current Unique Users" -ComputerName $srv.name
 $http = Get-Counter "\RPC/HTTP Proxy\Current Number of Unique Users" -ComputerName $srv.name
 New-Object PSObject -Property @{
 Server = $srv.name 
 "Client Access" = $RPC.CounterSamples[0].CookedValue
 "OWA" = $OWA.CounterSamples[0].CookedValue
 "Mobile" = $OWA.CounterSamples[0].CookedValue
 }
} 
I'm stuck trying to get my output from the screen to html
Free Windows Admin Tool Kit Click here and download it now
January 22nd, 2014 11:16pm

Start  here: http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

January 22nd, 2014 11:26pm

Well it worked out ok ..here is what I came up with.. it not perfect but it works

$ExchangeHost = "your-server"
$ExchangeServer = Get-ExchangeServer -Identity $ExchangeHost
 
# Get Connections
if ($ExchangeServer.IsClientAccessServer -eq $True)
{
	# OWA Connections
	$HostOWAConnections = (Get-Counter "\MSExchange OWA\Current Unique Users"  -ComputerName $ExchangeHost).CounterSamples[0].CookedValue
 
	# RPC Connections
	$HostRPCConnections = (Get-Counter "\MSExchange RpcClientAccess\User Count"  -ComputerName $ExchangeHost).CounterSamples[0].CookedValue
 
	# POP3 Connections
	#$HostPOP3Connections = (Get-Counter "\MSExchangePop3(1)\Connections Current"  -ComputerName $ExchangeHost).CounterSamples[0].CookedValue
 
	# IMAP Connections
	#$HostIMAPConnections = (Get-Counter "\MSExchangeImap4(1)\Current Connections"  -ComputerName $ExchangeHost).CounterSamples[0].CookedValue
    
    # http
    $Mobile = (Get-Counter "\RPC/HTTP Proxy\Current Number of Unique Users" -ComputerName $ExchangeHost).CounterSamples[0].CookedValue


	# Exchange Connections
	# [int]$ExchangeActiveConnections = [int]$HostOWAConnections + [int]$HostRPCConnections + [int]$HostPOP3Connections + [int]$HostIMAPConnections + [int] $http |Out-File c:\temp\brian.txt
   $obj = New-Object PSObject
    $obj | Add-Member Server $ExchangeServer
    $obj | Add-Member OWA $HostOWAConnections
    $obj | Add-Member Outlook $HostRPCConnections
    $obj | Add-Member Mobile $Mobile
   Write-output $obj |ConvertTo-HTML -AS list | Out-file C:\temp\brian.htm
  }
 function sendmail($body)
    {
    $SmtpClient = new-object system.net.mail.smtpClient
    $MailMessage = New-Object system.net.mail.mailmessage
    $SmtpClient.Host = "xxx.xxx.xxx.xxx"
    $mailmessage.from = "Exchange_2010_NoReply@YOURDOMAIN.COM"
    $mailmessage.To.add("you@domain.com")
    # $mailmessage.CC.add("CC_RECIPIENT@YOURDOMAIN.COM")
    $mailmessage.Subject = Exchange Current Connects Report $Datum
    $MailMessage.IsBodyHtml = $false
    $mailmessage.Body = $body

    $smtpclient.Send($mailmessage)
    }



    sendmail $obj
I write to a file and send it out via email... uncomment imap and pop if you need it

Free Windows Admin Tool Kit Click here and download it now
January 27th, 2014 7:40pm

Well it worked out ok ..here is what I came up with.. it not perfect but it works

$ExchangeHost = "your-server"
$ExchangeServer = Get-ExchangeServer -Identity $ExchangeHost
 
# Get Connections
if ($ExchangeServer.IsClientAccessServer -eq $True)
{
	# OWA Connections
	$HostOWAConnections = (Get-Counter "\MSExchange OWA\Current Unique Users"  -ComputerName $ExchangeHost).CounterSamples[0].CookedValue
 
	# RPC Connections
	$HostRPCConnections = (Get-Counter "\MSExchange RpcClientAccess\User Count"  -ComputerName $ExchangeHost).CounterSamples[0].CookedValue
 
	# POP3 Connections
	#$HostPOP3Connections = (Get-Counter "\MSExchangePop3(1)\Connections Current"  -ComputerName $ExchangeHost).CounterSamples[0].CookedValue
 
	# IMAP Connections
	#$HostIMAPConnections = (Get-Counter "\MSExchangeImap4(1)\Current Connections"  -ComputerName $ExchangeHost).CounterSamples[0].CookedValue
    
    # http
    $Mobile = (Get-Counter "\RPC/HTTP Proxy\Current Number of Unique Users" -ComputerName $ExchangeHost).CounterSamples[0].CookedValue


	# Exchange Connections
	# [int]$ExchangeActiveConnections = [int]$HostOWAConnections + [int]$HostRPCConnections + [int]$HostPOP3Connections + [int]$HostIMAPConnections + [int] $http |Out-File c:\temp\brian.txt
   $obj = New-Object PSObject
    $obj | Add-Member Server $ExchangeServer
    $obj | Add-Member OWA $HostOWAConnections
    $obj | Add-Member Outlook $HostRPCConnections
    $obj | Add-Member Mobile $Mobile
   Write-output $obj |ConvertTo-HTML -AS list | Out-file C:\temp\brian.htm
  }
 function sendmail($body)
    {
    $SmtpClient = new-object system.net.mail.smtpClient
    $MailMessage = New-Object system.net.mail.mailmessage
    $SmtpClient.Host = "xxx.xxx.xxx.xxx"
    $mailmessage.from = "Exchange_2010_NoReply@YOURDOMAIN.COM"
    $mailmessage.To.add("you@domain.com")
    # $mailmessage.CC.add("CC_RECIPIENT@YOURDOMAIN.COM")
    $mailmessage.Subject = Exchange Current Connects Report $Datum
    $MailMessage.IsBodyHtml = $false
    $mailmessage.Body = $body

    $smtpclient.Send($mailmessage)
    }



    sendmail $obj
I write to a file and send it out via email... uncomment imap and pop if you need it

January 27th, 2014 7:40pm

Don't really know why this is marked as an answer for 2013 because it is written for 2010...
Free Windows Admin Tool Kit Click here and download it now
March 9th, 2015 8:10am

Don't really know why this is marked as an answer for 2013 because it is written for 2010...

Just add 3 and you are set.

The code works on all from 2007 on.

March 9th, 2015 8:13am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics