Windows PowerShell

PowerShell Tip: String Manipulation using Regular Expression

Posted on

Summary Regular Expression is very Powerful and best way to play with strings. Using REGEX in PowerShell is best way to query log files, pattern matching etc.., however we should use it as applicable. Example Code #Given Name : Chendrayan Venkatesan #Required Output: Venkatesan , Chendrayan “Chendrayan Venkatesan” -replace “([a-z]+)\s([a-z]+)” ,’$2, $1′ #Given Name : […]

SharePoint

SharePoint 2010 Publishing Feature Activation

Posted on

One of our clients reported an issue while editing the home page of SharePoint portal. Error: “An Unexpected Error Occurred” Impact: Unable to save the changes made. Reason Provided by the customer: Power User tried to deactivate and activate the publishing feature. Team tried reactivating the publishing feature which caused more pain. The Navigation bar […]

EWS

Delete Lync Contact Entries in Exchange Online Using PowerShell

Posted on

PowerShell code to remove LYNC Contacts entries in Exchange Online. Code #Target MailboxID’s $MailboxNames = “TargetMailBoxID1” , “TargetMailBoxID1” #Any Exchange Admin ID with appropriate permissions $AdminID = “AdminID” #Fetch password as secure string $AdminPwd = Read-Host “Enter Password” -AsSecureString #Load the Exchange Web Service DLL $dllpath = “C:\Microsoft.Exchange.WebServices.dll” [Reflection.Assembly]::LoadFile($dllpath) #Create a Exchange Web Service $Service […]

SharePoint

Delete SharePoint 2010 Library View

Posted on

We tried modifying the view in SharePoint 2010 using Designer 2010 and it’s corrupted! No option to delete the view ! Spin up your SharePoint Shell Management and execute the below code Start-SPAssignment -Global $SPWeb = Get-SPWeb $WebUrl $List = $SPWeb.Lists[$ListName] $View = $List.Views[$ViewName] #$view.ID $List.Views.Delete($View.ID) $List.Update() $SPWeb.Update() $SPWeb.Dispose() Stop-SPAssignment -Global     Note: Ensure […]

SharePoint

Avoid Accidental Deletion of SharePoint List

Posted on

One of my client requested a settings in SharePoint 2010 to avoid accidental deletion of Lists. Indeed we can recover it from Recycle Bin within 30 days, but they need to avoid deletion. Alternatively we can make a permission settings to avoid deletion. Let’s see how to do this using PowerShell. Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue […]