Eli Hess

Explore articles and content from this author

Eli Hess

3 articles published

2 min read

Use PnP PowerShell to add ContentType for your SharePoint site

You can achieve the task by using SharePoint GUI. However, if your sites collection has tens of hundreds sites and each site has more than one document library, it will become a nightmare for a SharePoint administrator to do the task by using GUI.

Luckily, there is PnP Powershell which can help us achieve the goal.

The steps will be like below:

#Step1: export your login credential to a secure file on your local machine

4 min read

Executing LINQ Queries in PowerShell – Part 2

And we’re back!
Ok, so in the last blog we began a conversation about delegates and using LINQ in PowerShell. In today’s post, I’m going to give an example of how it can be incredibly useful. Let’s talk about Joins.

Joins

In my line of work, I’m constantly running into the need to combine datasets from multiple sources that relate to each other and pull out some specific properties. Say you have two internal services, one which is used to track production status and another which is used to monitor whether machines are online. To demonstrate this, let’s initialize some mock data once again.

4 min read

Executing LINQ Queries in PowerShell – Part 1

Greetings PowerShellers!
Lately, I’ve been itching to write something up on Microsoft’s Language-Integrated Query (LINQ). You’ve likely encountered it if you’ve done any development in C#. LINQ is an incredibly powerful querying tool for performing look-ups, joins, ordering, and other common tasks on large data sets. We have a few similar cmdlets built into PowerShell, but other than the ‘.Where()’ method on collection objects nothing that comes close to the speed at which LINQ operates.
To dig into this topic, we’re going to have to do a quick high level overview of a couple of other .NET staples often encountered in the C# world. You see, unlike most .NET methods which accept object types like integers, strings, and the like, LINQ uses static extension methods which only accept delegate object types.
What are delegates? In application development, there is an occasional need for objects within memory to communicate with each other for things such as “button click events.” To address this, the Windows API uses function pointers to create callback functions which then report back to other functions in your applications. Within the .Net Framework, these are called delegates.
Delegates are objects that point to another method, or possibly many methods, by storing three key pieces of information: the address of the method on which it makes calls, the parameters (if any) of this method, and the return type (if any) of this method. With this information, a delegate object is able to invoke these methods dynamically at runtime, either synchronously or asynchronously. With this information, a delegate object is able to invoke these methods dynamically at runtime, either synchronously or asynchronously.
A simple example of this in C# looks like this: