i'm trying for several hours, but don't get why this is not working...
https://tenant.sharepoint/sites/SiteA
https://tenant.sharepoint/sites/SiteB
https://tenant.sharepoint/sites/SiteC
https://tenant.sharepoint/sites/SiteD
Get all SharePoint Sites
Check if a SharePoint site is on CSV list
The Problem is, i always get "False" as result. What is the issue?
$exceptionSites = Import-Csv -Path "Document.csv"
$siteFilter = $exceptionSites.ExceptSite
$sites = Get-SPOSite -Limit ALL | select url
foreach ($site in $sites)
{
if ($siteFilter -contains $site)
{
Write-Output "Site is on list"
}
else
{
Write-Output "Site is not on list"
}
}
when i change if ($siteFilter -contains "https://tenant.sharepoint/sites/SiteA") it's working....
Take a look at $Sites
in your code. You'll see it still has the URL property.
Try this:
$sites = Get-SPOSite -Limit ALL | Select-Object -ExpandProperty url
Or try this:
if ($siteFilter -contains $site.url)
But don't do both.