Thursday, December 5, 2013

Fix a Secure Store service or any SharePoint service stuck on starting or stopping

change the "Server Name" in the script.  To stop change Provision() to UnProvision()

one thing to note is that if the status is provisioning, then you'll most likely need to Provision() then UnProvision().

Also all you need to do is get the service instance for other services by the type or name. 

--------------------------------------------------------------
add-pssnapin MIcrosoft.SharePoint.Powershell

Function MatchComputerName($computersList, $computerName)
{
                If ($computersList -like "*$computerName*") { Return $true; }
    foreach ($v in $computersList) {
      If ($v.Contains("*") -or $v.Contains("#")) {
            # wildcard processing
            foreach ($item in -split $v) {
                $item = $item -replace "#", "[\d]"
                $item = $item -replace "\*", "[\S]*"
                if ($computerName -match $item) {return $true;}
            }
        }
    }
}

           $secureStoreServiceInstances = Get-SPServiceInstance | ? {$_.GetType().Equals([Microsoft.Office.SecureStoreService.Server.SecureStoreServiceInstance])}
            $secureStoreServiceInstance = $secureStoreServiceInstances | ? {MatchComputerName $_.Server.Address "Server Name"}
           
            Write-HOst $secureStoreServiceInstance.Status

            $secureStoreServiceInstance.Provision()

Monday, November 25, 2013

Office Web App for SharePoint 2013 Cheat sheet

Run on the Office Web App server (can not have sharepoint installed, it is stand alone now).
---------------------------------------------------
1.Download KB2592525  to folder on your system
2.Create a new folder called “files”
3.Extract the MSU: expand Windows6.1-KB2592525-x64.msu –F:* .\files
4.go to files
5.Install using Pkgmgr: pkgmgr /ip /m:Windows6.1-KB2592525-x64.cab


Import-Module ServerManager

Add-WindowsFeature Web-Server,Web-WebServer,Web-Common-Http,Web-Static-Content,Web-App-Dev,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Includes,Web-Security,Web-Windows-Auth,Web-Filtering,Web-Stat-Compression,Web-Dyn-Compression,Web-Mgmt-Console,Ink-Handwriting,IH-Ink-Support

New-OfficeWebAppsFarm –InternalURL "http://url" -AllowHttp -EditingEnabled

Set-OfficeWebAppsFarm -LogLocation "D:\ULSLogs" -CacheLocation "D:\Cache" -RenderingLocalCacheLocation "D:\RenderCache"



On the sharepoint server, open powershell (if ISE, will need Add-pssnapin Microsoft.SharePoint.Powershell)
--------------------------------------
New-SPWOPIBinding -ServerName <WacServerName> -AllowHTTP
$WOPIzone = Get-SPWOPIZone
if($WOPIzone -neq "internal-http")
{
 Set-SPWOPIZone –zone "internal-http"
}

$AllowOAuth = (Get-SPSecurityTokenServiceConfig).AllowOAuthOverHttp
if($AllowOAuth -eq $false)
{
    $config = (Get-SPSecurityTokenServiceConfig)
    $config.AllowOAuthOverHttp = $true
    $config.Update()
}
(Get-SPSecurityTokenServiceConfig).AllowOAuthOverHttp

 

Thursday, October 31, 2013

Powershell to list all webs with UI version 3 for sharepoint 2013 upgrade purpose


Add-Pssnapin Microsoft.SharePoint.Powershell
 
$s | Get-SPSite -limit all | ForEach-Object {$site =$_;

$site | Get-SPWeb -limit all | ForEach-Object {

if($_.UIVersion -eq 3)

{

write-host "UI version : " $_.UIVersion  $_.Url

}

}}

SharePoint 2010 and Project Web app error provisioning

Had a strange error the other day with provisioning a Project Web Application (PWA).  

The errors didn't really say much except these three event log items.  Errors below. 

To resolve I have to create the PWA site on another environment and then do a back up and restore to a site collection in the environment that was breaking.   then run the provisioning on central admin.  Everything works great after. 


- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">

- <System>

<Provider Name="Microsoft-SharePoint Products-Project Server" Guid="{B2178104-...}" />

<EventID>7381</EventID>

<Version>14</Version>

<Level>2</Level>

<Task>20</Task>

<Opcode>0</Opcode>

<Keywords>0x4000000000000000</Keywords>

<TimeCreated SystemTime="2013-10-23T21:08:38.396865600Z" />

<EventRecordID>251151</EventRecordID>

<Correlation ActivityID="{DE39B42B...}" />

<Execution ProcessID="7972" ThreadID="4988" />

<Channel>Application</Channel>

<Computer>xxx.domain.com</Computer>

<Security UserID="S-1-5..." />

</System>

<EventData />

</Event>
-----------------------------------------------------------------
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">

- <System>

<Provider Name="Microsoft-SharePoint Products-Project Server" Guid="{B2178104..}" />

<EventID>6966</EventID>

<Version>14</Version>

<Level>2</Level>

<Task>20</Task>

<Opcode>0</Opcode>

<Keywords>0x4000000000000000</Keywords>

<TimeCreated SystemTime="2013-10-23T21:08:39.100031100Z" />

<EventRecordID>251152</EventRecordID>

<Correlation ActivityID="{DE39B42B...}" />

<Execution ProcessID="7972" ThreadID="4988" />

<Channel>Application</Channel>

<Computer>xxx.domain.com</Computer>

<Security UserID="S-1-5..." />

</System>

- <EventData>

<Data Name="string0">PW</Data>

<Data Name="string1">Microsoft.Office.Project.Server.Administration.ProvisionException: Post provisioning setup failed. at Microsoft.Office.Project.Server.Administration.PsiServiceApplication.CreateSite(ProjectProvisionSettings provset)</Data>

</EventData>

</Event>
-------------------------------------------------------------------------------------------------
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">

- <System>

<Provider Name="Microsoft-SharePoint Products-Project Server" Guid="{B2178104...}" />

<EventID>6971</EventID>

<Version>14</Version>

<Level>2</Level>

<Task>20</Task>

<Opcode>0</Opcode>

<Keywords>0x4000000000000000</Keywords>

<TimeCreated SystemTime="2013-10-25T18:11:34.919153600Z" />

<EventRecordID>252921</EventRecordID>

<Correlation ActivityID="{27BA856F...}" />

<Execution ProcessID="9040" ThreadID="2700" />

<Channel>Application</Channel>

<Computer>xxx.domain.com</Computer>

<Security UserID="S-1-5..." />

</System>

- <EventData>

<Data Name="string0">/PWA</Data>

<Data Name="string1">Microsoft.Office.Project.Server.Administration.ProvisionException: Post provisioning setup failed. at Microsoft.Office.Project.Server.Administration.PsiServiceApplication.CreateSite(ProjectProvisionSettings provset)</Data>

</EventData>

</Event>

Thursday, October 17, 2013

Simple powershell to set key/value pair in the web application properties

-Don't forget to add the snap in if not using the sharepoint ps console.

function SetPropertyBag ($webAppUrl, $key, $value) {

    $spwebApp=Get-SPWebApplication -Identity $webAppUrl
    Write $spwebApp

    if($spwebApp.AllProperties.ContainsKey($key) -eq $False)
    {
        $spwebApp.AllProperties.Add($key,$value);      
    }
    else
    {$spwebApp.AllProperties[$key]=$value; }

    Write-Host -foregroundcolor Green "value set in "  $key  " = "  $spwebApp.AllProperties[$key]  

    }

$webAppUrl= Read-Host 'Enter the web application url';

$keystring= Read-Host 'Enter the key string';
$valuestring= Read-Host 'Enter the value string';
SetPropertyBag $webAppUrl $keystring $valuestring;

Wednesday, September 4, 2013

TFS 2012 web access 'b' is null or not an object error on the product backlog board

If the user clicks on the board tab on the product backlog,  the first time the board renders without any issues.

Check to see if you are using IE8 or below for TFS 2012 web access.   IE8 is not supported. 

Tuesday, August 20, 2013

SharePoint 2013 migration issue with the SP.UI.ModalDialog error in javascript of CEWP

When there are javascript added to the Content Editor Web Part in SharePoint 2010, to open the dialog the code below is how you would do it but it breaks when you upgrade to 2013.

This works best if you add the new Script Webpart to the page and copy and paste all the scripts from the CEWP and leave the html as is.  

function openFormDialog(formtitle, formurl)
{
 var options = {
             url: formurl,
             tite: formtitle
         };

         SP.UI.ModalDialog.showModalDialog(options);
}

breaks in 2013

to fix the issue change the call to

function openFormDialog(formtitle, formurl)
{
 var options = {
             url: formurl + "?IsDlg=1",
             tite: formtitle
         };

SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}

SharePoint 2013 migration issue with javascript only content editor webpart breaking the webpart page and closes the browser

Here is a simple script to output the contents of the CEWP to be ran on the 2010 environment to investigate the potential issues you might encounter for javascript only CEWP when it gets migrated to 2013.


$siteUrl = "http://localhost"
$site = Get-SPSite $siteUrl
$cewpCount = 0
$cewps = New-Object Hashtable
$site.AllWebs | % {

     $pageUrl = $_.RootFolder.WelcomePage;
     $pageUrlFull = ($_.Url + "/" + $pageUrl);
     if($pageUrl.Length -gt 0 )
     {
       $parts = $_.GetWebPartCollection($pageUrl, 2)
         $parts | ? { $_.WebBrowsableObject.ToString() -eq "Microsoft.SharePoint.WebPartPages.ContentEditorWebPart" } | % {
         $ce = [Microsoft.SharePoint.WebPartPages.ContentEditorWebPart]$_
         Write-Host "Found on Page URL: " $pageUrlFull $_.StorageKey $ce.Title -ForegroundColor Green
          Write-Host $ce.Content.InnerText
          $cewpCount += 1;
          $cewps.Add($_.StorageKey, $pageUrlFull); }
      }    
    }
          
Write-Host "Found" $cewpCount "CEWPs" -ForegroundColor Green




Friday, August 16, 2013

SharePoint CAML query to get Todays events in calendar list

<Query>
    <OrderBy>
<FieldRef Name="EventDate"/>
</OrderBy>
<Where>
<And>
<DateRangesOverlap>
<FieldRef Name="EventDate"/>
<FieldRef Name="EndDate"/>
<FieldRef Name="RecurrenceID"/>
<Value Type="DateTime" IncludeTimeValue="False">
       <Today/>
                </Value>
            </DateRangesOverlap>
            <Lt>
                <FieldRef Name="EventDate"/>
                <Value Type="DateTime">
                   <Today/>
                </Value>
            </Lt>
        </And>
    </Where>
    <QueryOptions>
        <IncludeMandatoryColumns>false</IncludeMandatoryColumns>
        <ViewAttributes Scope="Recursive"/>
        <RecurrencePatternXMLVersion>v3</RecurrencePatternXMLVersion>
        <ExpandRecurrence>true</ExpandRecurrence>
        <RecurrenceOrderBy>true</RecurrenceOrderBy>
        <ViewAttributes Scope="RecursiveAll"/>
        <CalendarDate>
        <Today/>
        </CalendarDate>
    </QueryOptions>
</Query>

Wednesday, August 14, 2013

PowerShell Script to mount and Upgrade all site collections in a web application

Sometimes, the visual upgrade gets a bit buggy so use this instead and have no issues. Make sure you export all the solutions from the old central admin and add them and deploy them to the new Sharepoint 2013 environment. This way you will not have issues with the webparts and pages.

Add-PSSnapin Microsoft.SharePoint.Powershell
Mount-SPContentDatabase CSIHQ_Content -WebApplication http://server.com -AssignNewDatabaseId -DatabaseServer Dbservername
$SPwebApp = Get-SPWebApplication "http://server.com"
foreach ($SPsite in $SPwebApp.Sites) { Upgrade-SPSite $SPsite.Url -VersionUPGrade write-host $SPsite.url }

Friday, August 9, 2013

TFS 2012 and Visual studio 2010 CodedUI Project error: The given key was not present in the dictionary

Encountered a strange error today.  When i open a UIMap from an old project the error says "The given key was not present in the dictionary".   After doing some research, everyone suggested removing the files in the local directory but that did not work for me.

So i removed and AssemblyInfo.cs and then undid checkout/pending changes.

The IDE gives an file modification detected warning and askes to reload.
Click Reload.

The UIMap opens without an issue.

Friday, July 19, 2013

Microsoft Test Manager 2012: Create new Environment errors on validation

When the user tries to create a new environment and the validation times out.  Please check to see if the Team foundation server background service is running.

The Environment validation gets queued in the database and the Background service updates that information once it has ran.   So the table to check in the tfs_defaultCollection database is called dbo.LabOperation which is the queue and holds the status of the items.

select * from dbo.LabOperation

Hth.

Thursday, June 27, 2013

Powershell to transfer a large file

import-module bitstransfer

$Job = Start-BitsTransfer -Source c:\largefile.bak `
       -Destination Z:\ -Asynchronous
while (($Job.JobState -eq "Transferring") -or ($Job.JobState -eq "Connecting")) `
       { sleep 5;} # Poll for status, sleep for 5 seconds, or perform an action.
Switch($Job.JobState)
{
 "Transferred" {Complete-BitsTransfer -BitsJob $Job}
 "Error" {$Job | Format-List } # List the errors.
 default {"Other action"} #  Perform corrective action.
}

Powershell to export all farm solutions

Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

## setup our output directory
$dirName = "d:\Exported Solutions"

Write-Host Exporting solutions to $dirName
foreach ($solution in Get-SPSolution)
{
    $id = $Solution.SolutionID
    $title = $Solution.Name
    $filename = $Solution.SolutionFile.Name

    Write-Host "Exporting ‘$title’ to …\$filename" -nonewline
    try {
        $solution.SolutionFile.SaveAs("$dirName\$filename")
        Write-Host " – done" -foreground green
    }
    catch
    {
        Write-Host " – error : $_" -foreground red
    }

}