All posts by spjeff

Format-Table with row colors in PowerShell

How to run Format-Table in PowerShell and format output as table with color logic driven from cell value. Full code below. Cheers

VIDEO

SOURCE CODE

# List process and format as table
$proc = Get-Process
$proc | Format-Table @{
    # Add column "Name" to table
    Label = "Name"
    Expression = {
        if ($_.Name -eq "chrome") {
            # Format row color Green when Name is "chrome"
            $color = "32" # Green
        } else {
            # Format row color Red when Name is not "chrome"
            $color = "31" # Red
        }
        # Character 27 is ESC
        $e = [char]27
        # Format row with name and color
        "$e[${color}m$($_.Name)$e[0m"
    }
}, PID, CPU, PM, WS, VM, NPM, Path -AutoSize

Launch multiple M365 tenant PowerShell PNP console

Demo how to quickly launch multiple M365 tenant PowerShell PNP console. When supporting PROD, TEST, DEV lifecycle or have multiple M365 tenants we can leverage Devolutions Remote Desktop Manager (RDM) to have many PowerShell “profiles” and quickly authenticate with Client ID and Client Secret.

Great for M365, SharePoint Online SPO, and PowerPlatform tasks including:

  • View SharePoint sites
  • Increase SharePoint site quota
  • Grant SharePoint site administrator
  • Create SharePoint Site App Catalog
  • Generate CSV reports of sites and usage
  • Provision OneDrive users
  • Review M365 tenant security settings

Download RDM

https://devolutions.net/remote-desktop-manager/home/downloadfree

POWERSHELL

# Configuration
$SiteURL        = "https://TENANT-admin.sharepoint.com/"
$ClientID       = "GUID-HERE"
$ClientSecret   = "SECRET-HERE"
# Connect to the Site
Connect-PnPOnline -URL $SiteURL -ClientID $ClientID -ClientSecret $ClientSecret -WarningAction "Ignore"
Get-PnPTenantSite | Format-Table -AutoSize

VIDEO

SCREENSHOT

REFERENCES

https://medium.com/ng-sp/sharepoint-add-in-permission-xml-cheat-sheet-64b87d8d7600

https://pnp.github.io/powershell/

https://pnp.github.io/powershell/cmdlets/Connect-PnPOnline.html

PowerAutomate bypass Microsoft disable inactive MS Flow and always Turn ON

Microsoft 365 has feature with Power Automate to disable infrequently used MS Flow.

Demo will show how to force Turn ON all MS Flow in your tenant. Automatically re-enable flows that were suspended give stability for business process with quarterly, annual, or longer normal times between run.

Cheers.

VIDEO

SCREENSHOTS

REFERENCES

SharePoint Online Communication Site – Apply “Site Template” with 11 choices

Demo of how to apply “Site Template” to Communicate sites, and reverse changes to Microsoft default Communicate site.

As of today (4/5/2023) there are 11 “Site Template” choices available each with different deployment artifacts.

Cheers.

VIDEO

REFERENCE

Turbo SQL to SharePoint List Sync (PowerShell PS1)

PowerShell script to read source SQL table and synchronize into SharePoint Online (SPO) List destination. Great for PowerPlatform, PowerApps, and PowerBI integration scenarios. Optimized with usage of primary key, index columns, [Compare-Object] cmdlet [System.Data.DataRow] type, hashtable, and PNP batch HTTP POST network traffic. Cheers.

VIDEO

SCREENSHOTS

SOURCE CODE

REFERENCES

Turbo Crawl – Noderunner.exe CPU (RealTime Priority)

Wanted to share trick for how to unlock turbo Crawl search speeds with Microsoft SharePoint Server 2013/2016/2019/SE. Increasing the CPU process priority for “Noderunner.exe” from default “Normal” up to “RealTime” will give increase CPU horsepower to cycle from current document to the next. Given SharePoint and search crawl engine’s linear processing nature (serial document download, parse, save, then repeat) the pipeline performance benefits greatly from low latency.

Basically, with serial (one-at-a-time) processing the faster we pick up next document, the faster overall completion.

Internally, each Microsoft SharePoint search topology green checkmark is one instance of “Noderunner.exe” process doing the background processing. Increasing priority to those gives more O/S allocation of hardware. During “Full Crawl“, for example, we want as much hardware given to this pipeline as possible. Cheers.

CODE

# Turbo speed for Microsoft SharePoint Server 2013/2016/2019/SE crawl engine.  Boost CPU process priority to "real-time" for NODERUNNER for full farm search topology and W3WP for specific crawl machines.
Add-PSSnapIn "Microsoft.SharePoint.PowerShell"
$servers = Get-SPServer
$servers | Format-Table -AutoSize
foreach ($s in $servers) {
    # Display
    $pc = $s.Address
    Write-Host $pc -ForegroundColor "Yellow"
    # Find Noderunner
    $noderunner = (Get-Process -ComputerName $pc -Name "noderunner")
    $noderunner | Format-Table -AutoSize
    # Increase CPU priority
    foreach ($n in $noderunner) {
        # https://devblogs.microsoft.com/scripting/hey-scripting-guy-can-i-use-windows-powershell-to-lower-the-priority-of-a-process/
        $handle = $n.Handles
        
        # 256 = Realtime
        ([wmi]"win32_process.handle='$handle'").setPriority(256)
        # Increase priority
        Get-WmiObject Win32_process -ComputerName $pc -Filter 'name = "noderunner.exe"' | ForEach-Object { $_.SetPriority(256) }
    }
}

SEARCH TOPOLOGY

Below example shows traditional SharePoint Search Service Application (SSA) where each green checkmark indicates one instance of “Noderunner.exe”

PROCESS FLOW

Below is the serial pipeline for how search crawlers process one document then next. Low latency (from CPU Realtime) gives faster ability to pick up the next document and repeat.

PERFORMANCE CHART

Document Per Second (DPS) is the key metric for search engine speed to serially complete above steps.

REFERENCE

  • https://devblogs.microsoft.com/scripting/hey-scripting-guy-can-i-use-windows-powershell-to-lower-the-priority-of-a-process/
  • https://www.tenforums.com/tutorials/89548-set-cpu-process-priority-applications-windows-10-a.html
  • https://learn.microsoft.com/en-us/sharepoint/overview-of-search
  • https://learn.microsoft.com/en-us/sharepoint/search/manage-the-search-topology

PowerApps Admin – How to open MS Support Ticket (Full Form)

Demo showing the detailed process where attempting to open MS Support Ticket from traditional portal https://admin.microsoft.com/ redirects into https://admin.powerplatform.microsoft.com/support with detailed full form experience.

New ticket form inputs include:

  • PowerPlatform product (Flow, Canvas, Model, CDS, Virtual Agent, etc.)
  • MS Flow exact Connector
  • MS Flow exact action Step
  • MS Flow exact Run History URL for error and logic

Overall positive sign showing Microsoft investment into PowerPlatform support. Requires more effort to open MS Support Ticket with many form inputs, yet gives better chance at resolution and routing to correct engineer.

VIDEO

Azure Rapid Runbook – Run Every 5 Minutes

Demo how to schedule Azure Automation Runbook PowerShell PS1 on more frequent intervals than default 1 Hour provided by Azure Automation “Schedule” feature.

Leveraging Azure Logic Apps, we can create “Schedule” trigger to execute “Create Job” step and start Runbook every 5 Minutes. Cheers.

VIDEO

REFERENCES

PowerShell DEMO for Send-PNPMail and Register-PnPAzureADApp

Full demo showing step by step process to register new Azure AD application with API permission grant tenant level for send email.

Followed by second PS1 to execute Send-PnPMail and show successful delivery.

Replacement for legacy on-premise Send-MailMessage with SMTP server. Cheers.

VIDEO (PART 1 of 2)

Full demo showing step by step process to register new Azure AD application with API permission grant tenant level for send email.

Followed by second PS1 to execute Send-PNPMail and show successful delivery.

Replacement for legacy on-premise Send-MailMessage with SMTP server.

VIDEO (PART 2 of 2)

Second video showing Azure Automation Account (AA) configuration with Modules, Connection, PFX Certificate, and PS1 Runbook to successfully execute Send-PnPMail with cloud hosting.

REFERENCES

https://pnp.github.io/powershell/cmdlets/Send-PnPMail.html

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/send-mailmessage?view=powershell-7.3

Return to Top ▲Return to Top ▲