Skip to main content

Posts

Showing posts from April, 2025

Convert IST to CST/CDT in PowerShell – Handling Daylight Saving Time (DST)

Working across time zones can be tricky, especially when Daylight Saving Time (DST) is involved. If you’re dealing with automation, scheduling, or data transformation tasks, converting between Indian Standard Time (IST) and Central Time (CST/CDT) becomes essential. In this post, I’ll walk you through a PowerShell function that smartly handles the conversion of an IST datetime to either CST (Central Standard Time) or CDT (Central Daylight Time), depending on the date and DST rules. The PowerShell Function Below is a reusable PowerShell function that converts IST to CST/CDT accurately by accounting for Daylight Saving Time. function Convert-ISTToCSTorDST {     param (         [datetime]$ISTDate    # Input IST DateTime to be converted     )     # Central Time Zone Information     $centralTimeZone = [System.TimeZoneInfo]::FindSystemTimeZoneById("Central Standard Time")          # Check if the g...

Bulk Import Excel Data to SharePoint List Using PowerShell and PnP

  Managing large datasets in SharePoint can be tricky, especially when you're dealing with Excel files and need to avoid list view threshold issues. In this guide, I’ll walk you through a PowerShell script that efficiently imports data from Excel into a SharePoint Online list using PnP PowerShell — with batching support for performance. Prerequisites Make sure you have the following before running the script: SharePoint Online site URL Excel file with data properly formatted PnP PowerShell module installed ( Install-Module PnP.PowerShell ) Appropriate SharePoint permissions What the Script Does Connects to your SharePoint site Loads and reads an Excel file Converts Excel date values Batches records in groups (to avoid the 5000 item threshold) Adds the items to your SharePoint list or library Logs execution time PowerShell Script $siteUrl = "[Site Collection URL]" Connect-PnPOnline -Url $siteUrl -UseWebLogin # Capture the start time $startTime...

How to Split a Large Excel File into Smaller Chunks Using PowerShell

Working with massive Excel files can be cumbersome—slow to open, hard to process, and error-prone in automation. If you’re dealing with a large dataset and need to split it into smaller, manageable files, PowerShell offers a powerful and efficient way to do it—especially with the help of the ImportExcel module. In this guide, I’ll walk you through a simple script that takes a large Excel file and splits it into multiple smaller Excel files, each containing a defined number of records. Requirements PowerShell ImportExcel module You can install it via PowerShell with:              Install-Module -Name ImportExcel # Import the ImportExcel module Import-Module ImportExcel # Path to the large Excel file $excelFilePath = "[LocalFilePathwithFileExtention]" # Define the chunk size (e.g., 10,000 records per chunk) $chunkSize = 10000 # Read the Excel file $excelData = Import-Excel -Path $excelFilePath # Calculate how many chunks are needed $totalRo...