SharePoint Online: PowerShell'i kullanarak Hızlı Başlatma Bağlantılarını Güncelleyin


Gereksinim: PowerShell'i kullanarak SharePoint Online'da Hızlı Başlatmayı güncelleyin.

SharePoint Online'da Hızlı Başlatma Bağlantıları Nasıl Güncellenir?

Hızlı Başlatma, SharePoint'in tüm sürümlerinde site içeriğini düzenlemenin ve hızla erişmenin popüler bir yolu olmuştur. Peki ya sitenizdeki belirli bir sayfaya veya dosyaya giden bağlantıyı yenisiyle güncellemek isterseniz? Bu, PowerShell kullanılarak gerçekleştirilebilir ve yapılması nispeten kolaydır. Bu blog yazısı, PowerShell'i kullanarak Hızlı Başlatma araç çubuğundaki bağlantıların nasıl güncelleneceğini gösterecektir.

Hızlı başlatmada bağlantıları güncellemek için şu adımları izleyin:

  1. Site Ayarlarına gidin >> Bak ve hisset bölümünden "Hızlı başlatma"ya tıklayın.
  2. Hızlı başlatma bağlantısını düzenlemek ve güncellemek için “Düzenle” simgesine tıklayın.

Yayınlama özelliği etkinse, site ayarlarında "Görünüm ve Hisset" altında "Gezinme" bağlantısını göreceksiniz.

Hızlı Başlatmayı Güncellemek için SharePoint Çevrimiçi PowerShell:

Birden fazla SharePoint Online sitesi için Hızlı Başlat'taki bağlantıları güncellemeniz gerekiyorsa, bunu manuel olarak yapmak zaman alıcı ve sıkıcı bir iş olabilir. Neyse ki bu süreci otomatikleştirmek ve zamandan tasarruf etmek için PowerShell kullanılabilir. PowerShell kullanarak SharePoint Online'daki Hızlı Başlatma bağlantılarını güncellemeyi tartışalım.

Sol gezinme bölmesindeki eski bağlantıyı yeni bir bağlantıyla değiştirelim:


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
   
#Config Parameters
$SiteURL="https://Crescent.sharepoint.com/sites/marketing"
$OldURL = "https://support.crescent.com/app"
$NewURL = "https://support.crescent.com/applications"

#Setup Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials

#Get the Quick launch Navigation of the web 
$QuickLaunch = $Ctx.Web.Navigation.QuickLaunch
$Ctx.load($QuickLaunch)
$Ctx.ExecuteQuery()

#Loop through Each link in Quick Launch Navigation
ForEach($QuickLaunchLink in $QuickLaunch)
{
    $Ctx.Load($QuickLaunchLink)
    $Ctx.Load($QuickLaunchLink.Children)
    $Ctx.ExecuteQuery()

    If($QuickLaunchLink.Url -eq $OldURL)
    {
        $QuickLaunchLink.Url = $QuickLaunchLink.Url.Replace($OldURL,$NewURL)
        $QuickLaunchLink.Update()
        $Ctx.ExecuteQuery()
        Write-Host -f Green "Quick Launch Link: '$($QuickLaunchLink.Title)' Updated!"
    }

    #Get Second level Links
    Foreach($Link in $QuickLaunchLink.Children)
    {
        $Ctx.Load($Link)
        $Ctx.ExecuteQuery()
          
        If($Link.Url -eq $OldURL)
        {
            $Link.Url = $Link.Url.Replace($OldURL,$NewURL)
            $Link.Update()
            $Ctx.ExecuteQuery()
            Write-Host  -f Green "Quick Launch Link '$($Link.Title)' Updated!"
        }
    }
} 

Tüm Site Koleksiyonları için Hızlı Başlatma Bağlantısını Güncelleyin

Komut dosyasını bir işleve saralım ve SharePoint Online kiracısındaki tüm site koleksiyonları için hızlı başlatma bağlantılarını arayıp değiştirelim.


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

Function Update-SPOQuickLaunchLinks([Microsoft.SharePoint.Client.Web]$Web, $OldURL, $NewURL)
{   
    Try {
        Write-host -f Yellow "Searching Quick Launch Links in:" $($Web.url)
        $Ctx = $Web.Context
        #Get the Quick launch Navigation of the web 
        $QuickLaunch = $Web.Navigation.QuickLaunch
        $Ctx.load($QuickLaunch)
        $Ctx.ExecuteQuery()

        #Loop through Each link in Quick Launch Navigation
        ForEach($QuickLaunchLink in $QuickLaunch)
        {
            $Ctx.Load($QuickLaunchLink)
            $Ctx.Load($QuickLaunchLink.Children)
            $Ctx.ExecuteQuery()

            If($QuickLaunchLink.Url -eq $OldURL)
            {
                $QuickLaunchLink.Url = $QuickLaunchLink.Url.Replace($OldURL,$NewURL)
                $QuickLaunchLink.Update()
                $Ctx.ExecuteQuery()
                Write-Host -f Green "`tQuick Launch Link: '$($QuickLaunchLink.Title)' Updated!"
            }

            #Get Second level Links
            Foreach($Link in $QuickLaunchLink.Children)
            {
                $Ctx.Load($Link)
                $Ctx.ExecuteQuery()
          
                If($Link.Url -eq $OldURL)
                {
                    $Link.Url = $Link.Url.Replace($OldURL,$NewURL)
                    $Link.Update()
                    $Ctx.ExecuteQuery()
                    Write-Host  -f Green "`tQuick Launch Link '$($Link.Title)' Updated!"
                }
            }
        }
    }
    Catch {
        write-host -f Red "Error Updating Quick Launch Links!" $_.Exception.Message
    }
}

#Function to get each subsite in site collection
Function Get-SPOWebs($SiteURL)
{
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Credentials

    #Get the web
    $Web = $Ctx.Web
    $Ctx.Load($Web)
    $Ctx.Load($Web.Webs)
    $Ctx.ExecuteQuery()

    #Call the function to Search & Replace Quick launch links
    Update-SPOQuickLaunchLinks -Web $web -OldURL $OldURL -NewURL $NewURL

    #Loop through each each subsite in site
    Foreach($Web in $web.Webs)
    {
        Get-SPOWebs $Web.Url
    }
}

#Variables
$AdminCenterURL = "https://Crescent-admin.sharepoint.com"
$OldURL = "https://support.crescent.com/app"
$NewURL = "https://support.crescent.com/applications"

#Setup Credentials to connect
$Cred= Get-Credential
 
#Connect to SharePoint Online
Connect-SPOService -url $AdminCenterURL -Credential ($Cred)

#Get all Site collections
$Sites = Get-SPOSite -Limit All

#Loop through site collections
ForEach($Site in $Sites)
{
    #Call the function to get all sites in the site collection
    Get-SPOWebs($Site.URL)
}

Aynı komut dosyası, Üst gezinme bağlantılarını güncellemek için de kullanılabilir. $Web.Navigation.QuickLaunch'ı “$Web.Navigation.TopNavigationBar” ile değiştirmeniz yeterlidir.

Hızlı Başlatma Bağlantılarını Güncellemek için PnP PowerShell

Benzer şekilde, PnP PowerShell'i kullanarak SharePoint Online'daki hızlı başlatma bağlantısını da güncelleyebiliriz.


#Config Variables
$SiteURL = "https://crescent.sharepoint.com"
$LinkTitle = "Support Center"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Get the Context
$Context =  Get-PnPContext

#Get the Quick Launch Navigation
$NavigationNodeCollection = Get-PnPNavigationNode -Location QuickLaunch

#Get the Link to Update
$NavigationNode = $NavigationNodeCollection | Where-Object { $_.Title -eq  $LinkTitle}
If($NavigationNode)
{
    #Update the Link URL
    $NavigationNode.Url = "https://support.crescent.com"
    $navigationNode.Update() 
    $Context.ExecuteQuery()
    Write-host "Navigation Link has been updated!"
}

Bu makalede verilen komut dosyasını kullanarak SharePoint Online sitelerinizdeki Hızlı Başlatma bağlantılarını hızlı ve verimli bir şekilde güncelleyebilirsiniz!

İlgili makaleler