Determine .NET Framework versions installed using PowerShell

Users can install and run multiple versions of the .NET Framework on their computers. When you develop or deploy your app, you might need to know which .NET Framework versions are installed on the user’s computer. Note that the .NET Framework consists of two main components, which are versioned separately:

  1. A set of assemblies, which are collections of types and resources that provide the functionality for your apps. The .NET Framework and assemblies share the same version number.
  2. The common language runtime (CLR), which manages and executes your app’s code. The CLR is identified by its own version number (see Versions and Dependencies). Continue reading “Determine .NET Framework versions installed using PowerShell”

Difference between URI, URL and URN

It has been my observation that many of the tech engineers do not know the difference between URI, URN and URLs. For many of them, they are same. For very of them, rest of them and few others are confused. So through this blog post, I intend to clarify that difference. I guess this is more of the classical questions like what to formally call a web address and what do you mean by a web address in first place. In this age of varying protocols and APIs and methods, what is called as a web address is itself of a question. for example, may serve entirely different content than which may further differ that (these urls are just for understanding purposes only). Continue reading “Difference between URI, URL and URN”

Compare files with Visual Studio

Visual Studio 2015 file comparison tool can be considered good enough for most of the use cases. Before learning how to compare files with Visual Studio, I used to use WinMerge, or another tool to compare. Not anymore of that!

What is still missing in the IDE is a small menu that allows us to select 2 files and compare them. From command line, you can do it with devenv.exe /diff which compares two files. It takes four parameters:
SourceFile, TargetFile, SourceDisplayName(optional), TargetDisplayName(optional) Continue reading “Compare files with Visual Studio”

Working with ConvertTo-Json output issues

As you are aware, we can use ConvertTo-Json cmdlet to convert an object to Json output format using PowerShell. However, there is something you need to be aware of while using conversion. By default, it does not work with very large objects (containing of multiple sub-objects) and converts them properly. This is because of the fact that the Depth parameter for ConvertTo-Json has a default value of 2. Let’s understand what this means.

For our example, we’ll create a JSON file with below details first and save it on to your local machine as new-json.json

Continue reading “Working with ConvertTo-Json output issues”

Working with JSON in PowerShell

In last post, we have described on what JSON is and how it is becoming increasingly important in the DevOps phenomenon. So its necessarily not only to understand the format, but also involve in our tools of choices. Microsoft has introduced couple of cmdlets in PowerShell to make use of JSON format namely ConvertFrom-JSON and ConvertTo-JSON.

Again, we can get the same by making use of Get-Command cmdlet:

JSON cmdlets in PowerShell
JSON cmdlets in PowerShell

Continue reading “Working with JSON in PowerShell”

Understanding JSON and compare it to XML

In this day and age of continuous delivery and integration, the focus is continuously moving away from software interface and on to APIs. One of the prime objectives of DevOps is to achieve end to end automation of delivery. For this, the various kinds of softwares which are used in the process of delivery, need to exchange data. This is where APIs come in handy. Using APIs, there is no manual intervention needed, and all the data can be exchanged easily.

APIs, more specifically REST APIs, return data when queried. The earlier format of choice used to be XML, then it turned over to XAML but now the focus is on JSON due to its easiness.  Continue reading “Understanding JSON and compare it to XML”

Enforce PreRequisites match before running PowerShell scripts

Many a times, you would write a script, have it happily running on your machine, share it with someone and get a call from them only to find that your script is not functioning! We all have ran into this situation once or more in our life. Some people would avoid it by writing lengthy documentation. But who reads documentation any more. So you would go to their desk and solve it for them. To overcome this problem, Microsoft has added #Requires statement in PowerShell.

The #Requires statement prevents a script from running unless the Windows PowerShell version, modules, snap-ins, and module and snap-in version prerequisites are met. If the prerequisites are not met, Windows PowerShell does not run the script.  Continue reading “Enforce PreRequisites match before running PowerShell scripts”