Hello,
I recently added a link to the quick launch menu on some of my sites. The Quick Launch is structured with the same headings and links on each site. The new link is in the wrong place. I need to move the link up a few rows to maintain alphabetical order. On the following script, I am getting You cannot call a method on a null-valued expression." What am I doing wrong? Or, how can I move my recently added link to a new location within the same heading?
$data = Import-Csv "C:\Scripts\Test\Test Sites.csv" foreach ($d in $data) { $web = Get-SPWeb $d.SiteUrl $qlNav = $web.Navigation.QuickLaunch $qlHeading = $d.Header $LinkHeader = $d.Header foreach ($header in $web.Navigation.QuickLaunch) { if ($header.Title -eq $LinkHeader) { $qlNewPreviousSibling = $qlHeading.Children | where { $_.Title -eq "Agreements" } $qlLink = $qlHeading.Children | where { $_.Title -eq "Property Contacts" } $qlLink.Move($qlHeading.Children, $qlNewPreviousSibling) } } }
I would also be open to setting up the link's order when I add it in the first place.