Will Microsoft abandon PowerShell in the future? This thesis sounds provocative, but with the release of the .NET SDK 10 Preview 4, there is an exciting development that could make it at least partially true.
In the latest Preview 4, C# files (*.cs) can be executed directly with the .NET Runtime without having to compile them first.
Before we look at the implications, let's take a look at the history of PowerShell and C# and their shared history.
PowerShell
PowerShell logo
PowerShell, released by Microsoft in 2006 under the code name “Monad”, revolutionized Windows system administration. Developed by Jeffrey Snover and under the technical direction of Bruce Payette, it combined a scripting language with .NET. Version 1.0 was released in 2006, version 2.0 (2009) brought remoting, followed by version 3.0 (2012). Windows PowerShell was increasingly used and was particularly popular with Windows and database administrators. Due to the use of Windows PowerShell by threat actors, who used it in particular to spread ransomware in cyberattacks, Microsoft introduced workflows and extended security functions with version 5.0 in 2016. As the open source concept gained importance at Microsoft and cross-platform support (Linux/macOS) was an increasing desire, Microsoft released PowerShell Core 6.0 as an open source project in 2016. Since then, PowerShell has been continuously developed and since 2020 we have been working with PowerShell 7, which has brought advances in the areas of performance and compatibility in particular. Today, PowerShell is essential for automation and DevOps and is used in almost every company in the enterprise sector.
C#
C# logo
C# was developed in 2000 by Microsoft under Anders Hejlsberg, inspired by C++ and Java, with a focus on simplicity and productivity. C# 1.0 (2002) debuted as part of the .NET framework. C# 2.0 (2005) brought generics, 3.0 (2007) LINQ and lambda expressions, 5.0 (2012) async/await for multithreading. In 2014, .NET went open source, and C# 6.0 (2015) offered cleaner syntax. With .NET Core (2016), C# became cross-platform (Linux/macOS). Today, C# 11 (2024) is top for apps, games (Unity), cloud and AI.
.NET SDK 10 Preview 4
Preview 4 of the .NET SDK is causing quite a stir. With the dotnet run <file>.cs command, C# files can be executed without prior compilation - just as easily as PowerShell scripts.
What are the advantages?
In combination with Microsoft Azure (e.g. Microsoft Graph API), this could be a game changer. Managing the Graph API requires a PowerShell module that often requires updates and is now over 1 GB in size. Forks could be accessed, but whether Microsoft will allow this in the long term is unclear.
There is a current .NET version that you should update to. PowerShell, on the other hand, currently offers three versions: 5.1 is installed on Windows by default. However, version 7.x is required for the Graph API. In addition, PowerShell 2 is available on many systems, which makes hardening more difficult, as older versions can hardly be secured.
As PowerShell is primarily an add-on to C# and contains many .NET functions wrapped in C#, the performance of C# is usually higher. A simple comparison: The output of 20 “Hello World” lines takes 14 ms (145,800 ticks) in PowerShell and only 4 ms (44,861 ticks) in C# - an enormous difference.
However, PowerShell is particularly impressive due to its versatile and user-friendly features. It is available directly “out of the box” on all Windows servers and clients, which enables seamless integration and immediate use in Windows environments. Thanks to its intuitive handling, PowerShell offers a low barrier to entry, making it easier for beginners to quickly become productive. The entry barrier for C# is significantly higher. PowerShell Core 7 also supports cross-platform automation on all operating systems, including Linux and macOS, which significantly increases flexibility and efficiency in heterogeneous IT environments.
Summary
Will C# replace PowerShell? Not completely. However, C# could gain ground for automation, while PowerShell will continue to be used for administrative tasks such as remoting. How will this development continue?
What do you think? Will C# overtake PowerShell or will PowerShell remain future-proof? Let us know in the comments!