Thursday, July 28, 2016

Export users from group - Sharepoint

How to export users from SharePoint group with PowerShell?


Get-SPWeb https://projekt/orgit/ |
Select -ExpandProperty SiteGroups |
Where {$_.Name -EQ "Orgit-Visitors"} |
Select -ExpandProperty Users |
Select Name |
Out-File C:\NewFolder\Members.txt
#No free space after the name-for easier import
$content = Get-Content Members.txt
$content | Foreach {$_.TrimEnd()} | Set-Content Members.txt


Note: Before command locate folder where you wont to export file (txt, csv...) (cd c:\NewFolder)

Friday, July 22, 2016

Can't open Excel when a file run from task scheduler

Why can't Excel open a file when run from task scheduler?

I wrote a powershell script that opens an excel workbook and runs a macro. When I run that script from PS console, or even from command line using powershell.exe script.ps1, it jus works. When I set up a task from the windows task scheduler, it raises an exception about that excel file, saying that it either does not exist or is already in use.

Solution 1

Create these two folders:

32Bit:

C:\Windows\System32\config\systemprofile\Desktop 

64Bit:

C:\Windows\SysWOW64\config\systemprofile\Desktop

Excel needs these folders if it's not run interactively.


Solution 2

Open Component Services (Start -> Run, type in dcomcnfg)

Drill down to Component Services -> Computers -> My Computer and click on DCOM Config

Right-click on Microsoft Excel Application and choose Properties

In the Identity tab select This User and enter the ID and password of an interactive user account (domain or local) and click Ok

Note: When setting DCOM permissions, if Microsoft Excel doesn't appear in dcomcnfg try mmc comexp.msc /32

Monday, July 18, 2016

Disable\Enable SiteCollection visual upgrade - SharePoint

How to Disable\Enable SharePoint SiteCollection visual upgrade with PowerShell?

Open SharePoint Management Shell as Administrator

Disable:

$webAppUrl = "https://sbportal";
Get-SPSite -Limit All -CompatibilityLevel 14 -WebApplication $webAppUrl | % { $_.AllowSelfServiceUpgrade = $false; $_.AllowSelfServiceUpgradeEvaluation = $false; }


Enable:

$webAppUrl = "https://sbportal";
Get-SPSite -Limit All -CompatibilityLevel 14 -WebApplication $webAppUrl | % { $_.AllowSelfServiceUpgrade = $true; $_.AllowSelfServiceUpgradeEvaluation = $true; }

Tuesday, July 12, 2016

Change site collection URL in SharePoint 2013

How to change the site collection URL in SharePoint 2013? Suppose in your company, you have already created your site collection and customized everything but later, your company decides to change the Site URL. What will you do?

Open SharePoint Management Shell as Administrator

$site = Get-SPSite http://sharepoint/sites/marketing
$uri = New-Object System.Uri("http://sharepoint/sites/sales")
$site.Rename($uri)

Run IIS reset

You can only use this to rename site collection URL’s that
– Use “Wildcard inclusion” Managed Paths.
– Are Host named site collections (In which case you could also use Set-SPSiteURL)
You can’t use it to change http://sharepoint/sites/marketing to http://sharepoint/marketing (Even if the Explicit inclusion managed path exists).


Monday, July 11, 2016

Sharepoint BCS Login failed for user “NT AUTHORITY\ANONYMOUS LOGON”

Pass through authentication not working for BCS on a WebApplication which is Claims based and using Kerberos.While you try to access the External List based on User’s Identity  you received the following error Login failed for user ‘NT AUTHORITY\ANONYMOUS LOGON’


By Default Revert to Self is disabled. We will need to run following CMDlets from PowerShell to enable it


Open SharePoint Management Shell as Administrator


 $bdc = Get-SPServiceApplication | where {$_ -match "Business Data Connectivity Service"}; 
 $bdc.RevertToSelfAllowed = $true; 
 $bdc.Update();



We will need to modify External Content type by using SharePoint designer and have it use BDC Identity 



Select BDC Identity under Default and Client TAB and click on OK.

Now it will let all the users browse to the external list.














SharePoint BCS - Change default max number of rows


How to change limit of Items in External list in SharePoint?

Database Connector has throttled the response. The response from database contains more than '2000' rows. The maximum number of rows that can be read through Database Connector is '2000'. The limit can be changed via the 'Set-SPBusinessDataCatalogThrottleConfig' cmdlet.



Start SharePoint Management Shell as Administrator

$bdcProxy = Get-SPServiceApplicationProxy | where {$_.GetType().FullName -eq (‘Microsoft.SharePoint.BusinessData.SharedService.’ + ‘BdcServiceApplicationProxy’)}

$dbRule = Get-SPBusinessDataCatalogThrottleConfig -Scope Database -ThrottleType Items -ServiceApplicationProxy $bdcProxy

Set-SPBusinessDataCatalogThrottleConfig -Identity $dbRule -Maximum 1000000 -Default 5000

Default is the limit that is applied to external list. Change default number.