-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-urls.ps1
29 lines (25 loc) · 1.25 KB
/
check-urls.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
param ([string] $serverUrl = $(throw 'serverUrl parameter is required'))
# try to get the registration entries xml
trap {
"Could not fetch registration data from $serverUrl"
break
} $registrationEntries = (get-tfs-registrationdata $serverUrl)
# we have the xml, parse out the URL's
$registrationUrls = $registrationEntries.GetElementsByTagName('Url') |
# only interested in the url string itself
%{ $_.'#text' } |
# filter to only full or partial URL's (no hostname/UNC)
?{ $_ -match '^http' -or $_ -match '^/' } |
# filter out the ones we know will fail if called directly (base sharepoint, 2 TFVC ones)
?{ $_ -notmatch '/sites$' -and $_ -notmatch '/item.asmx$' -and $_ -notmatch '/upload.asmx$' }
write-host ('Found {0} registered urls to check at server {1}' -f $registrationUrls.Count, $serverUrl)
write-host ''
$registrationUrls | %{
#write-host "testing $_"
$fullUrl = $_
if ($fullUrl -notmatch '^http') { $fullUrl = $serverUrl + $fullUrl }
$result = ping-url $fullUrl
$color = 'green'
if ($result -match 'Failed') { $color = 'red' }
write-host -foreground $color ('Result of pinging {0}: {1}' -f $_, $result)
}