Posts

Showing posts from 2021

How to get site collection created date in SharePoint Online

Image
  Q: How to get the site collection created date in SharePoint online Answer:  This can be done using the PnP SharePoint commands $connection  =   Connect-PnPOnline   - Url  " <SITE URL> "   - ReturnConnection  - UseWebLogin $web  =   Get-PnPWeb   - Includes Created  - Connection $connection Write-Host  $web.Created Happy Coding...!!!

How to check for empty for null and empty Values in Power Automate?

Image
  Q: How to check for empty for null and empty Values in Power Automate? ANSWER:  Checking for NULL Value. In order to check for the null value Go to Expressions and then type null, the value will show up Checking for EMPTY Value There is no direct way to check on the empty value, so in order to check if the string value is empty, check the length of the variable Happy Coding..!!!

How to get the difference in 'DAYS' between two dates in Power Automate?

Image
  Q: How to get the difference in 'DAYS' between two dates in Power Automate? A: In order to get the difference in Days follow the Below Formula div(sub(ticks('2021-05-10'), ticks('2021-05-10')), 864000000000) Happy Coding..!!

How to execute parallel/ Threaded jobs in PowerShell

Image
  Many times we need to work in parallel when executing the Powershell commands. Today in this post I will tell how we can execute the commands in parallel.  In my case, I have used these parallel jobs for the migration of SharePoint On-Prem to SharePoint Online using Sharegate, executing multiple instances and then monitoring those instances to initiate as soon as any of the instances is finished executing. Step 1: Installing the Module To leverage the benefit of the parallel jobs, we need to install the Module so to install the module, execute the following command Install-Module   - Name  " ThreadJob "   - Scope AllUsers Once the module is installed, then you are ready to go. Step 2: Execute Parallel Jobs Now you can start parallel jobs in the background. Here is the sample for executing the parallel jobs $Job  =   Start-ThreadJob   - FilePath  " .\PowershellScript.ps1 "   - ArgumentList  @ ($param1, $param2)  - Name 

How to stop computer from sleeping

Image
  This is a very generic post, but I felt though this is small thing but can be of good use. So, many times we do run the PowerShell scripts or some processing on our local computer and it is blocked due to the system entering into sleep mode. Due to which the process gets stopped. There are third-party apps for this but do not rely on installing many 3rd party apps to my system. So I found the script which does the job for me. I know what's written in the script so I am confident while running this script. Here is the script, Clear-Host $myshell  =   New-Object   - com  " Wscript.Shell " while  ( $true ) {      Write-Host  ([ char ] 9829 )  - ForegroundColor Red  - NoNewline     $myshell.sendkeys( " . " )      Start-Sleep   - Seconds  300 } Hope this will help you as well, do comment and share if you like it. Happy Coding..!! Sumit Kanchan

Alternative to Discussion list in SharePoint Online

Image
  In SharePoint Online one of the most missed features from the legacy system is the ability to create discussion forums. Since we do not have the OOB functionality, but we still can achieve it using the OOB features. In this post, I will show you how you can create the discussion forums using OOB features and with a more attractive UI.  Let's start and set up the discussion Forum. STEP 1: Create necessary columns in Site Pages Library To Achieve the functionality, I have made use of the "Site Pages" Library as it gives you the OOB ability to comment and like on the page. In order to make it fully usable, we will create a column  PageType: This will tell us whether the page created is a discussion or the page Values: Page, Discussion STEP 2: Create Custom View Create a View (in my case I have created the view by the name Discussion),

Play Big with large lists and document libraries

Image
  What if the SharePoint list or library grew too big? This is a very common question when you are designing the SharePoint solution. So in this article, I will try to explain how you can do that. Impact of unhandled Large List So, the problem first, What is the impact if it grew too large..?? Will we lose data ... ?? NO Will, the data be deleted... ?? NO Is data not safe.. ?? NO What is the Threshold limit? So what is the impact of a large list?? yes, Threshold is the cause The impact is that you will get the threshold error if your view contains records greater than 5000. When any list or library view returns records of more than 5000 it displays the threshold error. This is the hard-line limit a view can show up the number of records. So, there are multiple ways you can handle this error Solution 1: Switch to Modern View, as the latest the best and will be continuously improved. For modern Microsoft is continuously evolving and more enhancement will be there in the future. Solution

Retrieve SharePoint List Item Versions in SharePoint Online using PnP

Image
  In many cases, we need to identify the versions of the SharePoint List Item. So here is the way to get all the versions of the item using PnP. function   Get-ItemVersion  {      param  ($spURL, $spListTitle)           $checked  =  ([ char ] 8730 )           Write-Host   " Creating connection to the SharePoint Online..... "   - ForegroundColor Yellow  - NoNewline     $spConnection  =   Connect-PnPOnline   - Url $spURL  - UseWebLogin  - ReturnConnection  - ErrorAction Stop      Write-Host  $checked  - ForegroundColor Green       Write-Host   " Reading list items from ' $listTitle '..... "   - ForegroundColor Yellow  - NoNewline      $listItems  =   Get-PnPListItem   - List $spListTitle  - PageSize  5000    - Connection $spConnection  - ErrorAction Stop           Write-Host  $checked "  ($( $listItems.Count ) in $((( Get-Date )  -   $start ).Seconds) sec) "   - ForegroundColor Green      $listItems |  ForEach-Object  {          $listIt

Function for Digital Unit Conversion in Power BI (KB, MB, GB...)

Image
  While displaying reports it is very common to convert the units. So today I will be displaying the function that can be used in order to convert the Units Space  = VAR  total  =     SUM ( Table1[ Used   Space ] )  +   0 RETURN      IF  (         total  <   1024 ,         FORMAT ( total,  " #0.0# B "  ),          IF  (             total  <  POWER (  2 ,  20  ),             FORMAT ( total  /  POWER (  2 ,  10  ),  " #0.0# KB "  ),              IF  (                 total  <  POWER (  2 ,  30  ),                 FORMAT ( total  /  POWER (  2 ,  20  ),  " #0.0# MB "  ),                 FORMAT ( total  /  POWER (  2 ,  30  ),  " #0.0# GB "  )             )         )     ) So if you look into the function the core logic is      B  -->  KB then divide by POWER (  2 ,  10  )     B  -->  MB then divide by POWER (  2 ,  20  )     B  -->  GB then divide by POWER (  2 ,  30  )      And...      KB  -->  B then multiply by POWER (

Retrieve Secret from Key-Vault using PowerShell in Azure Runbook

Image
  Today I will showcase to you how to retrieve the Secret from the Key-Vault using PowerShell in Azure Runbook. This is one of the most common scenarios whenever you are writing the script and need credentials for authentication.  Step 1: Check if the following Modules are available in the Azure Runbook AZ.KeyVault AZ.Accounts To check to Navigate to your Automation account, then in the left navigation click on Modules and search for the modules Step 2: If the modules mentioned in Step 1 are not found, then navigate to the " Modules gallery ", search for the modules, and then install. Once installed, re-check for the installed modules as mentioned in step 1.  Step 3: Copy the below script and paste it into your runbook      try  {         $connectionName  =   " AzureRunAsConnection "          # Get the connection "AzureRunAsConnection "         $servicePrincipalConnection  =   Get-AutomationConnection   - Name $connectionName          " Logging in to 

Secure Password with PowerShell encryption

Image
Today we will look into the encryption using PowerShell We usually when working on the elevated privileges, would like to have the security of the script so that the credentials are not compromised. So today I will be discussing it. Machine Specific Encryption The simplest way is to Secure the string and keep that in the file. so then the encrypted string cannot be compromised ENCRYPTION $securePassword  =   " Password@1234 "  |  ConvertTo-SecureString   - AsPlainText  - Force $encrypted  =  $securePassword |  ConvertFrom-SecureString  |  Out-File   - FilePath  " C:\Secured\Encrypted.txt " This will export the password into the encryption format using the default machine keys. to retrieve the password into the plaint text or secure string use the below code DECRYPTION # Returns the password as the secure string $securePassword  =   Get-Content   - Path  " C:\Secured\Encrypted.txt "  |  ConvertTo-SecureString        # Returns the plain text of the pas

Azure runbook script to send mail using PowerShell and SendGrid

Image
 Hi Friends, Today I will be showing how to create and send the mail notification using the SendGrid through Azure Runbook and Powershell SendGrid is a third party API that is very much integrated with Azure and is very easy to use. It provides various ways to send the mail. In this blog, I will be explaining the code to use SendGrid REST API to send the mail. STEPS..!! Step 1: To use SendGrid, you should have 2 things SendGrid Subscription Key: This key will let the SendGrid know the subscription you have and will allow the number of emails accordingly Sender Identity: This identifies the sender so that the mails do not lands up in the SPAM/JUNK folder. To have the above two, you need to login to the SendGrid and follow the instruction. Step 2: Store the Subscription key in Key Vault To maintain the security, I will be keeping the SendGrid Subscription Key into the Azure KeyVault. If you want to do the same, please follow the steps mentioned here Make a note of the two properties that

Comparing List Item count of SharePoint Sites

Image
 Hi friends, When we are migrating we would like to automate as much as possible. One of the processes that I automated was the comparison of the list item count for the two SharePoint sites. Using this PowerShell script will generate the CSV file will all the list differences. This is the quick way of validating the migration of thousands of sites. Happy Coding..!!

Adding Script Editor web part to SharePoint classic page using PowerShell

Image
 Hi friends, When we are migrating the SharePoint on-prem to SharePoint online, we need to tell the users about the site is migrated and there are multiple ways of doing it. One of them is to add the redirection script on the page so that the user will get redirected by itself to the newly migrated site. In this blog, I will be showing how to add the script editor web part using the PowerShell and add the script as well. Problem Statement I have a SharePoint list where all the old sites and new sites are mapped. Need to read all the items and add the script editor web part along with the script for the redirection of the page to the new site URL. Script added - It highlights the page and redirects the user to the new site after 10 seconds. Note: If there is a need to change in the script, do change in the  $WebPartXml  variable. Hope this script will save a lot of time and will help you. Happy Coding..!!