Taylohtio/_Scripts/list-condos-with-missing-re.../list-condos-with-missing-re...

59 lines
1.1 KiB
PowerShell

param(
[Parameter(Mandatory=$true)]
[string]$url
)
function Write-Log($msg)
{
Write-Host $msg -foregroundcolor green
($msg) | Out-File "log.txt" -Append
}
function Write-Log1($msg)
{
#Write-Host $msg -foregroundcolor green
($msg) | Out-File "condos.txt" -Append
}
function Group-Exists($site, $groupName)
{
$exists = $false
foreach ($group in $site.RootWeb.SiteGroups)
{
if ($group.Name -eq $groupName)
{
$exists = $true
break
}
}
return $exists
}
function Check-Pmc($site)
{
Write-Log $site.Url
foreach ($web in $site.RootWeb.Webs)
{
if ($web.Url.ToLower().Contains("epostitus") -or $web.Url.ToLower().Contains("lomakkeet") -or $web.Url.ToLower().Contains("akatemia"))
{
continue
}
$groupName = $web.Title + " - Responsible property managers"
$exists = Group-Exists $site $groupName
if (!$exists)
{
Write-Log (" " + $web.Url)
Write-Log1 ($web.Url)
}
}
}
$wa = Get-SPWebApplication $url
foreach ($site in $wa.Sites)
{
Check-Pmc $site
}
#$site = Get-SPSite $url
#Check-Pmc $site