Thursday, January 11, 2018

Disable Sandbox Model for Word Automation Services using PowerShell


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

$sp = Get-SPServiceApplication | where {$_.TypeName.Equals("Word Automation Services")}  
$sp.DisableSandbox = $true
$sp.Update()

Perform IISReset in all the servers of a SharePoint Farm using PowerShell


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

If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )  
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell } 
 
$host.Runspace.ThreadOptions = "ReuseThread" 
 
#Definition of the funcion that performs the IIS RESET in all the servers 
function PerformIISReset 
{     
    try 
    {         
        #Getting the servers where the IISReset is going to be done 
        $spServers= Get-SPServer | ? {$_.Role -eq "Application"} 
        foreach ($spServer in $spServers) 
        {             
            Write-Host "Perform IIS Reset in server $spServer" -f blue 
            iisreset $spServer /noforce "\\"$_.Address 
            iisreset $spServer /status "\\"$_.Address 
        }         
        Write-Host "IIS Reset completed successfully!!" -f blue   
    } 
    catch [System.Exception] 
    { 
        write-host -f red $_.Exception.ToString() 
    } 
} 
 
Start-SPAssignment –Global 
PerformIISReset 
Stop-SPAssignment –Global 
 

Extract WSP (SharePoint Solution) file from SharePoint Farm using PowerShell

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

$solName = "Sample.wsp"
$farm = Get-SPFarm

$file = $farm.Solutions.Item($solName).SolutionFile
$file.SaveAs("c:\Sample.wsp")

write-host "Completed"

Set Master Page Url using PowerShell - SharePoint

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

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

$webAppUrl = "https://webappurl"

################################################################


$mainSite = $webAppUrl 
$web = Get-SPWeb $mainSite
$web.MasterUrl = "/_catalogs/masterpage/v4.master"
$web.Update()
$web.Dispose()

Write-host "Completed"

Enable Crawl for DropOffLibrary Documents using PowerShell - SharePoint

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

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

$siteUrl = "https://record-site-coll-url"


###########################################################

$dropOffLibrary ="Drop Off Library"
try
{
    $site=Get-SPSite $siteUrl
    $web=$site.RootWeb
    $docLibrary =$web.Lists[$dropOffLibrary]
    # Change the advanced settings
    $docLibrary.NoCrawl = $false;
    $docLibrary.Update()
    $site.Dispose()
    write-host "Completed"
}
catch
{
    write-host "Error"
}


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...