Showing posts with label PowerShell scripts. Show all posts
Showing posts with label PowerShell scripts. Show all posts

May 16, 2014

Retrive all deployed solutions / .WSP files from the Farm

Hi All,

please do find below Power Shell script which will retrieve all deployed solutions to the local drive:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local 
$farm.Solutions | % {  
$filename = ($pwd.ToString() + "\" + $_.SolutionFile.Name);  
write-host ("Saving" + $filename);  
$_.SolutionFile.SaveAs($filename) 
       } 

save this above lines of code as a .ps1 file and execute [Won't support if OS is Windows server 2003]
tested in SharePoint 2007 environment [Windows server 2008 r2], you can try in 2010 also.

Thanks,
JK

February 10, 2012

Powershell script to List All Sharepoint Site collections and sub sites

Hi,

i came up with an requirement to gather all the site collections and sites and sub sub sites in our 2007 & 2010 environment. so decided to prepare a poweshell script which can list all site collection and it's sub webs list under the site collection and a Final count. the script as follows:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
$siteUrl = Read-Host "Enter Site URL"
$rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl)
$spWebApp = $rootSite.WebApplication
$count = 0
           write-host "Site Collections"
           write-host ""
    foreach ($site in $spWebApp.Sites) {
        $count++
        write-host "Site Collections URL --> -->" $site.URL
           write-host ""
           write-host "SubSites"
           write-host ""
    foreach ($web in $site.AllWebs) {
        $count++
        write-host "SubSite URL --> --> -->" $web.URL 
        write-host ""
    } 
}

write-host "Total Count :" $count

Hope this script help in your requirement too.

Regards,
JK

November 24, 2011

PowerShell Script To Display All SharePoint Site Collection Administrators In Web Application

Hi,

In my SharePoint Environment, we got a requirement to populate site collection admins list from the couple of  web applications. each web appilication contains 30+ sitecollections. so to pick the list in a manual way is a bit difficult & i am lazy too. so i got this below script in the artcle, and i modified according to my requirement to generate a report. script as below:

[System.Reflection.Assembly]::LoadWithPartialName(”Microsoft.SharePoint”)
$siteUrl = Read-Host "Enter Site URL"
$rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl)
$spWebApp = $rootSite.WebApplication
 foreach($site in $spWebApp.Sites)
{
    Write-Host "-----------------------------------------------------------"
    Write-Host "$site"
    foreach($siteAdmin in $site.RootWeb.SiteAdministrators)
    {
        Write-Host "$($siteAdmin.Name)"
    }
    $site.Dispose()
    Write-Host "-----------------------------------------------------------"
}
$rootSite.Dispose()


Regards,
Girish