fix: Improve site search in Get-FolderBrowser with better URL handling
This commit is contained in:
parent
aaabb11624
commit
3d170f3652
@ -112,12 +112,24 @@ function Get-FolderBrowser {
|
||||
try {
|
||||
# Get site ID first
|
||||
$siteUrl = $script:txtSiteUrl.Text.TrimEnd('/')
|
||||
$site = Get-MgSite -Search $siteUrl | Where-Object { $_.WebUrl -eq $siteUrl }
|
||||
# Extract site path from URL
|
||||
$sitePathMatch = $siteUrl -match "sharepoint\.com(.*)"
|
||||
if (-not $sitePathMatch) {
|
||||
throw "Invalid SharePoint URL format"
|
||||
}
|
||||
$sitePath = $matches[1]
|
||||
|
||||
# Get site directly using path
|
||||
$site = Get-MgSite -SiteId "root" -Property "siteCollection,webUrl,id" -ErrorAction Stop
|
||||
$site = Get-MgSite -SiteId $site.Id -Property "siteCollection,webUrl,id" -ErrorAction Stop `
|
||||
-Filter "startswith(webUrl, '$siteUrl')"
|
||||
|
||||
if (-not $site) {
|
||||
throw "Site not found"
|
||||
throw "Site not found at $siteUrl"
|
||||
}
|
||||
|
||||
$script:txtStatus.Text += "Found site: $($site.WebUrl)`n"
|
||||
|
||||
# Get drive (document library)
|
||||
$drives = Get-MgSiteDrive -SiteId $site.Id
|
||||
# Handle "Shared Documents" special case
|
||||
|
||||
Loading…
Reference in New Issue
Block a user