Posts

Showing posts with the label Powershell

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

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

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