1111 . PARAMETER ignoreLinksFile
1212 Specifies the file that contains a set of links to ignore when verifying.
1313
14- . PARAMETER devOpsLogging
15- Switch that will enable devops specific logging for warnings.
16-
1714 . PARAMETER recursive
1815 Check the links recurisvely. Applies to links starting with 'baseUrl' parameter. Defaults to true.
1916
7067param (
7168 [string []] $urls ,
7269 [string ] $ignoreLinksFile = " $PSScriptRoot /ignore-links.txt" ,
73- [switch ] $devOpsLogging = $false ,
7470 [switch ] $recursive = $true ,
7571 [string ] $baseUrl = " " ,
7672 [string ] $rootUrl = " " ,
@@ -89,6 +85,8 @@ param (
8985
9086Set-StrictMode - Version 3.0
9187
88+ . " $PSScriptRoot /logging.ps1"
89+
9290$ProgressPreference = " SilentlyContinue" ; # Disable invoke-webrequest progress dialog
9391
9492function ProcessLink ([System.Uri ]$linkUri ) {
@@ -211,30 +209,6 @@ function NormalizeUrl([string]$url) {
211209 return $uri
212210}
213211
214- function LogWarning
215- {
216- if ($devOpsLogging )
217- {
218- Write-Host " ##vso[task.LogIssue type=warning;]$args "
219- }
220- else
221- {
222- Write-Warning " $args "
223- }
224- }
225-
226- function LogError
227- {
228- if ($devOpsLogging )
229- {
230- Write-Host " ##vso[task.logissue type=error]$args "
231- }
232- else
233- {
234- Write-Error " $args "
235- }
236- }
237-
238212function ResolveUri ([System.Uri ]$referralUri , [string ]$link )
239213{
240214 # If the link is mailto, skip it.
@@ -554,9 +528,8 @@ foreach ($url in $urls) {
554528 $pageUrisToCheck.Enqueue ($uri );
555529}
556530
557- if ($devOpsLogging ) {
558- Write-Host " ##[group]Link checking details"
559- }
531+ LogGroupStart " Link checking details"
532+
560533while ($pageUrisToCheck.Count -ne 0 )
561534{
562535 $pageUri = $pageUrisToCheck.Dequeue ();
@@ -592,9 +565,7 @@ while ($pageUrisToCheck.Count -ne 0)
592565}
593566
594567try {
595- if ($devOpsLogging ) {
596- Write-Host " ##[endgroup]"
597- }
568+ LogGroupEnd
598569
599570 if ($badLinks.Count -gt 0 ) {
600571 Write-Host " Summary of broken links:"
0 commit comments