Wednesday, September 28, 2016

Disable default "Send an email invitation" SharePoint 2013

How to permanently disable send an email invitation when granting access? We need it by default unchecked ( send an email invitation unchecked).























Open file C:\Program Files\Common Files\Microsoft Shared\web server extensions\15\TEMPLATE\LAYOUTS\aclinv.aspx
Change the Checked="true" to Checked="false"

<div class="ms-core-form-subsection">
                <asp:CheckBox
                    runat="server"
                    id="chkSendEmailv15"
                    Checked="true"
                    class = "ms-aclinv-checkbox"
                    OnClick="UpdateSendEmailMessage()"/>
                <label for=<%SPHttpUtility.WriteAddQuote(SPHttpUtility.NoEncode(chkSendEmailv15.ClientID),this.Page);%>>
                    <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,aclinv_SendEmailCheckboxv15%>" EncodeMethod='HtmlEncode'/>
                </label>


Note: Change on all SharePoint Servers

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.

Tuesday, June 28, 2016

Restart Windows Service on failure and send mail - PowerShell


How to send email if a windows service stops?



In order to run a PowerShell script you first must define the program in this case you provide the full path to the PowerShell EXE.

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

The next you add in the remaining commands you want to execute when running the program. What I did was the following.

-command “& {C:\Skripte\ServiceAlertFromRecovery.ps1 ‘MSCRMAsyncService’ %1%}”


 Inside the script there are a few variables you will want to change. The items to change are all located near the top and are located in the “SendAlert” function.
  • $FromAddress = The from address for the email.
  • $ToAddress = You can use one or more email addresses separated by commas and all contained within the quotes.
  • $MessageSubject = This can be changed based on your needs but most likely doesn’t need any changing.
  • $MessageBody = This can be changed based on your needs but most likely doesn’t need any changing.
  • $SendingServer = The IP Address of the SMTP server you want to use.

$ComputerName = (get-wmiobject Win32_Computersystem).name
$ServiceName = $args[0]
$ServiceDisplayName = (Get-Service $ServiceName).DisplayName
$TimesRestarted = $args[1]

Get-Service $ServiceName
$Status = (Get-Service $ServiceName).Status
If ($Status -ne "Running")
{
 Start-Service $ServiceName
}

function SendAlert
{
  $FromAddress = "ServiceFailure@domain.com"
  $ToAddress = "emailaddr@domain.com"
  $MessageSubject = "Service Failure for $ComputerName"
  $MessageBody = "The $ServiceDisplayName ($ServiceName) service on $ComputerName has restarted $TimesRestarted times in the last 24 hours. Please review server event logs for further information."
  $SendingServer = ""

  ###Create the mail message and add the statistics text file as an attachment
  $SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress, $MessageSubject, $MessageBody

  ###Send the message
  $SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer
  $SMTPClient.Send($SMTPMessage)
}

SendAlert 
 
 
Download script 


Ref: http://it-erate.com/restart-windows-service-failure-powershell-script/





Revocation information certificate for this site not available. Do you want to proceed?

Sometimes, when you visit secure websites, you may receive the message "Revocation information for the security certificate for this site is not available. Do you want to proceed?" You need to adjust some of your settings to get rid of this message.






Disable the option to check for server certificate revocation on Internet Explorer

To disable server certificate revocation:
1. Open Internet Explorer.
2. On the Tools menu, click Internet Options.

3. Click the Advanced tab.

4. Scroll down to the Security section, and then uncheck the Check for server certificate revocation check box.

5. Click Apply, and then click OK.

6. Close the Internet Explorer window.

Thursday, March 24, 2016

Make SharePoint List Column (Form Field) Read Only - PowerShell

How to make SharePoint list column read only with PowerShell?

Start SharePoint Management Shell as Administrator

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Get the Web
$web = Get-SPWeb http://SiteName
#Get the List
$List = $Web.Lists["ListName"]
#Get the Field
$Field = $List.Fields["FieldName"]
#Set the field to Read only
$Field.ReadOnlyField = $true
$Field.Update()

Thursday, February 25, 2016

ILM Configuration: The miissku.exe process exited with error code -2146232832. Error. - SharePoint 2013


ILM Configuration: The miissku.exe process exited with error code -2146232832. Error.

ILM Configuration: The ValidateMiisEncryptionKey process returned False.
 

UserProfileApplication.SynchronizeMIIS: Failed to configure MIIS pre database, will attempt during next rerun.

Synchronization database is already initialized. Importing the encryption key for the database into the registry


 

Run as Administrator SharePoint Management Shell


$sync_db = "Sync DB"
$ups_service_app_name = "User Profile Service Application"



net stop sptimerv4
$syncdb=Get-SPDatabase | where {$_.Name -eq $sync_db}
$syncdb.Unprovision()
$syncdb.Status='Offline'
$ups = Get-SPServiceApplication  | where {$_.Displayname -eq $ups_service_app_name }
$ups.ResetSynchronizationMachine()
$ups.ResetSynchronizationDatabase()
$syncdb.Provision()
net start sptimerv4

Start the UserProfileSyncService again


Ref: http://blogs.technet.com/b/sp/archive/2013/05/29/http-www-blogger-com-blogger-g-blogid-8070685728411204795-editor-target-post-postid-706076184673021818-onpublishedmenu-overviewstats-onclosedmenu-overviewstats-postnum-23-src-postname.aspx

Friday, February 5, 2016

Specified host is not present in cluster - Distributed cache



Use-CacheCluster
Get-AFCacheHostConfiguration -ComputerName ComputerName -CachePort "22233"



If you receive a message stating “Specified host is not present in cluster” one of two things occurred; you misspelt the ComputerName (or port), or the computer is in fact not present in the cluster.


Re-registering a computer is simple enough, from that Management Shell, execute the following cmdlet:



Register-CacheHost –Provider "ProviderName" –ConnectionString "ConnectionString" –Account “NT Authority\Network Service” –CachePort 22233 –ClusterPort 22234 –ArbitrationPort 22235 –ReplicationPort 22236 –HostName "ComputerName"

Note: Provider and ConnectionString parameters are located in the HKLM registry hive under Software\Microsoft\ AppFabric\v1.0\Configuration



Again start command:

Use-CacheCluster
Get-AFCacheHostConfiguration -ComputerName ComputerName -CachePort "22233"