Home Analyst Portal

powershell to check availability of portal

Mike_StormsMike_Storms Customer Adept IT Monkey ✭✭

Hi,

Has anyone written a powershell to check the availability of the portal and report if it up/down and responding?

Comments

  • [Deleted User][Deleted User] Ninja IT Monkey ✭✭✭✭
    [Foreshadowing] We *might* just have something up our sleeves we haven't talked about yet being released really soon. Stay tuned for that. In the meantime, I'll dig some PoSh up for you!
  • [Deleted User][Deleted User] IT Monkey ✭
    Hi Mike,

    If you just want to see if the website is running in IIS or not then that is easy:

    Get-WebsiteState -Name "CiresonPortal"

    If you wanted to a more thorough test from a host then you would need to load the website page from a host machine and examine the content of the object to make sure that it is the website you are expecting and not something like an error page.

    Source (but they use WMI which is unnecessary complexity): https://briangordon.wordpress.com/2010/10/27/powershell-check-if-iis-is-running-on-a-remote-server/

    PowerShell <3
  • Mike_StormsMike_Storms Customer Adept IT Monkey ✭✭
    [Foreshadowing] We *might* just have something up our sleeves we haven't talked about yet being released really soon. Stay tuned for that. In the meantime, I'll dig some PoSh up for you!
    Hi Chris... any status on powershell for checking availability of portal
  • Jonathan_BolesJonathan_Boles Customer Ninja IT Monkey ✭✭✭✭
    Hey @Mike_Storms, I too am interested to see what @Chris_Ross has for PoSh and even more for the "forshadowed" tool/functionality :) - In the meantime, if your organization utilizes SCOM, might want to check out the Cireson Service Manager Portal Management Pack for SCOM provided by Raf Delgado. It can be found on TechNet at the following link: https://gallery.technet.microsoft.com/Cireson-Service-Manager-9cf3ddbc
  • Fredrik_BorchseniusFredrik_Borchsenius Customer IT Monkey ✭
    Something very simple,but until Chris can get something more thorough:

    if (Get-Website CiresonPortal | ?{$_.State -eq "Stopped"} | out-null){
      write-host "Portal is stopped. Starting portal" 
      Start-Website CiresonPortal
    } 
    else{
      write-host "Portal is running"
    }
    
    if (get-service Cachebuilder | ?{$_.Status -eq "Stopped"}){
     write-host "Cachebuilder is stopped. Starting service"
     Start-Service Cachebuilder 
    }
    else{
      write-host "Cachebuilder is running"
    }
    
  • Jerry_VeldhuisJerry_Veldhuis Customer Advanced IT Monkey ✭✭✭

    Here is some re-usable code that works remotely. It does requrire the IIS 6 WMI Compatibility role to be enabled on the Cireson portals. Handy if you have an environment with 20 portals to monitor :)

    Function GetWebSiteByName
    {
        param([Parameter(Mandatory=$True,Position=1)]$Computer,
              [Parameter(Mandatory=$True,Position=1)]$SiteName)
       
        $settings=Get-WmiObject IISWebServerSetting -Computername $Computer -Namespace root\MicrosoftIISv2  -Authentication PacketPrivacy -ErrorAction Ignore
        if ( $settings -eq $null ) {
            throw "Unable to retrieve status of IIS Sites on $Computer"
        }
        $setting=($settings | ?{$_.ServerComment -eq $SiteName})
        if ( $setting -eq $null ) {
            throw "Unable to locate Web Site $SiteName on $Computer"
        }
       
        $site=get-wmiobject -namespace "root\MicrosoftIISv2" -class "IIsWebServer" -ComputerName $Computer -Filter "Name='$($setting.Name)'"
        if ( $site -eq $null ) {
            throw "Unable to locate Site $($setting.Name) on $Computer"
        }
       
        $state=$site.serverstate;
        if ( $state -eq '1' )     {$WebSiteStatus='Starting'}
        elseif ( $state -eq '2' ) {$WebSiteStatus='Started'}
        elseif ( $state -eq '3' ) {$WebSiteStatus='Stopping'}
        elseif ( $state -eq '4' ) {$WebSiteStatus='Stopped'}
        elseif ( $state -eq '5' ) {$WebSiteStatus='Pausing'}
        elseif ( $state -eq '6' ) {$WebSiteStatus='Paused'}
        elseif ( $state -eq '7' ) {$WebSiteStatus='Continuing'}
        else {$WebSiteStatus='Unknown'}
       
        Add-Member -InputObject $site -MemberType NoteProperty -Name SiteName -Value $SiteName
        Add-Member -InputObject $site -MemberType NoteProperty -Name SiteStatus -Value $WebSiteStatus
        Add-Member -InputObject $site -MemberType NoteProperty -Name WMISiteName -Value $setting.Name
        return $site
    }


  • Mike_StormsMike_Storms Customer Adept IT Monkey ✭✭

    [Foreshadowing] We *might* just have something up our sleeves we haven't talked about yet being released really soon. Stay tuned for that. In the meantime, I'll dig some PoSh up for you!

    Any update on this chris_ross? Thanks!
Sign In or Register to comment.