Skip to content

Welcome to Chaya Digital - questions and solutions are both welcome! Please be as specific as possible when asking a question so that I can answer it accurately and quickly.

Please visit my store!

Three ways to clear InfoPath Caching on Users Local Machine

InfoPath caches local content for faster functionality – this can be very annoying when end users do not get to see your updates.

Here are three ways to clear your InfoPath cache; which you use will likely be based on the end users’ level of technology savvy.

From Run

Start > run > type “Infopath /cache clearall

Delete the Contents of These Folders Manually

C:\Users\ebruce\AppData\Local\Microsoft\InfoPath\FormCache3

C:\Users\ebruce\AppData\Local\Microsoft\InfoPath\FormCache4

In .Bat File Which End Users Can Click to Run

taskkill /im:infopath.exe /f

taskkill /im:iexplore.exe /f

"C:\Program Files (x86)\Microsoft Office\Office14\Infopath.exe" /cache clearall

"C:\Program Files (x86)\Microsoft Office\Office15\Infopath.exe" /cache clearall

taskkill /im:infopath.exe /f

Fix for SharePoint 2013 Error: Unable to Save Items or Open Shared With Popups for List Items

image

Error: The server was unable to save the form at this time. Please try again.

Error: unexpected response data returned from the server.

NOTE: This mostly happens on dev and test servers, as they have less resources and are often on a singe virtual machine.

Solution

  1. Start > Services
  2. Stop and Start the Service “SharePoint Search Host Controller”
  3. Your machine resources should free up and functionality should resume

SharePoint Farm Backup Checks Revisited with XML File Node Traversing

I have this running on sql server and throwing errors if it does not run as well as error checking. I have it running separately from the backup job to make sure it really works.

Not 100% sure why the sql service account could not run the powershell command send-mailmessage though.

I chose to include the whole content of the xml file, but if that is too messy, you have a few options. Note that it includes nodes like the backup method and start and endtime, as well as error counts.

If you only want to include certain parts of the backup XML file

You can pull it out like this:

[xml]$xml = get-content \\server\filesharepath\farm*\*.xml ;

$spbackupmethod = $xml.spbackuprestorehistory.sphistoryobject.spbackupmethod

$spbackupmethod

image

Or iterate through the xml nodes:

$xml.spbackuprestorehistory.sphistoryobject.spbackupmethod.childnodes | %{ $_.localname $_.innerxml}

Or if you just want that set of xml try:

%{$_.outerxml}

The Script

$ErrorActionPreference = “Stop”
$emailserver = “sqlserver.mydomain.com”
#change to this for send-mailmessage
#$emailserver = “mail.mydomain.com”
$emailfrom = “sqlserver@mydomain.com”
$erroremailfrom = “alerts@mydomain.com”
$emailto = “ebruce@mydomain.com”
$checkpath = “\\backupserver\backupshare\farm*\*.xml”

if (get-childitem $checkpath)
{
###################success
$emailbody =  (get-content $checkpath | out-string)
$emailsubject = “Backup Check Sql – SharePoint Backup SQL Job”
#does not work in sql server 2008 job – works in task scheduler or manual
#send-mailmessage -to $emailto -from $emailfrom -subject $emailsubject -body $emailbody -smtpserver $emailserver

#works in sql server 2008 job – send-mailmessage does not
$smtp = New-Object Net.Mail.SmtpClient($emailserver)
$objMailMessage = New-Object System.Net.Mail.MailMessage
$objMailMessage.From = $emailfrom
$objMailMessage.To.Add($emailto)
$objMailMessage.Subject = $emailsubject
$objMailMessage.Body = $emailbody
$smtp.send($objMailMessage)

}else{
##################failure
$emailsubject = “SharePoint Farm Backup Failed”
$emailbody = “SP Farm Backup Failed – Failure, the backup location is empty, could not find $checkpath. Please check SP Farm backup job in Central Admin and space on server.”
#does not work in sql server 2008 job – works in task scheduler or manual
#send-mailmessage -to $emailto -from $emailfrom -subject $emailsubject -body $emailbody -smtpserver $emailserver
#works in sql server 2008 – send-mailmessage does not
$smtp = New-Object Net.Mail.SmtpClient($emailserver)
$objMailMessage = New-Object System.Net.Mail.MailMessage
$objMailMessage.From = $erroremailfrom
$objMailMessage.To.Add($emailto)
$objMailMessage.Subject = $emailsubject
$objMailMessage.Body = $emailbody
$smtp.send($objMailMessage)

throw “SPFarm Backup Failure, the backup location is empty. Please check SP Farm backup job in Central Admin and space on server.”
}
if (get-childitem $checkpath)
{
###################success
$emailbody =  (get-content $checkpath | out-string)
$emailsubject = “Backup Check Sql6 – SharePoint 2007 – SQL Job”
#send-mailmessage -to $emailto -from $emailfrom -subject $emailsubject -body $emailbody -smtpserver $emailserver

#works in sql server 2008 – send-mailmessage does not
$smtp = New-Object Net.Mail.SmtpClient($emailserver)
$objMailMessage = New-Object System.Net.Mail.MailMessage
$objMailMessage.From = $emailfrom
$objMailMessage.To.Add($emailto)
$objMailMessage.Subject = $emailsubject
$objMailMessage.Body = $emailbody
$smtp.send($objMailMessage)

}else{
##################failure
$emailsubject = “SharePoint Farm Backup Failed”
$emailbody = “SP Farm Backup Failed – Failure, the backup location is empty, could not find $checkpath. Please check SP Farm backup job in Central Admin and space on server.”
#does not work in sql
#send-mailmessage -to $emailto -from $emailfrom -subject $emailsubject -body $emailbody -smtpserver $emailserver
#works in sql server 2008 – send-mailmessage does not
$smtp = New-Object Net.Mail.SmtpClient($emailserver)
$objMailMessage = New-Object System.Net.Mail.MailMessage
$objMailMessage.From = “sql6@mydomain.com”
$objMailMessage.To.Add(“whatsup@mydomain.com”)
$objMailMessage.Subject = “sql6 SP Farm Backup Failed”
$objMailMessage.Body = “SP Farm Backup Failed – Failure, the backup location H:\spbackup\farm\ is empty. Please check SP Farm backup job in Central Admin and space on server.”
$smtp.send($objMailMessage)

throw “SPFarm Backup Failure, the backup location is empty. Please check SP Farm backup job in Central Admin and space on server.”
}

Cheers!

SharePoint Farm Backup Powershell Script With Error Catching, Logging, and Email Notifications

The below works pretty well for me – note that you may want to check for converted quote marks and put in your own paths/etc.

There are a few additional details commented out to assist in tweaking to your own needs.

This can be run as a scheduled tasks as a powershell parameter, providing permissions are set appropriately.

 

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

#set email address to mail report/logs to
$email = "ebruce@mydomain.com"
$erroremail = "alerts@mydomain.com"
#############set parameters
$a = Get-Date -format yyyy-MM-dd-HH-mm
$aa = Get-Date -format "yyyy-MM-dd HH:mm"
$aaa = Get-Date -format yyyy-MM-dd
$reportname = "SPTestFarm_Backups"
$errorlog = "c:\ps_output\$reportname_$aaa.log"
$filepath = "\\backuphost\SharePoint2013\SPTestFarm\" #include trailing slash
$DeleteIfOlderThan = (get-date).addminutes(-1)
#$DeleteIfOlderThan = (get-date).adddays(-8)

Write-host SPFarm Backup starting
"————————————————-"| add-content $errorlog
"[$aa] SPFarm Backup Starting"| add-content $errorlog

try{
    #### uncomment next line to test for error catching
    #$test = ebruce@mydomain.com
    Write-host "Full Backup Job In Progress – test"

    #############  remove directory
    #get item properties list
    #Get-ItemProperty -Path \\backuphost\SPFarm2013_Backup\farm\farm | Format-list -Property * -Force
    #Get-ItemProperty -Path \\backuphost\SPFarm2013_Backup\farm\farm | Get-Member -MemberType property
    #write-host Get subfolders
    #Get-ChildItem -Path $filepath
    write-host Remove Folders Older Than $Deleteifolderthan…
    $aa = Get-Date -format "yyyy-MM-dd HH:mm"
    "[$aa] Removing Folders Older Than $Deleteifolderthan" | add-content $errorlog
    Get-ChildItem -Path $filepath | ForEach-Object{
        if($_.CreationTime -le $deleteifolderthan){
            $string = $filepath+$_.name;
            write-host $_.name,$_.creationtime;
            $aa = Get-Date -format "yyyy-MM-dd HH:mm"
            "[$aa] Removing $string – recursive" | add-content $errorlog
            remove-item -path $string -recurse -force}
        }

    #Make bak directory
    write-host make new directory name…
    $newdirectory = $filepath+’farm_’+$a
    write-host Creating new directory $newdirectory
    $aa = Get-Date -format "yyyy-MM-dd HH:mm"
    "[$aa] Creating new directory $newdirectory" | add-content $errorlog
    new-item -path $newdirectory -itemtype directory

    #backup SP full
    Write-host Running SharePoint: Full Backup to $newdirectory
    $aa = Get-Date -format "yyyy-MM-dd HH:mm"
    "[$aa] Error Detail: Running SharePoint: Full Backup to $newdirectory" | add-content $errorlog
    Backup-SPFarm -BackupMethod Full -Directory $newdirectory

#sp 2007 with spsadm – use –showtree like –whatif for testing

#stsadm -o backup -directory $farmpath -backupmethod Full -percentage 1 -backupthreads 3

    #Differential Backup
    #write-host Differential Backup Job In Progress
    #$path = "\\backuphost\SharePoint2013\farm\"
    #$folder = gci $path | where-object { $_.PSIsContainer} | sort CreationTime -desc | select -f 1
    #$folderpath = $path+$folder
    #write-host Writing Incremental to $folderpath
    #Backup-SPFarm -BackupMethod Differential -Directory $folderpath -WhatIf

}
catch [system.exception]{ #Use most specific catch first – catches any/all errors – base class generic
    #email with
    $aa = Get-Date -format "yyyy-MM-dd HH:mm"
    "[$aa] Error: See Central Administration Backup and Restore Job Status & History details located http://sptest:2013/_admin/BackupStatus.aspx and http://sptest:2013/_admin/BackupHistory.aspx" | add-content $errorlog
    "Error: $_" | Write-host -foregroundcolor red
    $aa = Get-Date -format "yyyy-MM-dd HH:mm"
    "[$aa] Error Detail: $_" | add-content $errorlog
$emailstring = "Backup Completed"
}
finally{
    Write-host SPFarm Backup Ending
    $aa = Get-Date -format "yyyy-MM-dd HH:mm"
    "[$aa] SPFarm Backup Complete"| add-content $errorlog

$emailstring = "Backup Error"

#mail report
#############Email
write-host "Mailing $errorlog to $email"
$smtp = New-Object Net.Mail.SmtpClient("mail.mydomain.com")
    $objMailMessage = New-Object System.Net.Mail.MailMessage
    $objMailMessage.From = "sptest@mydomain.com"
    $objMailMessage.To.Add($email)
    $objMailMessage.Subject = $reportname + "_Report"
    $objMailMessage.Body = $Reportname + "_Report: " + $emailstring

   ##Create  the file attachment for this e-mail message.
   #$data = New-Object Net.Mail.Attachment($filepath)
   $data = New-Object Net.Mail.Attachment($errorlog)
   $objMailMessage.Attachments.Add($data)

$smtp.send($objMailMessage) | Out-Null

write-host "waiting for smtp…"
$data.Dispose();
$objMailMessage.Dispose();

###########Delete created csv file
#write-host "deleting $errorlog"
#TODO: decide if logs should be removed
#Remove-Item "$filepath"
#While(Test-Path $filepath) {Remove-Item $filepath}

SharePoint 2013 And Outlook 2013 Calendar or Library Sync Error

image

Error:

Task ‘SharePoint’ reported error (0x80040102) : ‘Outlook cannot connect to the SharePoint List (YourCalendarHere). The server may not be reachable from your location. Contact the SharePoint site administrator for more information. HTTP 301.’

Issue

You can connect to a calendar in SharePoint or Outlook initially, but get an error on syncing.

Going to File > account settings button > account settings > SharePoint lists and clicking on item may show that you are connected with Read permissions.

NOTE: I recommend deleting the SP connections in Outlook and then reconnecting to Outlook after any of the changes below!!!

Solutions 1: Permissions Need to be Granted

Connection has No access, cannot connect

Make sure the user has access to the calendar – if there is broken inheritance on the site. Make sure the user has site access.

Solution 2: Multiple Computers to Sync

You log in to multiple machines, uncheck the checkbox for “display this list on other computers with the account: myemail@mydomain.com

image

Solution 2: Alternate Access Mapping

Connection has Write Permissions

Check your AAM to make sure it does not have any lingering development settings – for example, we may have a machine name listing, that is later changed to sharepoint.mydomain.com, but the old AAM is left in Central Administration as a backup. I typically like just one https://subdomain.mydomain.com address in AAM

NOTE: It may take a few minutes for this to take effect, or you can try doing an iisreset on all your Web Front End servers

Solution 3: Allow Limited Access Permissions

Connection has Read Permissions

If you like to use broken inheritance and users may not have site access, you may need to disable the site collection feature Limited-access user permission lockdown mode – Note that this is intended to help avoid unintentional access to site content when the user is removed at a higher level. It is on by default in on-prem installations and off by default in O365.

Solution 4: Enable Syncing

Connection has Write Permissions

This may only be needed for documents and specific instances.

Enable at the Website level: Offline Synchronization for External Lists

Manage Robocopy Error Codes When .Bat Is Run In Scheduled Tasks

Task Scheduler does not easily handle error codes for robocopy. To send errors to the task scheduler only when there is an actual failure, use something like the below, where 0 is success and 1 is failure

robocopy_myfolder.bat

REM Robocopy.exe Location | source location (backups on drive) | destination location (SMS drive) | option/switch (/s – copy subdirectories excluding empty ones or /E copy empty folder for structure)
c:\robocopy\robocopy.exe C:\my\file\location\awd \\network-machine\ShareName\My\Copy\Location /E /log:c:\robocopy\robocopy_myfolder.log
if errorlevel 16  echo  ***FATAL ERROR***  & EXIT /b 1
if errorlevel 15  echo FAIL MISM XTRA COPY & EXIT /b 1
if errorlevel 14  echo FAIL MISM XTRA      & EXIT /b 1
if errorlevel 13  echo FAIL MISM      COPY & EXIT /b 1
if errorlevel 12  echo FAIL MISM           & EXIT /b 1
if errorlevel 11  echo FAIL      XTRA COPY & EXIT /b 1
if errorlevel 10  echo FAIL      XTRA      & EXIT /b 1
if errorlevel  9  echo FAIL           COPY & EXIT /b 1
if errorlevel  8  echo FAIL                & EXIT /b 1
if errorlevel  7  echo         MISM XTRA COPY & EXIT /b 0
if errorlevel  6  echo      MISM XTRA      & EXIT /b 0
if errorlevel  5  echo      MISM      COPY & EXIT /b 0
if errorlevel  4  echo      MISM           & EXIT /b 0
if errorlevel  3  echo           XTRA COPY & EXIT /b 0
if errorlevel  2  echo           XTRA      & EXIT /b 0
if errorlevel  1  echo                COPY & EXIT /b 0
if errorlevel  0  echo    –no change–    & EXIT /b 0
:end

Reference

http://support.microsoft.com/kb/954404

http://technet.microsoft.com/en-us/library/cc733145.aspx

http://weblogs.sqlteam.com/robv/archive/2010/02/17/61106.aspx

command line syntax key http://technet.microsoft.com/en-us/library/cc771080.aspx

Scripts to Move File Location of MDF and LDF in Microsoft SQL Server Management Studio

Occasionally, logs or databases may outgrow their original location and need to be moved, or perhaps were never in the proper location to begin with. This often happens when you install SQL Server with defaults, and everything is created on the C: drive.

Here is a quick set of scripts to help move the files for the database and point the database to the new file locations.

–Detach the database

–first
USE master;
GO
— Important! We need to drop the existing connections.
ALTER DATABASE TestMovingMDF SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
EXEC sp_detach_db @dbname = N’TestMovingMDF’;
GO

–Copy the files

–second – copy mdf/ldf to new location

–Reattach .mdf and .ldf files in new location

–second————————————————–
USE master;
EXEC sp_attach_db @dbname = N’TestMovingMDF’,
@filename1 = N’C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\test\TestMovingMDF.mdf’,  –path to .mdf
@filename2 = N’C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\test\TestMovingMDF_log.ldf’;  –path to .ldf
GO

InfoPath cannot build the Visual Basic or C# Code

Adding Visual Basic or C code to a form requires Microsoft Visual Studio Tools for Applications (VSTA). To enable this feature, run Microsoft Office 2010 setup, and change the Microsoft Visual Studio Tools for Applications option under InfoPath to Run from my computer. The Microsoft .NET Framework 2.0 must be installed before installing VSTA.image

Start > add remove programs > right click on Microsoft Office 2010 > change

image

Add or remove features > continue

Expand > Microsoft office > Microsoft infopath > .Net programmability supportimage

Click on Visual studio tools for applications > select Run from my computer

 image

Click continue (if this was already set, you may not need to)

NOTE: Prerequisites are .NET framework 2.0 and MS core xml services 6.0

image

Microsoft .NET Framework 2.0

Control Panel\Programs\Programs and Features > click on Turn Windows Features on or off (left panel) > wait for load > look for .NET Framework 2.0, 3.5, or 4.x, etc. (this should be inclusive of the older versions of .NET)

image 

Expand > make sure BOTH boxes are checked for “Communication Foundation …” > click OK > wait for configuration change

image

Microsoft Core XML Services 6.0

SQL Agent Powershell Job to Check SharePoint Farm Backups complete properly with Thrown Error and Email Notification

SQL Agent BackupFilesCheck Job

$ErrorActionPreference = “Stop”
if ((ls “M:\spbackup\farm\”) -eq $null)
{
$smtp = New-Object Net.Mail.SmtpClient(“smtp.mydomain.com”)
$objMailMessage = New-Object System.Net.Mail.MailMessage
$objMailMessage.From = “sqlsp@mydomain.com”
$objMailMessage.To.Add(“spalerts@mydomain.com”)
$objMailMessage.Subject = “SQLSP SP Farm Backup Failed”
$objMailMessage.Body = “SP Farm Backup Failed – Failure, the backup location M:\spbackup\farm\ is empty. Please check SP Farm backup job in Central Admin and space on server.”
$smtp.send($objMailMessage)
throw “Failure, the backup location is empty. Please check SP Farm backup job in Central Admin and space on server.”
}else{
$smtp = New-Object Net.Mail.SmtpClient(“s-ex6.mydomain.com”)
$objMailMessage = New-Object System.Net.Mail.MailMessage
$objMailMessage.From = “sqlsp@mydomain.com”
$objMailMessage.To.Add(“ebruce@mydomain.com”)
$objMailMessage.Subject = “SQLSP SP Farm Backup Exists”
$objMailMessage.Body = “SP Farm Backup Exists”
$smtp.send($objMailMessage)
}

NOTE: You could use sql job setting for email, but this gives a bit more control IMHO

Task runs Backupmanagement.bat

This along with a scheduled task job that let you keep two copies:

[adjust script as needed]
@echo off
echo ==================================================
echo Backup the farm
echo ==================================================
@SET stsadm=”C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\stsadm”
rmdir /S /Q “\\sqlsp.mydomain.com\M$\spbackup\farmold”
rename “\\sqlsp.mydomain.com\M$\spbackup\farm” “farmold”
mkdir “\\sqlsp.mydomain.com\M$\spbackup\farm”
%stsadm% -o backup -directory “\\sqlsp.mydomain.com\M$\spbackup\farm” -backupmethod full
echo complete