Tue. Jan 4th, 2022
Function Get-DestinationListURL([String]$Sprint, [String]$SiteTitle, [String]$SrcURL, [String]$ListURL, [String]$ListName, $MasterList, $ReportOutput, $RulesOutput,$Credentials, $SPOCredentials)
{#write-host -f Cyan Get-DestinationListURL
    $DomainArray = @()
    $DomainArray += "https://sp.demeter.zeus.gsi.gov.uk/"
    $DomainArray += "https://nesp.demeter.zeus.gsi.gov.uk/"
    Try{$i=0
        foreach ($Domain in $DomainArray)
        {
           $pos = $SrcURL.IndexOf($Domain)
            IF($pos -gt -1)
            {
                foreach ($row in $MasterList)
                {$i++
                    if ( $SrcURL[-1] -ne '/' ) {$SrcURL = $SrcURL + "/"}

                    $pos = $SrcURL.IndexOf($row.SrcURL)
                    IF($SrcURL -eq $row.SrcURL)
                    {
                    $dstURL = $row.dstURL
                    if($dstURL -ne "")
                    {
                        $pos = $ListURL.IndexOf($Domain)
                        IF($pos -gt -1)
                        {
                            $ShortListURL = $ListURL.Substring($pos + $Domain.length)
                        }
                        
                        #Rules Variables
                        $Rootfolder = "Forms/AllItems.aspx?RootFolder="
                        $WopiFrame2 = "_layouts/15/WopiFrame2.aspx"
                        $WopiFrame = "_layouts/15/WopiFrame.aspx"
                        $Forms = "Forms/AllItems.aspx"
                        $UniCode = ReplaceTextForUnicode -FilePath $ShortListURL
                        $Sourcedoc = "_layouts/15/WopiFrame.aspx?sourcedoc="
                        $PagesHome = "SitePages/Home.aspx"
                        
                        $pos = $ListName.IndexOf("-")
                        IF($pos -gt -1)
                        {
                            $ListName = $ListName -replace "-",""
                        }
                      
                        #List Rules - Each List has 5 Rules
                        $SourcedocFrom = $SrcURL + $Sourcedoc + $ShortListURL #1
                        $SourcedocTo = $dstURL + "/" + $ListName #1
                        $RootfolderFrom = $SrcURL + $Rootfolder + $UniCode #2
                        $RootfolderTo = $dstURL + "/" + $ListName #2
                        $WopiFrameFrom = $SrcURL + $WopiFrame + $ShortListURL #3
                        $WopiFrameTo = $dstURL + "/" + $ListName #3
                        $WopiFrame2From = $SrcURL + $WopiFrame2 + $ShortListURL #4
                        $WopiFrame2To = $dstURL + "/" + $ListName #4
                        $srcListURLFrom =  $Domain + $ShortListURL #5
                        $dstListURLTo =  $dstURL + "/" + $ListName #5
                        $srcRelativeListURLFrom =  "/" + $ShortListURL #6
                        $dstRelativeListURLTo =  $dstURL + "/" + $ListName # #6

                        #Site Rules - Each Site has 5 Rules
                        $SiteWopiFrameFrom = $SrcURL + $WopiFrame #1
                        $SiteWopiFrame2From = $SrcURL + $WopiFrame2 #2
                        $SiteFormsFrom = $SrcURL + $Forms #3
                        $SitePagesFrom = $SrcURL + $PagesHome #4
                        $SiteURLFrom = $SrcURL #5
                        $SiteURLTo = $dstURL + "/" #5

                        $dstListURL =  $dstURL + "/" + $ListName
                        #$LinkStatus = CheckLinkStatus -dstListURL $dstListURL
                        $output = "$($Sprint),$($SiteTitle),$($SrcURL),$ListURL,$ListName,$dstURL,$dstListURL,$SourcedocFrom,$RootfolderFrom,$WopiFrameFrom,$WopiFrame2From,$LinkStatus,List"
                        Add-Content $ReportOutput $output
                        $Ruleoutput = "`"TRUE`",`"Begins with`",`"Full filespec`",`"$($SourcedocFrom)`",`"$($SourcedocTo)`",`"FALSE`",`"FALSE`",`"0`",`"`","
                        Add-Content $RulesOutput $Ruleoutput #Rule List 1
                        $Ruleoutput = "`"TRUE`",`"Begins with`",`"Full filespec`",`"$($RootfolderFrom)`",`"$($RootfolderTo)`",`"FALSE`",`"FALSE`",`"0`","
                        Add-Content $RulesOutput $Ruleoutput #Rule List 2
                        $Ruleoutput = "`"TRUE`",`"Exact match`",`"Full filespec`",`"$($WopiFrameFrom)`",`"$($WopiFrameTo)`",`"FALSE`",`"FALSE`",`"0`","
                        Add-Content $RulesOutput $Ruleoutput #Rule List 3
                        $Ruleoutput = "`"TRUE`",`"Exact match`",`"Full filespec`",`"$($WopiFrame2From)`",`"$($WopiFrame2To)`",`"FALSE`",`"FALSE`",`"0`","
                        Add-Content $RulesOutput $Ruleoutput #Rule List 4
                        $Ruleoutput = "`"TRUE`",`"Begins with`",`"Full filespec`",`"$($srcListURLFrom)`",`"$($dstListURLTo)`",`"FALSE`",`"FALSE`",`"0`","
                        Add-Content $RulesOutput $Ruleoutput #Rule List 5
                        $Ruleoutput = "`"TRUE`",`"Begins with`",`"Full filespec`",`"$($srcRelativeListURLFrom)`",`"$($dstRelativeListURLTo)`",`"FALSE`",`"FALSE`",`"0`","
                        Add-Content $RulesOutput $Ruleoutput #Rule List 6

                        $Ruleoutput = "`"TRUE`",`"Exact match`",`"Full filespec`",`"$($SiteWopiFrameFrom)`",`"$($dstURL)`",`"FALSE`",`"FALSE`",`"0`","
                        Add-Content $RulesOutput $Ruleoutput #Rule Site #1
                        $Ruleoutput = "`"TRUE`",`"Exact match`",`"Full filespec`",`"$($SiteWopiFrame2From)`",`"$($dstURL)`",`"FALSE`",`"FALSE`",`"0`","
                        Add-Content $RulesOutput $Ruleoutput #Rule Site #2
                        $Ruleoutput = "`"TRUE`",`"Exact match`",`"Full filespec`",`"$($SiteFormsFrom)`",`"$($dstURL)`",`"FALSE`",`"FALSE`",`"0`","
                        Add-Content $RulesOutput $Ruleoutput #Rule Site 3
                        $Ruleoutput = "`"TRUE`",`"Exact match`",`"Full filespec`",`"$($SitePagesFrom)`",`"$($dstURL)`",`"FALSE`",`"FALSE`",`"0`","
                        Add-Content $RulesOutput $Ruleoutput #Rule Site 4
                        $Ruleoutput = "`"TRUE`",`"Exact match`",`"Full filespec`",`"$($SiteURLFrom)`",`"$($SiteURLTo)`",`"FALSE`",`"FALSE`",`"0`","
                        Add-Content $RulesOutput $Ruleoutput #Rule Site 5                    } 
                    break
                }
            }
            }
            }
        }
    }Catch
    {
            write-host Could not find link $($LinkBefore) - $_.Exception.Message -ForegroundColor Red
            $e = $_.Exception
            $line = $_.InvocationInfo.ScriptLineNumber
            $msg = $e.Message
    }
}

This website uses cookies. By continuing to use this site, you accept our use of cookies.