This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Active Roles 7 Web site status with PowerShell.

I have been looking for a way to monitor the Active Roles website with PowerShell. I have been stuck when pulling in a page request via Invoke-WebRequest and System.Net.WebClient.

Example 1:
$ARSURL= "https://ars.org"
$Creds = Get-Credential
Invoke-WebRequest -Uri $URL -Credential $Creds
And I get the following error: "Invoke-WebRequest : Server Error
401 - Unauthorized: Access is denied due to invalid credentials."

Example 2:
$webclient = new-object System.Net.WebClient
$webclient.Credentials = new-object System.Net.NetworkCredential($username, $password, $domain)
$webpage = $webclient.DownloadString($url)
And I get the following error: Exception calling "DownloadString" with "1" argument(s):
"The remote server returned an error: (401) Unauthorized."

Any idea on how I can connect to the ARS website via PowerShell?

  • Well - I responded to a question about ARS 7 without thinking - I'm not there yet.  This answer applies to ARS 6.9 ... May also apply to Version 7 - if the about page can be called directly.  Otherwise, your mileage will vary.

    If you're still with me ... I've played around with this a bit too  There is more to explore ... but here is one style of accomplishing the task.

    For me - A quick way to check the basic availability of an ARS web site, would be to pull the about page and display the logged on user ID, ARS service and web version + the page status.

    We maintain 4 separate ARS groups of servers, and I cycle the $ARSURL below between the three ARS web servers to check that the site is up, and that it is currently pointed to the proper ARS service host partner.

    $ARSURL= "myhost.myplace.com/.../About.ASPX

    $page = Invoke-WebRequest -Uri $ARSURL -UseDefaultCredentials

    ($page.allelements | where {$_.tagname -eq "TBODY"}).innertext

    Returns:

    Current user: DOMAIN\USERID

    Role: ActiveRoles Administrator

    Web Interface version: 6.9.0.5483

    Administration Service: myhostinGA.myplace.com

    Administration Service version: 6.9.0.5483

    OK

    OK

    Alternatively - if you're looking at something to script for automating in a status report -  I'd go with the simple $page.StatusCode  - or $page.StatusDescription

    the HTHML code for a good result is 200 ... I've only seen two codes- it's available or it's not.  If it's not the 'code' returned is 500.  If the page is building/busy - you'll get a long wait and a 'timeout'

    $ARSURL= "myhost.myplace.com/.../About.ASPX

    $page = Invoke-WebRequest -Uri $ARSURL -UseDefaultCredentials

    $page.StatusDescription

    Returns 

    OK

  • Thank you. Great examples etc.

  • The only caveat I would offer is if you are load balancing your ARS web UIs using a VIP of some sort, make sure you hit the actual host URL and not the VIP'd one that you publish to your user's.

  • Indeed. Ill post the script once I'm done.