21 Aralık 2016 Çarşamba

List All Content Types & Get List Of Items (documents/pages) used by Content types (PowerShell)

List All Content Types

$site = Get-SPSite  http://testsiteur

$web = $site.RootWeb

foreach ($ctype in $web.ContentTypes) {$ctype.Name+" :"+ $ctype.ID}

 Get List Of Items (documents/pages) used by Content types

$webs = get-spsite http://testsiteurl  | get-spweb 

foreach ($web in $webs)
{
  foreach ($lst in $web.lists)
  {
    foreach ($item in $lst.Items)
    {
      if ($item.ContentType.Name -eq "Telefon")
      { $item.ContentType.Name +"-"+ $item.Url}
    }
  }
  $web.Dispose() 
}

Get All Content Databases from SQL by PowerShell

[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
$sqlServer = new-object ("Microsoft.SqlServer.Management.Smo.Server") "test\testsqlserver"
foreach($sqlDatabase in $sqlServer.databases) {$sqlDatabase.name}

19 Aralık 2016 Pazartesi

Sharepoint Get All Features by PowerShell

Get-SPFeature | Sort @{Expression={$_.GetTitle(1033)}} -Descending:$false |
ft @{Label='ID';Width=40;Expression={$_.Id}}, @{Label='Title';Width=250;Expression={$_.GetTitle(1033)}} |
Out-File -Width 350 "c:\TEMP\features.txt"

Get SharePoint Content Database Sizes by PowerShell

$date = Get-Date -Format "dd-MM-yyyy" 
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$TXTFile = "c:ReportsSPContentDatabase_$date.txt"
$webapps = Get-SPWebApplication
foreach($webapp in $webapps)
{
$ContentDatabases = $webapp.ContentDatabases
Add-Content -Path $TXTFile -Value "Content databases for $($webapp.url)"
foreach($ContentDatabase in $ContentDatabases)
{
$ContentDatabaseSize = [Math]::Round(($ContentDatabase.disksizerequired/1GB),2)
Add-Content -Path $TXTFile -Value "-     $($ContentDatabase.Name): $($ContentDatabaseSize)GB"
}
}
------------------------------------------------------------------------------------------
-Send Results By Email-

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$date = Get-Date -Format "dd-MM-yyyy" 
$TXTFile = "c:ReportsSPContentDatabase_$date.txt"
$SMTPServer = "relay.com"
$emailFrom = "test@test.com"
$emailTo = "testto@test.com"
$subject = "Content Database size reports"
$emailBody = "Daily/Weekly/Monthly report on Content databases"

$webapps = Get-SPWebApplication
foreach($webapp in $webapps)
{
$ContentDatabases = $webapp.ContentDatabases
Add-Content -Path $TXTFile -Value "Content databases for $($webapp.url)"
foreach($ContentDatabase in $ContentDatabases)
{
$ContentDatabaseSize = [Math]::Round(($ContentDatabase.disksizerequired/1GB),2)
Add-Content -Path $TXTFile -Value "-     $($ContentDatabase.Name): $($ContentDatabaseSize)GB"
}
}
if(!($SMTPServer) -OR !($emailFrom) -OR !($emailTo))
{
Write-Host "No e-mail being sent, if you do want to send an e-mail, please enter the values for the following variables: $SMTPServer, $emailFrom and $emailTo."
}
else
{
Send-MailMessage -SmtpServer $SMTPServer -From $emailFrom -To $emailTo -Subject $subject -Body $emailBody -Attachment $TXTFile
}

14 Kasım 2016 Pazartesi

Internal Value for Approval Status

This post is mainly for my own reference purpose. The internal field name for approval status of a list/library item is _ModerationStatus, which has corresponding values and it is type of ModStat:


Status
Internal Value
Approved
0
Rejected
1
Pending
2
Draft
3


Sample usage for these values in CAML query : Retrieve all Approved documents from a particular document library
CAML query would look something like below:

<Where><Eq><FieldRef Name=’_ModerationStatus’ /><Value Type=’ModStat’>0</Value></Eq></Where>



Referance:
http://sharepointwriting.blogspot.com.tr/2011/10/internal-value-for-approval-status.html

7 Ekim 2016 Cuma

Create Site Columns & Site Content Types by PowerShell


  • Take care all columns Web id & Lookup Filed List id
    If you have Lookup field first create list and get id