19 Aralık 2016 Pazartesi

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

18 Aralık 2015 Cuma

Sharepoint Field get ıtem Append Changes to Existing Text

 public static string GetVersionedMultiLineTextAsPlainText(SPListItem item, string key)
        {

            StringBuilder sb = new StringBuilder();

            foreach (SPListItemVersion version in item.Web.Lists[item.ParentList.ID].Items[item.UniqueId].Versions)
            {

                SPFieldMultiLineText field = version.Fields[key] as SPFieldMultiLineText;

                if (field != null)
                {

                    string comment = field.GetFieldValueAsText(version[key]);

                    if (comment != null && comment.Trim() != string.Empty)
                    {

                        sb.Append("");

                        sb.Append(version.CreatedBy.User.Name).Append(" (");

                        sb.Append(version.Created.ToString("MM/dd/yyyy hh:mm tt"));

                        sb.Append(")

");
                        sb.Append("-" + comment);
                        sb.Append("
");
                    }

                }

            }

            return sb.ToString();

        }


7 Aralık 2015 Pazartesi

Button Click => FileUplaod

 

 lnkbtnAddPhoto.Attributes.Add("onclick", "document.getElementById('" + FileUpload1.ClientID + "').click()");

24 Kasım 2015 Salı

Sharepoint infopath submit form by date/user/item id

Submit formula:

  • concat(substring-before(now(); "T"); "-"; substring-after(userName(); "domain");"-";"formID=", max(ID) + 1 )


Referans:
http://www.spointblog.com/Pages/Post.aspx?ItemID=26

17 Kasım 2015 Salı

Sharepoint login as different user

Text="<%$Resources:wss,personalactions_loginasdifferentuser%>"
Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>"
MenuGroupId="100"
Sequence="100"
UseShortId="true" />

  • C:\Program Files\Common Files\Microsoft shared\Web ServerExtensions\15\TEMPLATE\CONTROLTEMPLATES Gidip: 

Welcome.ascx user kontrolünün NOTEPAD'le açıp içine yukarıda yazdığım kontrolü yapıştırıp kaydedin.


SpList Status Indicator


Referenced: http://officepowerups.com/2013/06/11/display-icons-in-sharepoint-list/

12 Kasım 2015 Perşembe

Event Receiver Properties

Library         BeforeProperties    AfterProperties    properties.ListItem
ItemAdding      No value            No value           Null
ItemAdded       No value            No value           New value
ItemUpdating    Original value      Changed value      Original value
ItemUpdated     Original value      Changed value      Changed value
ItemDeleting    No value            No value           Original value
ItemDeleted     No value            No value           Null
Dursun bi şurda :D