Microsoft cloud engineer - SharePoint, Office 365, Azure, DotNet, Angular, JavaScript.
Microsoft cloud engineer - SharePoint, Office 365, Azure, DotNet, Angular, JavaScript.

April 2015

DataTable in PowerShell for crazy fast filters

Recently I was working with a 60,000 row CSV and applying several filters to find matching rows.   This took between 1.0-1.8 seconds per row.   While OK in small scale (few hundred) the script run duration grew to several hours.    There had to be a better way.

Enter [System.Data.DataTable]

Native PowerShell collections are simple to create and easy to work with.   However, in large scale I find DataTable to perform better.   It requires more up front coding to get ready (columns, schema, populate rows) but then runs crazy fast.   Sample code below.

Enjoy! 

shades_smile

 

2207

 

PowerShell

People.CSV

Query remote User Profile with PowerShell and REST API

The below code leverage SharePoint 2013 REST /_api/ to get User Profile detail remotely.   WebClient issues the HTTP GET and saves XML response.   Parsing XML gives full profile detail which can be exported or saved with other functions.   Hope this helps! 

shades_smile

 

NOTE – Remember to replace “sharepoint2013” with target farm DNS and “domain\” with Active Directory domain.

 

IISFlush.ps1

While troubleshooting an error with Excel Web Access I found recycle wasn’t sufficient and IISRESET was needed.   However, this raised questions about daily scheduled IIS recycle and if that would be enough to give a stable IIS footprint each business day.   I decided to err on the side of caution and schedule a full IISRESET along with code to ensure all sites and pools started up again OK.   PowerShell below.  

 

Also, I would recommend installing SPBestWarmUp (http://spbestwarmup.codeplex.com)  by running “spbestwarmup.ps1 –install”    This creates a Scheduled Task repeating every 15 minutes to simulate user traffic and keep those IIS pools responsive for end users.   No more wait on first visit.   It even warms up Central Admin to help out SharePoint admins.  

 

Enjoy! 

shades_smile

 

Test if GAC assembly exists with PowerShell

Recently I was troubleshooting a SharePoint health analyzer message about missing GAC DLL assembly.   Some servers in the farm had the DLL while others did not.  The below PowerShell one-liner helped me run a test on each server to load the GAC DLL and verify if it was installed.   Hope this helps others too!  

shades_smile

 

Code

 

References

© Copyright 2016
@ SPJeff

Return to Top ▲Return to Top ▲