Posted on:
Categories: PowerShell;SharePoint
Description:
​If you ever need to change protocol for the sites on your farm, you may want the ability to back up, and change the QuickLinks saved to users' MySites. These are the links used for the "Connect to Office" functionality. These sites are kept in a hidden list on your mysite accesible either through "Managing your SharePoint sites" or via MysiteHostURL/_layouts/MyQuickLinks.aspx If you implement a protocol change for any site with links in this list, these links will be broken. The Scripts below will allow you to backup the current state of all users' quick links as well as changing them from http to https and back. With a simple modification to the script, you could also target a single user. You will need to create the C\_UProfileLinks directory before running this script. The script below will export all links in their current state to the XML file "C\_UProfileLinks\ddMMMyyyyHHmmss.xml" . You will need to run the script with an account that has permission on the User Profile Service as well as possibly running the script from an elevated command prompt as administrator in order to write to the file system. You also need to change line 15 in the script to include a valid ULR hosted by the farm to create a service context. Below is the script for backing up the links if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) Add-PSSnapin "Microsoft.SharePoint.PowerShell" $folder = "C\_UProfileLinks" $date = Get-Date -format "ddMMMyyyyHHmmss" $Path = $folder + "\" + $date + ".xml" $XmlWriter = New-Object System.XMl.XmlTextWriter($Path,$Null) $xmlWriter.Formatting = 'Indented' $xmlWriter.Indentation = 1 $XmlWriter.IndentChar = "`t" #------- YOU MUST CHANGE THE URL BELOW ---------------- $url = "http//AnyURLInTheFarm" #Site only for getting context, this can be any url hosted in the farm #------- YOU MUST CHANGE THE URL ABOVE ---------------- $site = Get-SPSite $url $context = Get-SPServiceContext($site) $UProfileMgr = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) $UProfileMgrEnum = $UProfileMgr.GetEnumerator() $xmlWriter.WriteStartDocument() $xmlWriter.WriteStartElement('SiteCollection') $XmlWriter.WriteAttributeString('SPSite', $site.Url) foreach($UProfile in $UProfileMgrEnum ) Try If ($UProfileMgr.UserExists($($UProfile["AccountName"]))) $qlm = $UProfile.QuickLinks $qlmLinks = $qlm.GetItems() If ($qlmLinks -ne $null) $xmlWriter.WriteStartElement('Account') $xmlWriter.WriteAttributeString('Username', $UProfile["AccountName"]) foreach($qlink in $qlmLinks) $xmlWriter.WriteStartElement('Link') $XmlWriter.WriteAttributeString('Url', $qlink.Url) $xmlWriter.WriteEndElement() $xmlWriter.WriteEndElement() else #Do nothing Catch [Exception] Return $_.Exception.Message $xmlWriter.Flush() $xmlWriter.Close() $xmlWriter.WriteEndElement() $xmlWriter.WriteEndDocument() $xmlWriter.Flush() $xmlWriter.Close() To change the links from http/80 to https/443 you can use the script below. (If some users already have the target protocl in place, this script will simply ignore them. It only changes http links to https (default). You will need to create the C\_UProfileLinks directory before running this script. This script also outputs a log to the file C\_UProfileLinks\ConversionLog_ddMMMyyyyHHmmss.xml showing the changes applied. You also need to change line 15 in the script to include a valid ULR hosted by the farm to create a service context. There are 3 lines to change to implement a change from https/443 to http/80. Change all 3 lines to have the script flip links from https/443 to http/80 if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) Add-PSSnapin "Microsoft.SharePoint.PowerShell" $folder = "C\_UProfileLinks" $date = Get-Date -format "ddMMMyyyyHHmmss" $Path = $folder + "\ConversionLog_" + $date + ".xml" $XmlWriter = New-Object System.XMl.XmlTextWriter($Path,$Null) $xmlWriter.Formatting = 'Indented' $xmlWriter.Indentation = 1 $XmlWriter.IndentChar = "`t" #------- YOU MUST CHANGE THE URL BELOW ---------------- $url = "http//AnyURLInTheFarm" #Site only for getting context, this can be any url hosted in the farm #------- YOU MUST CHANGE THE URL ABOVE ---------------- $site = Get-SPSite $url $context = Get-SPServiceContext($site) $UProfileMgr = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) $UProfileMgrEnum = $UProfileMgr.GetEnumerator() $xmlWriter.WriteStartDocument() $xmlWriter.WriteStartElement('SiteCollection') $XmlWriter.WriteAttributeString('SPSite', $site.Url) foreach($UProfile in $UProfileMgrEnum ) Try If ($UProfileMgr.UserExists($($UProfile["AccountName"]))) $qlm = $UProfile.QuickLinks $qlmLinks = $qlm.GetItems() If ($qlmLinks -ne $null) $xmlWriter.WriteStartElement('Account') $xmlWriter.WriteAttributeString('Username', $UProfile["AccountName"]) foreach($qlink in $qlmLinks) $xmlWriter.WriteStartElement('Link') $XmlWriter.WriteAttributeString('OG_Url', $qlink.Url) $xmlWriter.WriteEndElement() #------------------------------------ $ogURL = $qlink.Url # 1/3 change condition to "https" to match changing FROM https TO http If ($ogURL.Contains("http")) # 2/3 change the parameters here to ("https","http") to change links FROM https TO http $newProtocolURL = $ogURL.Replace("http","https") # 3/3 change the parameters here to ("443","80") to change links FROM 443/https TO 80/http $finalURL = $newProtocolURL.replace("80","443") $qlink.Url = $finalURL $qlink.Commit() #------------------------------------ $xmlWriter.WriteStartElement('Link') $XmlWriter.WriteAttributeString('New_Url', $qlink.Url) $xmlWriter.WriteEndElement() Else # do nothing $xmlWriter.WriteEndElement() else # do nothing Catch [Exception] Return $_.Exception.Message $xmlWriter.Flush() $xmlWriter.Close() $xmlWriter.WriteEndElement() $xmlWriter.WriteEndDocument() $xmlWriter.Flush() $xmlWriter.Close()




Posted on:
Categories: SharePoint
Description:
We were recently called to troubleshoot a SharePoint server services down situation on a client's staging farm. All browsing of SharePoint sites resulted in correlation errors on the configured web front end server. Browsing sites on the configured application server also hosting the SharePoint Foundation Web Application service, were fully functional. This web front end server is the primary web application server servicing client request and therefore was the only server with the Forefront product installed and configured. This identified the WFE as the problematic server for further investigation.Symptoms Correlation errors when browsing any site protected by Microsoft Forefront Protection 2010 for SharePoint Source SharePoint Foundation / ULS & Application Error EventID 1 (Antivirus Scanner timed out) logged immediately when clients request web services from web application services Source FSCEventing Application Information EventID 1076 (Forefront Protection Eventing Service has stopped) logged continuously on server running Microsoft Forefront Protection 2010 for SharePoint Microsoft Forefront Server Protection Controller windows service will not start due to "dependency" errors Microsoft Forefront Server Protection console will hang/freeze upon launch from the start menuCause These symptoms can be caused when the Forefront Protection 2010 for SharePoint will not start successfully. Specifically the "Microsoft Forefront Server Protection Controller" service will not start. When the Forefront Protection 2010 for SharePoint is installed, this service processes all incoming browsing requests through the Forefront Antivirus scanning engine. When the product is enabled, SharePoint browsing will not function without this request handler. The services must be running. In this way, it ensures protection of the farm. In this situation the root cause of the service failure was a corrupted config file in the Forefront Protection 2010 for SharePoint application directory. "C\Program Files\Microsoft Forefront Protection for SharePoint\Data\Configuration.xml" The application periodically creates a backup of this file (Configuration.bak), in this case the backup was also corrupted. This was likely due to a hard shutdown of the server.Resolution The final resolution of this issue was using a functioning "Configuration.xml" file "C\Program Files\Microsoft Forefront Protection for SharePoint\Data\Configuration.xml" from a working farm (our errors were on a staging farm so fortunately we had a producion farm to copy the file from). The steps to resolve and tools used to troubleshoot the issue are below.Implementing the fix Stop all SharePoint services on the server with the failing Forefront product. In out two server farm, the web front end was the only server with the product/services running. Stop the windows SharePoint services in order SharePoint Administration Services SharePoint Timer Services SharePoint Tracing Services World Wide Web Publishing services Once these services have stopped successfully, we disabled the Forefront services by using the FSCUtility.exe utility from the application program directory. C\Program Files\Microsoft Forefront Protection for SharePoint\FSCUtility.exe /disable Ref http//technet.microsoft.com/en-ca/library/dd639437.aspx Replace the corrupted "Configuration.xml" file with a known good, or file from backup. Re enable Forefront services C\Program Files\Microsoft Forefront Protection for SharePoint\FSCUtility.exe /enable Start the windows SharePoint services in order SharePoint Administration Services SharePoint Timer Services SharePoint Tracing Services World Wide Web Publishing services Start the "Microsoft Forefront Server Protection Controller" windows service on the server. This will start all required subordinate Forefront services.Outcome In our scenario, this restored all Forefront services as well as all SharePoint services and brought the farm back to a functional state. The Forefront console was then fully functional and the product was fully configurable.Troubleshooting Tools usedSharePoint ULS Log Viewer Reviewing the ULS logs on the web front end server revealed it as the only problematic server as well as identified the "Antivirus Scanner timed out" errors immediately on browsing the sites. This pointed us to investigate the Forefront product as the cause.Sysinternals Procmon Using procmon on the server while starting the Forefront Server Protection Controller windows service illustrated high numbers of reads/failures on the "C\Program Files\Microsoft Forefront Protection for SharePoint\Data\Configuration.xml" file on the file system. We also noticed continued reading/writing to the "C\Program Files\Microsoft Forefront Protection for SharePoint\Data\Configuration.bak" configuration backup file.Forefront Management Shell The Microsoft Forefront Protection 2010 for SharePoint product has a PowerShell console that allows for non-gui administration of the Forefront product. Ref http//technet.microsoft.com/en-us/library/dd639426.aspx I hoped to elevate the tracing levels of the product for further troubleshooting with "Set-FsspTracing -Level Verbose" however, this would error out likely due to the controller services failing.




Posted on:
Categories: SharePoint
Description:
Scenario When you click on the TimeSheet link in Project Server 2013 an error is shown.Solution ULS Logs showed the following stack trace [bucketHash3754B72C] Exception occured in method 'TimeSheet.CreateTimesheet' System.ArgumentException An item with the same key has already been added. at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) at Microsoft.Office.Project.Server.Events.ServerEventManager.ConfiguredServerEvents.EventHandlerConfiguration.GetInstance(ProjectSite projectSite) at Microsoft.Office.Project.Server.Events.ServerEventManager.ConfiguredServerEvents..ctor(ProjectSite projectSite) at Microsoft.Office.Project.Server.Events.ServerEventManager.ConfiguredServerEvents.<>c__DisplayClass8.<GetInstance>b__7() at Microsoft.Office.Project.Server.Utility.LazySet`2.GetValue(TKey key, Func`1 instanceFactory) at Microsoft.Office.Project.Server.Events.ServerEventManager.ConfiguredServerEvents.GetInstance(Guid siteUid) at Microsoft.Office.Project.Server.Events.ServerEventManager.<GetServerEventManager>b__0(IPlatformContext context) at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) at Microsoft.Office.Project.Server.Events.ServerEventManager.GetServerEventManager(IPlatformContext platformContext) at Microsoft.Office.Project.Server.BusinessLayer.TimeSheet.CreateTimesheet(TimesheetDataSet dsDelta, PreloadType preloadType) at Microsoft.Office.Project.Server.Wcf.Implementation.TimeSheetImpl.<>c__DisplayClass45.<CreateTimesheet>b__44() at Microsoft.Office.Project.Server.Wcf.Implementation.WcfMethodInvocation.InvokeBusinessObjectMethod(String businessObjectName, String methodName, IEnumerable`1 actions) StackTrace at Microsoft.Office.Project.Server.Native.dll (sig=874dbfdc-4770-4b1a-81f8-2b3d83ee10e5|2|microsoft.office.project.server.native.pdb, offset=3C1E) at Microsoft.Office.Project.Server.Native.dll (offset=1255D) Based on the stack trace, I know the issue is that Microsoft.Office.Project.Server.Events.ServerEventManager.ConfiguredServerEvents.EventHandlerConfiguration.GetInstance() method returns two items with the same id. Open the code using JustDecompile or Reflector Issue occurs at the highlighted line, where the code converts eventHandlersDataSet object to a Dictionary with the Key of PSEventID. Next, I looked at the ReadEventHandlerAssociations() method to see where it's getting its data from. The code lead us to a ReadEventReceivers() method. This code calls the "MSP_ADMIN_ReadEventReceivers" Stored Procedure and returns a EventHandlersDataSet. After dissecting the MSP_ADMIN_ReadEventReceivers Stored Procedure, I was able to create the following query "SELECT EVENT_ID FROM pub.MSP_EVENT_HANDLERS GROUP BY EVENT_ID" When I ran this query it showed that Event_ID 95 had two items. Removing the AxUtils.ResourceEventsForAxSync Event Handler from the "Server Side Event Handlers" menu in Central Administration resolved the issue.




Posted on:
Categories: SharePoint;PowerShell
Description:
Symptoms After upgrading to SharePoint 2013 from SharePoint 2010, you notice that incoming email is not working. You can see that incoming emails are appearing in the drop folder of the server that you have configured to receive incoming emails, but they are never processed. Solution You can manually toggle incoming email on and off for each list that is configured to receive incoming email; however, if you have a lot of lists that are configured to receive incoming email, this is not a practical solution. The following PowerShell script will check all lists in your farm and essentially toggle incoming email off and on, which should resolve this issue. $sites = Get-SPSite -limit all foreach($site in $sites) foreach($web in $site.Allwebs) foreach($list in $web.lists) if(($list.CanReceiveEmail -eq "True") -and ($list.EmailAlias -ne $null)) Write-Host $web.Url Write-Host -foregroundcolor Green $list.Title Write-Host -foregroundcolor Yellow $list.EmailAlias $alias = $list.EmailAlias $list.EmailAlias = $null $list.Update() $list.EmailAlias = $alias $list.Update()




Posted on:
Categories: SharePoint;SQL
Description: Guide on how to patch Workflow Manager
Scenario You need to patch Workflow Manager to CU2/Refresh.Solution Download Workflow Manager CU2 - http//support.microsoft.com/kb/2902007 WorkflowManagerClient_x64.msi - Don’t forget this file or you will have lots of fun ) WorkflowManager-KB2902007-x64-EN.exe Download Service Bus CU Pre-Requisite - http//support.microsoft.com/kb/2799752 ServiceBus-KB2799752-x64-EN.exe Install the Service Bus CU ServiceBus-KB2799752-x64-EN.exe Install the Workflow Manager CU2 WorkflowManagerClient_x64.msi WorkflowManager-KB2902007-x64-EN.exe Fix SQL Permissions After Patching you will notice the following errors in the Event Viewer Failed SQL command after 1 tries with error '229'. Exception System.Data.SqlClient.SqlException (0x80131904) The EXECUTE permission was denied on the object 'InsertTrackingAndStatus', database 'PS2013_STG_Services_WFInstanceManagementDB', schema 'dbo'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.CompleteAsyncExecuteReader() at System.Data.SqlClient.SqlCommand.EndExecuteNonQueryInternal(IAsyncResult asyncResult) at System.Data.SqlClient.SqlCommand.EndExecuteNonQuery(IAsyncResult asyncResult) at Microsoft.Workflow.Management.ExecuteNonQueryAsyncResult.OnEndExecuteSql(IAsyncResult result) at Microsoft.Workflow.Management.ExecuteSqlAsyncResult.EndAsyncResult(IAsyncResult result) at Microsoft.Workflow.Common.BackoffRetryAsyncResult.IsolateWithRetry(IAsyncResult result) at Microsoft.Workflow.Common.AsyncResult.AsyncCompletionWrapperCallback(IAsyncResult result) ClientConnectionId176fd008-644c-43e5-bd5b-cf383611170e Command Details SQL Text InsertTrackingAndStatus SQL Parameters > @StatusRecords = Microsoft.Workflow.Management.SqlDataAccessProvider+InstanceStatusValuesCollection > @MetadataWithInstanceId = > @Variables = Microsoft.Workflow.Management.SqlDataAccessProvider+VariablesCollection > @TrackingRecords = > @StatusHistoryRecords = > @DebugTraceRecords = > @RollingStatusHistoryWindowSize = 1000 > @RollingDebugTraceWindowSize = 5000 Failed SQL command after 1 tries with error '229'. Exception System.Data.SqlClient.SqlException (0x80131904) The EXECUTE permission was denied on the object 'GetInProgressScopeSnapshots', database 'PS2013_STG_Services_WFResourceManagementDB', schema 'dbo'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.CompleteAsyncExecuteReader() at System.Data.SqlClient.SqlCommand.InternalEndExecuteReader(IAsyncResult asyncResult, String endMethod) at System.Data.SqlClient.SqlCommand.EndExecuteReaderInternal(IAsyncResult asyncResult) at System.Data.SqlClient.SqlCommand.EndExecuteReader(IAsyncResult asyncResult) at Microsoft.Workflow.Management.ExecuteReaderAsyncResult.OnEndExecuteSql(IAsyncResult result) at Microsoft.Workflow.Management.ExecuteSqlAsyncResult.EndAsyncResult(IAsyncResult result) at Microsoft.Workflow.Common.BackoffRetryAsyncResult.IsolateWithRetry(IAsyncResult result) at Microsoft.Workflow.Common.AsyncResult.AsyncCompletionWrapperCallback(IAsyncResult result) ClientConnectionId09bfa67f-c511-4b2f-8612-f5ad28197157 Command Details SQL Text GetInprogressScopeSnapshots SQL Parameters > @BatchSize = 20 To resolve this, execute the following SQL Query on WF_InstanceManagement_DB and WF_ResourceManagement_DB As per MSFT instructions http//social.msdn.microsoft.com/Forums/azure/en-US/054d2a58-8847-4a6a-b1ab-05a79f49fe65/workflow-manager-cumulative-update-february-error?forum=wflmgr IF EXISTS (SELECT * FROM sys.database_principals WHERE name = N'WFServiceOperators' AND type = 'R') BEGIN -- Grant all permissions of stored procedures and tables DECLARE @ObjectName sysname, @ObjectType char(20), @Cmd varchar(300) DECLARE ObjectCursor CURSOR LOCAL FAST_FORWARD FOR SELECT name, type FROM sys.objects UNION SELECT name, 'WFUDT' FROM sys.types WHERE is_user_defined = 1 OPEN ObjectCursor FETCH ObjectCursor INTO @ObjectName, @ObjectType WHILE (@@fetch_status <> -1) BEGIN SET @Cmd = CASE @ObjectType WHEN 'P' THEN N'GRANT EXECUTE ON [' + @ObjectName + N'] TO [WFServiceOperators]' WHEN 'WFUDT' THEN N'GRANT CONTROL, REFERENCES ON TYPE[' + @ObjectName + N'] TO [WFServiceOperators]' ELSE '' END IF @Cmd <> '' BEGIN EXEC(@Cmd) END FETCH ObjectCursor INTO @ObjectName, @ObjectType END CLOSE ObjectCursor DEALLOCATE ObjectCursor END GO




Posted on:
Categories: PowerShell;SharePoint
Description: Script for finding all the instances of SharePoint 2013 Workflows
Scenario SharePoint 2013 Workflow Manager is in a broken state. You must find all of the instances of SharePoint 2013 Workflows in order to gauge the impact of the problem.Solution Knowing that Workflow Manager is in a broken state, we won't be able to use its API to find all the workflows. From experience, I know that SharePoint 2010 Workflows are stored in the site in a library called "Workflows". At this point, I went to my DEV environment and created a 2013 workflow and started looking around for it. Luckily, the 2013 workflows work the same way and I didn’t have to open up to code to find them. The following script will return all sites which contain a SharePoint 2013 Workflow. The results will be output in a csv format with | as the delimiter.#----------------------------------------------------------------------------- # Name Get-SP2013Workflows.ps1 # Description This script will find SharePoint 2013 Workflows # # Usage Run the function # By Ivan Josipovic, Softlanding.ca #----------------------------------------------------------------------------- Function Get-SP2013Workflows() foreach ($web in get-spsite -limit all | get-spweb -limit all ) if ($web.folders["wfsvc"] -ne $null) foreach ($wfFolder in $web.folders["wfsvc"].subfolders | ? $_.name -ne "forms" ) $xaml = $wfFolder.files | ? $_.name.tolower().EndsWith(".xaml"); $xamlStream = new-object System.IO.StreamReader($($xaml.OpenBinaryStream())); $xml = [xml]$xamlStream.ReadToEnd(); Write-Host "$($web.url)|$($xml.Activity.Class.ToString().TrimEnd(".MTW"))"; #Get-SP2013Workflows();




Posted on:
Categories: PowerShell;SharePoint
Description: Script for Automated Patching of AppFabric
Scenario Microsoft has recently changed their guidance for AppFabric in regards to patching. Initially they were planning on patching AppFarbic using the standard SharePoint Cumulative Updates. They have recently changed this guidance to allow us to patch AppFabric separately. Noted Here http//blogs.technet.com/b/speschka/archive/2014/02/06/update-to-guidance-for-patching-appfabric-on-sharepoint-2013-distributed-cache-servers.aspx At the time of this blog the latest AppFabric Cumulative update is CU5 http//support.microsoft.com/kb/2932678Solution We have created a script which will update AppFabric on a specific server. The following script will Stop the Distributed Cache Service on the current server. Look for a Cumulative Update executable in the same directory as the script and execute it. The script will look for a executable with a name that matches AppFabric1.1*.exe. Update the AppFabric config to enable Garbage Collection. Start the Distributed Cache Service on the current server. #----------------------------------------------------------------------------- # Name Update-AppFabric.ps1 # Description This script will patch and enable Garbage Collection in AppFabric # Usage Run script, make sure that the AppFabric CU is in the same directory # as the script and that there are no other exes in the same directory. # Do not rename the AppFabric Cumulative Update! # By Ivan Josipovic, Softlanding.ca #----------------------------------------------------------------------------- $patchfile = Get-ChildItem | where $_.Name.ToLower().StartsWith("appfabric1.1") -and $_.Extension -eq ".exe"; if($patchfile -eq $null) Write-Host "Unable to retrieve the file. Exiting Script" -ForegroundColor Red; Return; Write-Host "Stopping AppFabric" -ForegroundColor Magenta; Stop-SPDistributedCacheServiceInstance -Graceful Write-Host "Stopping AppFabric complete" -ForegroundColor green; Write-Host "Patching now keep this PowerShell window open" -ForegroundColor Magenta; Start-Process -FilePath $patchfile.FullName -ArgumentList "/passive" -Wait; Write-Host "Patch installation complete" -foregroundcolor green; Write-Host "Updating AppFabric config" -ForegroundColor Magenta; $location = "C\Program Files\AppFabric 1.1 for Windows Server\DistributedCacheService.exe.config" $xml = [xml](get-content $location); if ($xml.configuration.appSettings.add -eq $null) $appsettings = $xml.CreateElement("appSettings"); $add = $xml.CreateElement("add"); $key = $xml.CreateAttribute("key"); $key.InnerText = "backgroundGC"; $add.Attributes.Append($key) | out-null; $value = $xml.CreateAttribute("value"); $value.InnerText = "true"; $add.Attributes.Append($value) | out-null; $appsettings.AppendChild($add) | out-null; $configsections = $xml.configuration.configSections; $xml.configuration.InsertAfter($appsettings,$configsections) | out-null; $xml.save($location); Write-Host "Updating AppFabric config complete" -ForegroundColor green; Write-Host "Starting AppFabric" -ForegroundColor Magenta; $instance = Get-SPServiceInstance | ? $_.TypeName -eq "Distributed Cache" -and $_.Server.Name -eq $envcomputername; $instance.Provision(); Write-Host "Starting AppFabric complete" -ForegroundColor Magenta;




Posted on:
Categories: SharePoint;PowerShell
Description: You open a Site using SharePoint Designer, when you click on "List and Libraries", no Lists are displayed.
Scenario You open a Site using SharePoint Designer, when you click on "List and Libraries", no Lists are displayed. Solution ULS Logs shows the following Stack Trace Original error System.ArgumentException Feature '32fc3d44-5bbb-4ea5-84f7-3c4f277fe138' for list template '10000' is not installed in this farm. The operation could not be completed. at Microsoft.SharePoint.SPFeatureManager.<>c__DisplayClass19.<GetFeatureRootAndListSchemaPaths>b__18() at Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken userToken, Boolean bResetContext, WaitCallback code, Object param) at Microsoft.SharePoint.SPFeatureManager.GetFeatureRootAndListSchemaPaths(Byte[]& userToken, Guid& tranLockerId, Int32 nZone, Guid databaseid, Guid siteid, Guid webid, Guid featid, Int32 ltid, String& sPathToFeatureRoot, String& sPathToSchemaXml) at Microsoft.SharePoint.Library.SPRequestInternalClass.GetListContentTypes(String bstrUrl, String bstrListName, ISPDataCallback pXMLCallback) at Microsoft.SharePoint.Library.SPRequest.GetListContentTypes(String bstrUrl, String bstrListName, ISPDataCallback pXMLCallback) at Microsoft.SharePoint.SPContentTypeCollection.FetchCollection(IList`1 exceptions) at Microsoft.SharePoint.SPList.get_DefaultContentTypeOrder() at Microsoft.SharePoint.SPFolder.get_ContentTypeOrder() at Microsoft.SharePoint.SPFolder.get_ContentTypeOrder_Client() at Microsoft.SharePoint.ServerStub.SPFolderServerStub.WriteOnePropertyValueAsJson(JsonWriter writer, Object target, ClientQueryProperty field, ProxyContext proxyContext) at Microsoft.SharePoint.Client.ServerStub.WriteAsJson(JsonWriter writer, Object obj, ClientObjectQuery objectQuery, ProxyContext proxyContext) at Microsoft.SharePoint.Client.ServerStub.WriteAsJsonWithMonitoredScope(JsonWriter writer, Object value, ClientObjectQuery objectQuery, ProxyContext proxyContext) Based on this, it looks like we have a List which was deployed by a feature, and that feature no longer exists on the farm. Let's find the list and delete it. Alternatively, if you can find the wsp, you can re-reploy it. I used the following script to find and delete the list $web = get-spweb http//site; $list = $web.Lists | ? $_.TemplateFeatureId -eq "32fc3d44-5bbb-4ea5-84f7-3c4f277fe138"; $list.delete(); SharePoint Designer will now display all the lists.




Posted on:
Categories: PowerShell;SharePoint
Description:
Scenario You deploy SharePoint 2013, a few months later you realize that the c\ drive is running out space. After some investigation, you find that most of the space is take by a specific folder "C\Program Files\Microsoft Office Servers\15.0\Data". This is the location of the SharePoint Search Index. The recommended practice is to keep the Index on separate disk. Solution To move the Search Index, we are going to use PowerShell. To move the index we will need to use about 13 separate PowerShell Commandlets. Luckily, we have simplified it for you. #----------------------------------------------------------------------------- # Name Move-SPEnterpriseSearchIndex.ps1 # Description This script will move the SharePoint 2013 Search Index # # Usage Run the function with the 3 required Parameters # By Ivan Josipovic, Softlanding.ca #----------------------------------------------------------------------------- function Move-SPEnterpriseSearchIndex($SearchServiceName,$Server,$IndexLocation) Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0; #Gets the Search Service Application $SSA = Get-SPServiceApplication -Name $SearchServiceName; if (!$?)throw "Cant find a Search Service Application `"$SearchServiceName`""; #Gets the Search Service Instance on the Specified Server $Instance = Get-SPEnterpriseSearchServiceInstance -Identity $Server; if (!$?)throw "Cant find a Search Service Instance on Server `"$Server`""; #Gets the current Search Topology $Current = Get-SPEnterpriseSearchTopology -SearchApplication $SSA -Active; if (!$?)throw "There is no Active Topology, you can try removing the `"-Active`" from the line above in the script"; #Creates a Copy of the current Search Topology $Clone = New-SPEnterpriseSearchTopology -Clone -SearchApplication $SSA -SearchTopology $Current; #Adds a new Index Component with the new Index Location New-SPEnterpriseSearchIndexComponent -SearchTopology $Clone -IndexPartition 0 -SearchServiceInstance $Instance -RootDirectory $IndexLocation | Out-Null; if (!$?)throw "Make sure that Index Location `"$IndexLocation`" exists on Server `"$Server`""; #Sets our new Search Topology as Active Set-SPEnterpriseSearchTopology -Identity $Clone; #Removes the old Search Topology Remove-SPEnterpriseSearchTopology -Identity $Current -Confirm$false; #Now we need to remove the extra Index Component #Gets the Search Topology $Current = Get-SPEnterpriseSearchTopology -SearchApplication $SSA -Active; #Creates a copy of the current Search Topology $Clone=New-SPEnterpriseSearchTopology -Clone -SearchApplication $SSA -SearchTopology $Current; #Removes the old Index Component from the Search Topology Get-SPEnterpriseSearchComponent -SearchTopology $Clone | ? ($_.GetType().Name -eq "IndexComponent") -and ($_.ServerName -eq $($Instance.Server.Address)) -and ($_.RootDirectory -ne $IndexLocation) | Remove-SPEnterpriseSearchComponent -SearchTopology $Clone -Confirm$false; #Sets our new Search Topology as Active Set-SPEnterpriseSearchTopology -Identity $Clone; #Removes the old Search Topology Remove-SPEnterpriseSearchTopology -Identity $Current -Confirm$False; Write-Host "The Index has been moved to $IndexLocation on $Server" Write-Host "This will not remove the data from the old index location. You will have to do that manually )" #Move-SPEnterpriseSearchIndex -SearchServiceName "Search Service Application" -Server "SP2013-WFE" -IndexLocation "C\Index"




Posted on:
Categories: SharePoint;PowerShell
Description: Scriped workaround for the Claims Conversion bug in the April 2014 Cumulative Update
Scenario You are running SharePoint 2013 with the April 2014 Cumulative Update and you need to upgrade a Web Application to Claims Authentication. Unfortunately, the Convert-SPWebApplication commandlet is broken by the April Cumulative Update. The only provided workaround is to use Move-SPUser or stsadm -o migrateuser. More info on Trevor Swears blog http//thesharepointfarm.com/2014/05/sharepoint-2013-april-2014-cu-claims-conversion-bug Please note that both of these commands will migrate the user across the whole farm. Solution In the meantime, use the following script to migrate a Web Application to Claims. Please note that this script will migrate the user to Claims on every Web Application on the Farm. This is a limitation of the Move-SPUser commandlet. #----------------------------------------------------------------------------- # Name Convert-SPWebApplicationToClaims.ps1 # Description This script will migrate a Web Application to Claims Authentication # # Usage Run the function with a WebApplication URL as the parameter # Warning The users will me migrated on all Web Applications on the farm!! # By Ivan Josipovic, Softlanding.ca #----------------------------------------------------------------------------- Function Convert-SPWebApplicationToClaims ($WebApp) foreach ($Site in Get-SPSite -limit all -WebApplication $WebApp) foreach($user in $Site.RootWeb.SiteUsers | ? !$_.UserLogin.StartsWith("i0#.w|") -and !$_.UserLogin.StartsWith("c0!.s|") -and !$_.UserLogin.StartsWith("c0(.s|")) Write-Host $user.UserLogin if($user.UserLogin -eq "SHAREPOINT\system")continue; if($user.IsDomainGroup) switch ($user.UserLogin.ToLower()) "nt authority\all authenticated users" Move-SPUser -Identity $user -NewAlias "c0(.s|true" -IgnoreSID -Confirm$false -EA 0; "nt authority\authenticated users" Move-SPUser -Identity $user -NewAlias "c0!.s|windows" -IgnoreSID -Confirm$false -EA 0; default Move-SPUser -Identity $user -NewAlias "c0+.w|$($user.Sid.ToLower())" -IgnoreSID -Confirm$false -EA 0; else Move-SPUser -Identity $user -NewAlias "i0#.w|$($user.UserLogin)" -IgnoreSID -Confirm$false -EA 0; #Convert-SPWebApplicationToClaim -WebApp http//site.client.com




Posted on:
Categories: SharePoint;PowerShell
Description: Scripted approach to enabling large file upload on SharePoint
Scenario You need to increase the maximum file size of files that can be uploaded to SharePoint. By default, SharePoint allows a maximum file size of 250MB. Solution SharePoint required 3 changes in order to allow larger files to be uploaded WebApplication.MaximumFileSize, SharePoint setting which specifies how large of a file SharePoint will accept in MB. The maximum is 2047MB. Web.config executionTimeout, IIS setting which specifies how long in seconds that a single request can execute. Web.config maxRequestLength, IIS setting which specifies how large of a buffer in KB that IIS allows for a single request. This following script will set all the values mentioned above. Furthermore, the Web.config changes are applied through SharePoint using the SPWebConfigModification Object which will apply the Web.config modifications in a supported manner. #----------------------------------------------------------------------------- # Name Enable-SPLargeFileUpload.ps1 # Description This script will enable large file upload on a Web Application # # Usage Run the function with the required parameters # By Ivan Josipovic, Softlanding.ca #----------------------------------------------------------------------------- Function Enable-SPLargeFileUpload ($WebApplication, $FileSize, $ExecutionTimeout, $MaxRequestLength) $webapp = Get-SPWebApplication $webApplication Function CreateModification ($path, $name, $owner, $value) $configMod1 = New-Object "Microsoft.SharePoint.Administration.SPWebConfigModification"; $configMod1.Path = $path; $configMod1.Name = $name; $configMod1.Sequence = 0; $configMod1.Type = 1; $configMod1.Owner = $owner; $configMod1.Value = $value; $webapp.WebConfigModifications.Add($configMod1); CreateModification -Path "/configuration/system.web/httpRuntime" -Name "executionTimeout" -Owner "LargeFileUpload" -Value $ExecutionTimeout; CreateModification -Path "/configuration/system.web/httpRuntime" -Name "maxRequestLength" -Owner "LargeFileUpload" -Value $MaxRequestLength; $webapp.MaximumFileSize = $FileSize; $webapp.Update(); $webapp.Parent.ApplyWebConfigModifications(); #Enable-SPLargeFileUpload -WebApplication http//site.client.com -FileSize 2047 -ExecutionTimeout 18000 -MaxRequestLength 2097152;




Posted on:
Categories: Business;SharePoint
Description: It is easy to lose sense of creativity when we start dealing with technologies and specific features of those technologies. But losing a sense of creativity means creating the same solutions again and again without innovation. The way I see it, creativity should be applied in two ways.
​Let's be honest, I'm not a painter, musician, or sculptor. I'm a consultant in the field of technology. If I were to have had a conversation with the future me 15 years ago, I wouldn’t have thought creativity would be such an integral part of my IT career. It is easy to lose sense of creativity when we start dealing with technologies and specific features of those technologies. But losing a sense of creativity means creating the same solutions again and again without innovation. The way I see it, creativity should be applied in two ways. Creativity In How You Create Your SolutionsWith the technology landscape constantly in flux, we have to ensure we are adjusting our methods of creating and delivering solutions. One of the areas I like to focus on is trying to get requirements from users. Simply asking questions, sometimes does not do the trick, whether it be due to the complexity of the process and/or the user just not knowing what is possible when it comes to streamlining their processes. Getting creative in the way you get information from users can be an art form in itself. Recently I have been looking at "Innovation Games", a set of games that you can play with users, to get different kinds of information from them. These games help in things like, prioritizing features, identifying hidden needs/requirements, and realizing steps that need to be taken to reach your goals. However if you are not willing to take the leap of faith by getting up in front of a room and telling your stakeholders that we are about to play some games, there are other creative steps you can take as well. Get your stakeholders together in a room, and give each one a blank page. Now tell them to draw what their perception of a useful and usable intranet looks like. A simple exercise like this can help bring out requirements that may have taken multiple sessions to discover. Creativity In The Solutions You CreateOf course, in dealing with SharePoint as our delivery platform, we come across the scenario where there are usually multiple ways of addressing the same business requirements. That’s where creativity comes into play when developing a solution. When using creativity to architect a potential solution, there are some questions I ask myself Am I adhering to best practices? Will this give the user what they need? Will it be a positive user experience? Answering these questions help me validate my solution, and help me explore new ways of doing things that may be quicker, and have a better experience for end users. At the end of the day I not only want to create something that fulfills requirements, I also want to innovate and provide a solution that thinks outside of the box. The importance of creativity is developing a unique solution to each and every problem.