Test-RemoteConnection.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
function Test-RemoteConnection { <# .SYNOPSIS Requests the keepalive.aspx page from the server to test connectivity. .DESCRIPTON The Test-RemoteConnection command submits a web request to the specified host to both warmup and test connectivity. .PARAMETER Timeout The time to way before aborting in seconds. .PARAMETER Quiet The command should return a true or false value indicating connectivity. .EXAMPLE The following example tests connectivity with the session host and returns a true or false value. $session = New-ScriptSession -Username admin -Password b -ConnectionUri http://remotesitecore Test-RemoteConnection -Session $session -Quiet .EXAMPLE The following example tests connectivity with the session host and returns an object with Sitecore details or $null results. $session = New-ScriptSession -Username admin -Password b -ConnectionUri http://remotesitecore Test-RemoteConnection -Session $session .LINK New-ScriptSession #> [CmdletBinding()] param( [Parameter(ParameterSetName='Session')] [ValidateNotNull()] [pscustomobject]$Session, [switch]$Quiet ) process { $result = Invoke-RemoteScript -ScriptBlock { [PSCustomObject]@{ "SPEVersion" = $PSVersionTable.SPEVersion "SitecoreVersion" = [SitecoreVersion]::Current.ToString() "CurrentTime" = [datetime]::UtcNow } } -Session $Session $isSuccess = $result -ne $null if($Quiet) { $isSuccess } else { $result } } } |