Tag: PowerShell Coding

Create a modern team site using PnP PowerShell in SharePoint

  In this tutorial, we will learn about what is a modern team site in SharePoint, what is a communication site in SharePoint online, what is the difference between team site and communication site in SharePoint Online. Then we will learn about how to create a modern team site in SharePoint Online using PnP PowerShell

Continue reading

In 2 steps convert a classic SharePoint page to modern using PnP

  Over the many years we as a SharePoint professional, we have been using the SharePoint classic page both in SharePoint on-premise and SharePoint online(classic). But recently in the last couple of years, Microsoft has been focusing to convert the classic SharePoint to modern SharePoint. So in this article, we will learn about how to

Continue reading

PowerShell: How to pass multiple parameters into a function in PowerShell

  In this post I will show how to pass multiple parameters into a function in PowerShell coding.    Addition of numbers function using PowerShell example: cls #The below sample function will accept numeric parameters and do the addtion. Function Add-Numbers() { param ( [Parameter(Mandatory=$true)] [int32] $FirstNumber, [Parameter(Mandatory=$true)] [int32] $SecondNumber, [Parameter(Mandatory=$false)][int32] $ThirdNumber ) Try {

Continue reading

Exception or Error handling in PowerShell -Try/Catch/Finally Block Example

  In this post I will show that how we can handle the exception in PowerShell coding using the try/catch/finally block and how we can write the error or exception message into the log file.   Exception handling using try/catch/finally block PowerShell example: cls $fileName = “File_Uploading_Report” $enddate = (Get-Date).tostring(“yyyyMMddhhmmss”) $logFileName = $fileName +”_”+ $enddate+”_Log.txt”

Continue reading

Using PowerShell create a log file

  In this post, I will show that how to build or create a logging function in PowerShell in the PowerShell “.ps1” file directory. However, we can change to any directory wherever we wish – only we need to change the directory path.   How to create a log file for the PowerShell scripting or

Continue reading

Using PowerShell – Create a folder if not exists

  In this post I will show how to create a folder or directory if not exists in the given directory or path using PowerShell code or script.   The below PowerShell code will create a folder with the name “LogFiles” in the .ps1 file root directory if not exists. Create a folder in the

Continue reading

SharePoint Online Automation – O365 – Upload files to document library using PowerShell CSOM

  Here in this post – I will show how we can upload multiple files or documents to SharePoint online document library using PowerShell CSOM programmatically from the given directory.   Below are the list of files – located in my local directory which I am going to upload to SharePoint online document library using

Continue reading

Encode and decode an URL using PowerShell coding

  Here in this post, I will show how to encode and decode the URL using PowerShell coding and also we will learn how to decode a SharePoint list id (GUID) using the online tool. Introduction: A website’s URL, also usually known as the “website address”, is what we would enter into a web browser

Continue reading

SharePoint Online Automation – O365 – Download files from a document library using PowerShell CSOM

  Here in this post – I will show how we can download files or documents from SharePoint online document library using PowerShell CSOM programmatically from the given date by passing “From Date” and “To Date” to the query. Lets say we want to download certain files from SharePoint document library those were created between

Continue reading

SharePoint Online Automation – O365 – Create multiple items in a list using PowerShell CSOM

  Here in this post, I will show how to create multiple list items in SharePoint online list using  PowerShell CSOM code programmatically.   PowerShell CSOM code to add multiple items: CLS #Load SharePoint CSOM Assemblies #Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll” #Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll” $fileName = “Adding_Multiple_Items_Report”

Continue reading