none
Exchange 2013 current connections formattng issue RRS feed

  • Question

  • 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


    Wednesday, January 22, 2014 7:25 PM

Answers

  • 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 


    ¯\_(ツ)_/¯


    • Edited by jrv Wednesday, January 22, 2014 7:54 PM
    • Marked as answer by Peachland-tech Wednesday, January 22, 2014 10:03 PM
    Wednesday, January 22, 2014 7:54 PM
  • 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

    Monday, January 27, 2014 7:40 PM

All replies

  • 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 


    ¯\_(ツ)_/¯

    Wednesday, January 22, 2014 7:46 PM
  • 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.

    ¯\_(ツ)_/¯

    Wednesday, January 22, 2014 7:50 PM
  • 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 


    ¯\_(ツ)_/¯


    • Edited by jrv Wednesday, January 22, 2014 7:54 PM
    • Marked as answer by Peachland-tech Wednesday, January 22, 2014 10:03 PM
    Wednesday, January 22, 2014 7:54 PM
  • Thanks
    Wednesday, January 22, 2014 10:04 PM
  • $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
    Wednesday, January 22, 2014 11:16 PM
  • Wednesday, January 22, 2014 11:26 PM
  • 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

    Monday, January 27, 2014 7:40 PM
  • Don't really know why this is marked as an answer for 2013 because it is written for 2010...
    Monday, March 9, 2015 12:07 PM
  • 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.


    ¯\_(ツ)_/¯

    Monday, March 9, 2015 12:09 PM