reSP – great Resharper plugin from SubPoint Solutions.

Makes Your SharePoint solutions code more stable and robust:
http://subpointsolutions.com/resp/

SharePoint EventHandlerExplorer 2013/2016

Posted: 29th February 2016 by Gennady in Uncategorized

Sharepoint EventHandlerExplorer 2013/2016 is a tool, that allows to register/unregister SharePoint event receivers to specific Webs, Lists/Libs, or Content Types on the fly:

View More..

SharePoint and Why It Always Depends

Posted: 4th February 2016 by Gennady in Uncategorized
:) imho Gr-r-reat post by Bjørn Furuknap about how to talk between Customer and SharePoint Developer:
SharePoint and Why It Always Depends

do-not-repeat-it-in-production_demotivator (1)

When we accidentally delete some web, it could be found in Central Administration’s Recycle Bin(http://server/_layouts/15/AdminRecycleBin.aspx?View=2)

But if we delete Site Collection(that contains all these webs)

connection_close

– in Recycle Bin there will be nothing. You can simply delete site collection like any other web, and there is no one way to restore it from Web Interface :)

There is no preview check like, by example, on GitHub:

Github_Are_You_sure

As usually – SharePoint generates a problem for Us, and then proposes a solution to resolve this problem:

deleted site collection remains in object, which we can access by Get-SPDeletedSite:

get-spdeletedsite_thumb

Knowing its SiteId, we can restore site collection using Restore-SPDeletedSite:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Get-SPDeletedSite
Restore-SPDeletedSite -Identity 8be8d8d4-a8c5-4eda-91cd-0c27b79a050d

p.s.: And if You really want to kill Your site collection – SharePoint can help You here too – welcome to other powershell commandlet Remove-SPSite, which could be undone at all :)

p.p.s.: Be happy, Make backups and Plan Your governance and security in SharePoint :)

Enable PeoplePicker for Anonymous access

Posted: 26th September 2015 by Gennady in C#, SharePoint
Tags: , ,

I have custom webpart with PeopleEditor object inside. By default anonymous users will not see it:

control is not available

To show it we need to grant “BrowseUserInfo” permission from SPBasePermissions enumeration(thanks to Karel Hájek’s post, who digged this problem with Reflector).

does_user_have_permissions

Karel offers to edit Content database to grant it, and then configure Active Directory to allow anonymous queries, all is in his post.

From myself I can give advice to never edit SharePoint Content Database directly. There is more simple method using Powershell:

$sharePointSnapin = Get-PSSnapin | Where-Object { $_.Name -eq  "Microsoft.SharePoint.PowerShell"}
if($sharePointSnapin -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell    
}


$web = Get-SPWeb http://portal/web/

$web.AnonymousPermMask64;
# output:    ViewListItems, ViewVersions, ViewFormPages, Open, ViewPages, UseClientIntegration


$web.AnonymousPermMask64 = "$rights, BrowseUserInfo";
$web.Update();

Now PeoplePicker successfully rendered:

people_picker_rendered

iLoveSharepoint Power Webpart allows Sharepoint 2010 to inject Powershell scripts directly to Sharepoint portal pages.

As behind Powershell is all the power of .NET framework(and not only that), it allows you to create interesting solutions, without opening Visual Studio and WSP deployment.

Let’s create some function in Powershell. For example – will greet the user depending on the time of day. Will print name of current user in friendly format.


# attachSharePoint snap-in in safe way
$sharePointSnapin =Get-PSSnapin | Where-Object { $_.Name-eq  "Microsoft.SharePoint.PowerShell"}
if($sharePointSnapin-eq $null)
{Add-PSSnapin Microsoft.SharePoint.PowerShell    
}


# say helloin accordance with the time of the day
FunctionGetGreeting()
{
    #curent time
    $actualtime = (Get-Date).TimeOfDay;

    # select time interval
    $evening =New-TimeSpan-Hours 17-Minutes 30-Seconds 0
    $morning =New-TimeSpan-Hours 8-Minutes 0-Seconds 0
    $dinner =New-TimeSpan-Hours 11-Minutes 0-Seconds 0
    $night =New-TimeSpan-Hours 22-Minutes 0-Seconds 0
    
    if ($actualtime-ge $morning-and $actualtime-le $dinner)
    {
        return "Good morning";
    }
    if ($actualtime-ge $dinner-and $actualtime-le $evening)
    {
        return "Good day";
    }
    if ($actualtime-ge $evening-and $actualtime-le  $night)
    {
        return "Good evening";
    }
    if ($actualtime-ge  $night-or $actualtime-le  $morning)
    {
        # let's imagine for complete example
        return "Good night :)";
    }
}

# To get display name we can make requests to the DC, but 
# Login User in current DC is in "Domain\Name.Surname" format
# so we can get friendlyDisplayName right here
FunctionGetDisplayName($name)
{
    if($name-match "\\")
    {
        $name = $name.remove(0, $name.LastIndexOf('\')+1);
    }
    if($name-match ".")
    {
        $name = $name.replace("."," ");
    }
           
    return $name
}

$hello = (GetGreeting)+ ", " + (GetDisplayName-name ([Environment]::UserName))


#render html
function Render($writer)
{
    $writer.Write("</pre>
<h1>$hello</h1>
<pre>")
}

The result of executing:

image

So we got dynamic behavior in Sharepoint, without writing code in VS and deploying WSP solutions

New VM configurations in Windows Azure

Posted: 4th January 2015 by Gennady in Azure, PowerShell
Tags: ,

In Windows Azure there are new virtual machines configurations. Some of them could be interesting for testing purposes, like “D11”:

vv_2015-01-04_191856

Existing configuration could be changed in UI or with this code:

Set-ExecutionPolicy RemoteSigned
Import-Module Azure

$VMname = "myVM"
$ServiceName = "myVM"
$VMSize = "A5"

$myVM = Get-AzureVM –ServiceName $ServiceName –Name $VMname
$myVM | Stop-AzureVM
$myVM | Set-AzureVMSize $VMSize | Update-AzureVM

where VMsize is a value from this list:

ExtraSmall,Small,Medium,Large,ExtraLarge,A5,A6,A7,A8,A9,Basic_A0,Basic_A1,Basic_A2, Basic_A3,Basic_A4,Standard_D1,Standard_D2,Standard_D3,Standard_D4,Standard_D11, Standard_D12,Standard_D13,Standard_D14