OBtain a list of Unapproved communities by Powershell

The list of all Approved communities exist in a SharePoint List at

http://mysite/sites/communities/MysiteCommunityRequestLib/Forms/AllItems.aspx

All Communities exist in a site collection at

http://mysite/sites/communities/default.aspx

I want to write a PowerShell script that will iterate through the Approved communities in the List named MysiteCommunityRequestLib and the communities in the site collection

http://mysite/sites/communities

If a community exists in the site collection but the name of the community does not exist in the list of approved communities, the code will write the name of the community, Private/Public status and Discoverable/Undiscoverable status to a .csv file named “Unapproved_Communities.csv”.

I want help to implement this functionality. I wrote the below script but its throwing error..This script is not complete

function Get-NGSiteProperties([string] $WebApp) {
$webs = Get-SPWebApplication $WebApp | Get-SPSite -Limit All | Get-SPWeb -Limit All 
 $spweb=getspweb -Identity $webapp
 $spDocumentLibrary = $spWeb.GetList("mysitecommunityrequestlib ")      
foreach ($web in $webs) {  
Write-Host "Getting Site:" $web -foregroundcolor Black -backgroundcolor Yellow  
$data = @{
"web-URL" = $web.URL;
"web-Title" = $web.Title;
"ng-community-title" = $web.Properties["ng-community-title"];
"ng-community-discoverable" = $web.Properties["ng-community-discoverable"];
"ng-community-privacy" = $web.Properties["ng-community-privacy"];
        }

        New-Object PSObject -Property $data;

foreach($list-item in $spDocumentLibrary)

                                {
                                $prop= $list-item.Properties["ng-community-title"];

                                if($prop -eq $data.Properties["ng-community-title"])
                                {
                                //match successful
                                }
                   else  {
                           Write-Host "data.properties"
}             
      Export-Csv c:\logs\communitytitle.csv}
Please check the script and let me know whther I have missed anything. I dont know how to write it so it will save the name of communities with public\private status and discoverable\non discoverable status in csv report.
Thanks in advance
  • Hi,

    If a community exists in the site collection but the name of the community does not exist in the list of approved communities, the code will write the name of the community, Private/Public status PowerShell and Discoverable/Undiscoverable status to a .csv file named “Unapproved_Communities.csv”.

    Thanks and regards,

    Lavanya Sreepada.