Wednesday, November 11, 2015

Remove the Send To Connectors from Central Admin for a Web Application

Requirement: Remove the Send To Connectors from Central Admin based on names list

PowerShell Script:

-----------------------------------------------------------------------------------------------------------------
clear
Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.Powershell

######################## ENVIRONMENT VARIABLES ########################

$WebApplicationURL = "http://spdd" ## eg: "http://spddwebapp"
 


############################################################################
 
    $officeFileNamesList =@("REC001 Send To Conenctor","REC002 Send To Conenctor")
    $ServiceURL = "_vti_bin/officialfile.asmx"
    write-host "Opening web app object."  
    $WebApp = Get-SPWebApplication $WebApplicationURL
 
[System.Collections.ArrayList]$webOff = $WebApp.OfficialFileHosts
#$off = $WebApp.OfficialFileHosts | where OfficialFileName -eq $officeFileNamesList

write-host "Loop through all OfficialFileNames"
foreach($offFile in $webOff)
{
 
   if($officeFileNamesList -contains $offFile.OfficialFileName)
   {
        $name = $offFile.OfficialFileName
        $WebApp.OfficialFileHosts.remove($offFile)
        $WebApp.Update()
        write-host "Succesfully removed the connector '$name'!"
   }
}


write-host "Completed"

-----------------------------------------------------------------------------------------------------------------

Configure Send To Connector in SharePoint 2010 using PowerShell Script

Requirement: Configure Send To Connector in SharePoint 2010 for moving or copying the documents across site collections (such as record centers).

Solution: We can configure this in Central Administration but want to automate this using script.

PowerShell Script:
-------------------------------------------------------------------------------------------------------
clear
Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.Powershell

###############ENVIRONMENT VARIABLES ###########################

$WebApplicationURL = "http://spdd" ## eg: "http://spddwebapp"
    $RecordCenterSiteColls = @("RECSITE1","RECSITE2")


#####################################################################
    $ServiceURL = "_vti_bin/officialfile.asmx"
    write-host "Opening web app object."
 
    $WebApp = Get-SPWebApplication $WebApplicationURL


function AddSendToConnection($sendServiceURL, $siteName )
{

    #Get the Web Application
 
   
    $SPOfficialFileHost = New-Object Microsoft.SharePoint.SPOfficialFileHost

    #Set Send to Options#

    #Send to Connection Name
    $oFName = $siteName + " Send To Conenctor"
    $SPOfficialFileHost.OfficialFileName = $oFName

    #Send to Target location
 
    #write-host "Office File Url - $offFileUrl"
    $SPOfficialFileHost.OfficialFileUrl = $sendServiceURL

    $SPOfficialFileHost.ShowOnSendToMenu = $true

    #Send to Operation

    $SPOfficialFileHost.Action=[Microsoft.SharePoint.SPOfficialFileAction]::Move

    $SPOfficialFileHost.Explanation = "Send to connection for documents move to other record site collections."

    $WebApp.OfficialFileHosts.Add($SPOfficialFileHost);

    $WebApp.Update()

}

write-host "Loop through all receiver site collections."
foreach ($rSite in $RecordCenterSiteColls)
{
    $fullSiteURL = $WebApplicationURL + "/sites/" + $rSite
    $sendServiceURL =   $fullSiteURL + "/" + $ServiceURL
    write-host "Send service URL - $sendServiceURL"
    AddSendToConnection $sendServiceURL $rSite
    write-host "Succesfully added Send To Connector for $rSite"
}

write-host "Completed"
-------------------------------------------------------------------------------------------------------

Access to XMLHttpRequest at 'from origin has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. .net core angular

Issue: The angular application was getting error from API that the origin has been blocked by CORS policy. Solution: Make sure that the...