PowerShell to C# and back
$24.99
Minimum price
$29.99
Suggested price

PowerShell to C# and back

A journey to C# and becoming better at PowerShell

About the Book

Why did we write this book?

We started writing this book to document our journey to learn C#, to be honest, we were scratching our own itch. There is no book or tutorial available today that can bridge the gap between a scripting language like PowerShell and modern programming language like C#, which is a natural language of choice, so we decided to write our own!

This book is the second book of this type since Prateek has written "PowerShell Guide to Python" a year back to take readers on a journey to learn Python using Powershell with the benefits of associative learning. Back then the most popular request\feedback was a book to cover PowerShell and C# together, so here it is! :)

PowerShell cmdlets are mostly written in C# and very often you will see .Net classes utilized in PowerShell scripts, and it seems like both these worlds are very much interconnected but still, there is a lot of friction, especially for IT professionals who lack understanding of object-oriented programming and find it difficult to understand software design patterns.

The purpose of this book is to provide bite-sized easily consumable chunks of knowledge and concepts to the reader, that will make it simple for them to learn and understand C# and improve their skill sets. More than that, leaving readers will tip, tricks and scenarios, that will develop a synergy with C# and PowerShell, and the knowledge attained can be refed further extend their capabilities by writing better and advanced scripts and Automation.

"Your problem is to bridge the gap which exists between where you are now and the goal you intend to reach."
                  ~ Earl Nightingale

Who is the Target Audience?

C# can be used to create almost anything from Windows desktop applications and games to develop powerful web applications and has become increasingly popular for mobile development too. Cross-platform tools such as Xamarin allow apps written in C# to be used on almost any mobile device. On top of that, since the announcement of .NET Core which is an open-source, general-purpose development platform now you can create .NET Core applications using C# for Windows, macOS, and Linux this just opens up a lot of opportunities and horizons for C#.

System Administrators and IT Professionals

System Administrators who want to upgrade their PowerShell scripting skills into C# Development or Programming roles, this book is written exactly keeping you in mind. The purpose of this book is to bridge the gap between PowerShell and C# and leave the readers with enough confidence, exposure, and hands-on experience so that they can develop in C# comfortably. Microsoft's cloud platform 'Azure' is growing rapidly, and having C# and PowerShell in your skill arsenal, that compliment each other and align with Azure automation and development needs, will definitely give you a competitive advantage as an IT professional.

C# Developer

If you are a C# developer and want to learn to write powerful automation and scripts using PowerShell, then you must read this book, because this book will help you associate concepts of modern programming language like C# with PowerShell and make it easy for you to learn PowerShell. Nowadays most of the CI/CD platforms like Azure DevOps leverage some sort of scripting language to run tasks and background jobs in their pipelines, so learning PowerShell will start to impact your day job in a good way.

What to expect from the Book?

Each chapter begins with a set of learning goals for the chapter and the topics covered as a list, which gives a fair idea to the reader what to expect in the chapter. It also enables the readers with a choice to skip the chapter if the topic is familiar and can be revisited later stage. After this a small introduction of the chapter to make the reader comfortable with the topic, followed by the main content of the chapter, headings, and sub-headings, figures, code samples/examples.

Towards the end of the book, all chapters have a 'Key takeaway' section which summarizes key pointers of the chapter. Key takeaways can be used to reinforce the learning and even come handy during revisions without going deep dive into the whole chapter again. Finally, chapters will end with some Exercises\Assignments that will further allow you to use the learnings from the chapter and implement that in code.

All chapters end with some reading recommendations, the official documentation for the reader on the related topic, which readers can follow to gain knowledge on the topic which is out of the scope of the book. Following is the structural pattern you will observe in all the chapters:

  • Purpose of the chapter
  • Introduction to the chapter
  • Main chapter content
  • Key Takeaways from the Chapter
  • Exercises and Assignments
  • Reading Recommendations

Available Book Formats

The book can be download in any of the following formats and it is recommended to read it on a personal computer in PDF format for clarity in images and code samples. We might publish this book on Amazon through Kindle Direct Publishing (KDP) in digital post-completion and even print it in the future but for now, it is only digitally available here.

  • PDF - For laptops and personal computers
  • EPUB - For phones and tablets
  • MOBI -For Amazon Kindle and E-Readers
  • WEB - On the web browser

Book updates and email notifications

This book has been published as we are writing it, a chapter at a time on Leanpub.com , which is a lean publishing platform and we will keep on updating and improving the book so that you have the best version of the book available. This book is work in progress and it is recommended that you allow Leanpub to send you update emails when a new version of the book manuscript is published. 

By default, this setting is not enabled and you have to turn it on by following the below steps, otherwise, you will miss any new chapters or updates we push to the book.

  1. Log into your Leanpub.com account
  2. From the top-right corner in the 'Account' drop-down menu, click on 'Library'
  3. Click on this book in your library.
  4. Now on the right-hand side, you will get 'Email Settings'
  5. Under 'Email Settings' select the checkbox next to 'New version available'

How to Provide Feedback?

We would appreciate you sending us an e-mail to prateek@ridicurious.com with any feedback about how you are using the content, and how the book could be improved, but this is just a request so that we can improve the book and track how it is being used. You can also use the "Email the Author(s)" option on the book webpage to reach out to both of us!

About the Authors

Prateek Singh
Prateek Singh

Prateek Singh is an Infrastructure Developer, an avid PowerShell blogger, and a community contributor. In 2017 and 2018, FeedSpot and SQLHack recognized his blog RidiCurious.com as among the “Top 50 PowerShell blogs in the world.” Find his open-sourced at GitHub, and reach out to him on Twitter at @singhprateik.

Prateek has written more than 250 articles on his blog and several other websites such as 4SysOps.com, IPSwitch.com, and TechTarget.com and also runs a YouTube channel. He is a published author of 3 books and contributing author of 2 Book and currently writing the 6th one, following is the complete list:

Deepak Singh Dhami
Deepak Singh Dhami

Deepak works as a systems engineer touching cloud platforms, build/release & automation. Awarded Microsoft Most Valuable Professional award (year 2014-17) for his contributions in the Cloud & Data-center Management.

Recently, he has started going back to his development roots and picking up C#, Go for Infrastructure development needs.

Blog - https://dexterposh.github.io/

GitHub - https://github.com/DexterPOSH

Reach out to him on Twitter @DexterPOSH

Bundles that include this book

$54.99
Suggested Price
$39.99
Bundle Price

Table of Contents

  • About the Book
    • Why did we write this book
    • Who is the Target Audience
      • System Administrators and IT Professionals
      • C# Developer
    • Book updates and email notifications
    • How to provide Feedback
  • Prerequisites
    • Setup and Tools
      • Windows PowerShell
      • PowerShell Core
      • Visual Studio Code, C# and Extension .Net Core SDK
      • Visual Studio (Optional)
  • How to Use this Book
    • Available Book Formats
    • Structure of a Chapter
    • Downloading Code samples and Examples
    • Running code samples and examples
      • C# Interactive Window in Visual Studio
      • dotnet-script extension for .Net Core Command Line
      • PowerShell and C# Jupyter Notebooks
  • Chapter 1: C# Primer
    • Introduction
    • C# Language
      • Key Characteristics
      • A Brief History of CSharp
    • Compilers, Runtime and .NET Framework
    • Program Structure and Organization
      • Program, Assemblies and Hello World
      • Namespaces
      • Class
      • Members
    • C# Programming Elements
      • Comments
      • Case Sensitivity
      • Using Directive and Statement
      • Types and Variables
        • Values Types
        • Reference Types
        • Variables
      • Operators, Operands and Expressions
        • Operators
      • Basic Input and Output
      • Conditional statements
        • If and If..Else statement
        • Switch statement
      • Loops and Iterations
      • Exceptions Try..Catch..Finally
      • Classes and objects
      • Arrays
    • Summary
    • Key Pointers
    • Exercises and Assignments
    • Reading Recommendations
  • Chapter 2: Classes and Objects
    • Introduction
    • Procedural vs Object-oriented programming
    • .Net Class Library
    • Classes and Objects
      • PowerShell Class
      • C# Class
    • Object Introspection
      • Inspecting PowerShell objects for properties and methods
      • Inspecting C# objects for properties and methods
      • Inspecting Constructors in C# objects
      • typeof() vs GetType() vs ‘is’
    • Class Members
      • Fields and Properties
        • PowerShell Class Properties
          • Default values to PowerShell class properties
          • PowerShell Cast initialization
          • Static Properties in PowerShell
        • C# Class Fields, Properties, and Accessors
          • Fields
          • Properties and Accessors
          • Initial values to C# class properties
          • Static Properties in C#
          • C# Object Initializer
      • Methods
        • PowerShell Class Methods
          • Static methods in PowerShell Class
          • Instance methods in PowerShell Classes
        • C# Class Methods
          • Static methods in C# Class
          • Instance methods in C# Class
      • Constructors
        • Constructors in PowerShell Classes
        • Constructors in C# Classes
    • Summary
    • Key Pointers
    • Exercises and Assignments
    • Reading Recommendations
  • Chapter 3: Variables
    • Introduction
      • Value Types
      • Reference Types
    • Naming conventions
      • Naming PowerShell variables
      • Naming C# variables
    • Declaring variables
    • Constant variables
    • Clearing and un-setting values of variables
    • Variable scopes
      • Variable scopes in PowerShell scripts
      • Variable scopes with C# Classes
        • Class level scope
        • Method level scope
        • Block level Scope
    • Summary
    • Key Pointers
    • Exercises and Assignments
    • Reading Recommendations
  • Chapter 4: Console Input and Output
    • Introduction
    • What is a Console?
    • Standard Input and Output
    • Writing to Console
    • Writing without a New-Line
    • Reading from Console
    • Reading numeric values
    • Reading keys from Console
    • Reading from Console Securely
    • Clearing the Console
    • Summary
    • Key Pointers
    • Exercises and Assignments
    • Reading Recommendations
  • Solutions to Exercises

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Do Well. Do Good.

Authors have earned$10,901,033writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF, EPUB and/or MOBI files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub