Posts

Enable/Disable SharePoint OOTB SPAlerts using PowerShell

Image
SPAlerts aka User Alerts is one of nice feature that SharePoint provides OOTB, This feature get automatically enabled once we configure SMTP Outbound mail address in Central Admin.  Basically it has 3 types of Alerts Frequency: Immediate Daily Weekly  Each runs on it own respective TimerJob in CA.User can set alerts for both List/Library level or item level for any existing and newly created SPList/Lib objects.  However, There is no UI option available in SharePoint to enable/disable this feature per User/List/Library level; Without deleting  it. But some time our requirements are never been interesting that we need to disable alerts for Specific User or All the users from specific List/Library $oWeb = Get-SPWeb "https://site.domain.com/sites/web" $oList = $oWeb .Lists.TryGetList( "Communication" ) # Get all alert # $alerts = $oWeb.Alerts | ? { ($_.List.Title -eq $oList.Title) } # Get alerts of specific frequency $alerts = $oWeb .Aler

SharePoint Server - Recycle / Stop-Start Application/Site pool using C#

Image
As a continuation of my previous post List All Servers in SharePoint Farm using C# Now w'll see to Start/Stop Pools without login to the server each time. { Please check the NOTE at the very end on this post } List All Application/Site Pools /// <summary> /// Load Pools from the given server /// </summary> /// <param name="serverName">Server name</param> /// <param name="pool">Pool type</param> public void LoadPools( string serverName, PoolType pool) { var server = ServerManager.OpenRemote(serverInstance); if (pool == PoolType.AppPool) { appPoolCollection = new List<ApplicationPool>(); appPoolCollection = server.ApplicationPools.ToList(); } else if (pool == PoolType.SitePool) { siteCollection = new List<Site>(); siteCollection = server.Sites.ToList(); } } Start/Stop Application Pool /// <summary> /// Reset Applicat

Powershell Scripts 2

Image
Lets see continuation of my previous PowerShell series. This time will start from the basic commands. Load Assembly references in PowerShell Declare Global Variables in PowerShell Pass/Read Command Line arguments Convert DateTime based on regional settings in PowerShell Read RESX value in PowerShell Perform CAML Query in PowerShell Add SharePoint Snapin if (( Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null ) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue } Load default/custom Assembly references [void][System.Reflection.Assembly] :: LoadWithPartialName( "System.Net" ) [void][System.Reflection.Assembly] :: LoadWithPartialName( "System.IO" ) [void][System.Reflection.Assembly] :: LoadWithPartialName( "System.Xml" ) [void][System.Reflection.Assembly] :: LoadWithPartialName( "System.Collections.Generic" ) [void][System.Reflection.Assem

List All Servers in SharePoint Farm - C#

Image
Some times we need to login to all the servers in SharePoint farm just to restart selected Application or Site Pool. Let's see a C# code how to retrieve and recycle selected pools from all the servers in our SharePoint farm. In this series will see How to retrieve all servers in SharePoint farm using C# PS: Please check the NOTE at the very end on this post. First things first import dll's using System ; using Microsoft.SharePoint ; using Microsoft.SharePoint.Administration ; using Microsoft.Web.Administration ; Declare global variables // Global enum Variables public enum Action { Start, Stop, Invalid } ; public enum PoolType { AppPool, SitePool } ; // Global Server variable public List<string> servers = null ; // Global Pool ' s collection variables public List<ApplicationPool> appPoolCollection = null ; public List<Site> siteCollection = null ; Get All SharePoint Farm server names public

PowerShell Scripts

Image
Let see some of the most useful PowerShell commands in SharePoint to perform below activities. Read SMTP Outgoing Mail Address from Central Administration Get/Set Primary and Secondary Site Administrator Remove user from Site Collection Admin Remove user from Site Groups Set user from direct web Roles Permissions Read SMTP Outgoing Mail Address from CA function LoadEmailConfig() { try { $caWebApp = ( Get-SPWebApplication -IncludeCentralAdministration) | ? { $_ .IsAdministrationWebApplication -eq $true } Write-Host ( "SmtpServer: " + $caWebApp .OutboundMailServiceInstance.Server.Address) Write-Host ( "FromAdress: " + $caWebApp .OutboundMailSenderAddress) } catch { WriteToLog ( "Trying to get eMail Configuration from Central Admin. Exception:- " + $_ .exception.message) } Get/Set Primary/Secondary Site Administrator function GetAdmins() { $site =

What is Microsoft Flow

Image
Being a Microsoft fan, I always wonder how cloud based solution could help business/companies to gain more with good ROI. Microsoft has proved in many ways by providing tons SaaS services to name a few Office 365, Groups, Delve, Powerapps... Lot’s more. Microsoft Flow is one among the list where my interest flows recently... What is Flow? Microsoft Flow is a cloud-based service that makes it practical and simple for line-of-business users to build workflows that automate time-consuming business tasks and processes across applications and services. In detail : Flow as a service it can connect to various cloud based services including Non-Microsoft product and enabling end-users to create business centric workflows with simpler steps and conditions. Its gives a step-by-step visualization of various Services. Let’s deep dive in to the terms in Flow Connectors : It is an encapsulated bridge to hold the authorization from flow end to respective services. Triggers : T

Develop Powerapps from the Scratch - Series3/3

Image
Hi All, Here again with the final series 3. You can check out my previous series to contextually understand this one. Develop Powerapps from the Scratch - Series1/3 Develop Powerapps from the Scratch – Series2/3 All Right let’s get STARTED Data source Product Title aka Review Title Review Description Rating Product 1 P1-Review 1 Long text… 5 Product 1 P1-Review 2 Long text… 4 Product 1 P1-Review 3 Long text… 2 Product 2 P2-Review 1 Long text… 4 Product 2 P2-Review 1 Long text… 1 Product 3 P3-Review 1 Long text… 5 Product 3 P3-Review 2 Long text… 1 Product 3 P3-Review 3 Long text… 3 Product 3 P3-Review 4 Long text… 5 View Review Screen Add a new screen and rename it to “screenViewReview” or you can “duplicate” the existing scr