Tagged: audit Toggle Comment Threads | Keyboard Shortcuts

  • akhileshgandhi 6:52 pm on July 2, 2013 Permalink | Reply
    Tags: audit, lastmodified, , , , size   

    Get All SiteCollection Audit Info 

    cls
    #get-spsite -Limit All -ContentDatabase WSS_Content_ProjectServer | select url,@{label=”Size in GB”;Expression={$_.usage.storage/1024MB}} | Format-Table –AutoSize

    function ProcessSiteCollection($site)
    {

    $list = $site.url

    if ($site.Quota.Storagemaximumlevel -gt0)
    {
    [int]$MaxStorage = $site.Quota.StorageMaximumLevel /1MB
    }
    else
    { $MaxStorage = “0”
    };
    $contentDbName = get-spsite -Identity $list -Limit All | select contentdatabase
    if ($site.Usage.Storage -gt0) {[int]$StorageUsed = $site.Usage.Storage /1MB};
    if ($Storageused -gt0 -and $Maxstorage -gt0){[int]$SiteQuotaUsed = $Storageused / $Maxstorage * 100} else {$SiteQuotaUsed = “0”};
    $subsite = New-Object System.Object

    $subsite | Add-Member -MemberType NoteProperty -Name “Url” -Value $site.Url
    $subsite | Add-Member -MemberType NoteProperty -Name “Web Application” -Value $Webapp.DisplayName
    $subsite | Add-Member -MemberType NoteProperty -Name “Owner Name” -Value $site.Owner.Name
    $subsite | Add-Member -MemberType NoteProperty -Name “Owner Email” -Value $site.Owner.Email
    $subsite | Add-Member -MemberType NoteProperty -Name “Last Modified” -Value $site.LastContentModifiedDate.ToShortDateString()
    $subsite | Add-Member -MemberType NoteProperty -Name “Quota Limit (MB)” -Value $MaxStorage
    $subsite | Add-Member -MemberType NoteProperty -Name “Total Storage Used (MB)” -Value $StorageUsed
    $subsite | Add-Member -MemberType NoteProperty -Name “Site Quota Percentage Used” -Value $SiteQuotaUsed
    $subsite | Add-Member -MemberType NoteProperty -Name “Content DB” -Value $site.ContentDatabase.Name
    $global:SiteCollInfo += $subsite

    Write-Host “Title :” $site.HostName
    Write-Host “Url :” $site.Url
    Write-Host “Web Application” $Webapp.DisplayName
    Write-Host “Owner Name” $site.Owner.Name
    Write-Host “Owner Email” $site.Owner.Email
    Write-Host “Last Modified” $site.LastContentModifiedDate.ToShortDateString()
    Write-Host “Quota Limit (MB)” $MaxStorage
    Write-Host “Total Storage Used (MB)” $StorageUsed
    Write-Host “Site Quota Percentage Used” $SiteQuotaUsed
    Write-Host “Content DB” $site.ContentDatabase.Name
    Write-Host
    # $web = Get-SPWeb $site.Url
    # [long]$total = 0
    # # $total += GetWebSize -Web $web
    # $val = ProcessSubWebs -Site $web
    # $total += $total +$val ;
    # $totalInMb = ($total/1024)/1024
    # $totalInMb = “{0:N2}” -f $totalInMb
    # $totalInGb = (($total/1024)/1024)/1024
    # $totalInGb = “{0:N2}” -f $totalInGb
    # write-host “Total size of all sites below” $StartWeb “is” $total “Bytes,”
    # write-host “which is” $totalInMb “MB or” $totalInGb “GB” -foregroundcolor blue
    $web.Dispose()

    }

    function ProcesWebApplication($Webapp)
    {
    Write-Host “Web Application : ” $webApp.name
    Write-Host “Application Pool : ” $webApp.ApplicationPool.Name
    # #Get all Solution in Web Application
    # Get-SPSolution | ForEach-Object {
    # if ($_.LastOperationDetails.IndexOf($webApp.url) -gt 0)
    # {
    # Write-Host ” Solutions:”
    # Write-Host ” ” $_.DisplayName
    # }
    # }

    #Get All Site Collection in a Web Application
    foreach($site in $webApp.Sites)
    {
    ProcessSiteCollection $site ;
    $site.Dispose()
    }

    }

    $global:SiteCollInfo = @()
    #Get All Web Application
    $contentWebAppServices = (Get-SPFarm).services |? {$_.typename -eq “Microsoft SharePoint Foundation Web Application”}

     

    foreach($webApp in $contentWebAppServices.WebApplications)
    {

    ProcesWebApplication -Webapp $webApp;

    }

    $global:SiteCollInfo | Export-Csv -NoTypeInformation -Path “C:\AllSiteCollectionInfo.csv”

     
  • akhileshgandhi 9:25 pm on July 1, 2013 Permalink | Reply
    Tags: audit, pwoershell,   

    Sharepoint Audit Report 

     

    Get Items not modified for more then 3 years in entire Farm

     

    Get-SPSite -Limit All | Select -ExpandProperty AllWebs | Select -ExpandProperty Lists | Where { $_.GetType().Name -eq “SPDocumentLibrary” -and -not $_.Hidden } |
    Select -ExpandProperty Items |
    Where { $_[“Modified”] -lt (Get-Date).AddYears(-3) } |
    Select Name, {$_[“Modified”]},
    @{Name=”URL”;Expression={$_.ParentList.ParentWeb.Url + “/” + $_.Url}}

     

     

    Get Items where size is grreater then 5MB

    Get-SPSite -Limit All | Select -ExpandProperty AllWebs | Select -ExpandProperty Lists | Where { $_.GetType().Name -eq “SPDocumentLibrary” -and -not $_.Hidden } |
    Select -ExpandProperty Items | Where { $_.File.Length -gt 5MB } | Select Name, {$_.File.Length/1MB}, @{Name=”URL”;Expression={$_.ParentList.ParentWeb.Url + “/” + $_.Url}}

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel