Monday, October 24, 2022
Documentation System.Net.WebClient
Saturday, October 22, 2022
PowerShell: Installing the latest version of PowerShell on a Windows Client Host
Overview
This post will demonstrate how to install the latest version of PowerShell on a Windows client host. Before installing the latest version of PowerShell it is important to recognize that a given host can have multiple versions of PowerShell installed. It is possible to have PowerShell 5.x and 7.x running on the same host and in fact, this can be quite handy for certain development situations (backward compatibility). After installing the latest version of PowerShell, it will also be shown how to run the previous version of PowerShell (5.x) or the latest version of PowerShell (7.x)
Installing PowerShell
The Microsoft recommended way to install Powershell on Windows 10 and Windows 11 clients is using winget. Microsoft's documentation, Installing PowerShell on Windows, points out that winget is not available on Windows server variants:
To install the latest version of PowerShell:
1. Launch a PowerShell console window with administrative privileges.
2. Before installing the latest version of PowerShell, displays the $host variable's Version property using the PowerShell console window.
Notice above that the version of PowerShell installed is 5.1.608 which is not the latest as 7x. is the latest.
3. To determine the latest version of PowerShell available for installation, from the PowerShell console invoke, winget search, as follows:
Running the Latest Version of PowerShell
Running a PowerShell 7.x Console
- Click on the Windows key and type pwsh into the search textbox (see below)
- Select "Run as administrator" to invoke a PowerShell 7.x console window running with administrative priveledges:
Getting the latest PowerShell MSI
Visual Studio Code
Installing PowerShell Preview Version
Friday, October 21, 2022
Updating XML documention: XML schema (XSD) validation with XmlSchemaSet
In my never-ending quest to keep Microsoft's documentation, I noted the following in XML schema (XSD) validation with XmlSchemaSet:
The code above subscribes to an event by creating a new delegate instance (new ValidationEventHandler) which was how code was written in for C# 1.0 to 1.1 (2002-2004):
new ValidationEventHandler(
booksSettingsValidationEventHandler);
As of C# 2.0 (released in 2005) there is no need to explicitly create a delegate instance when subscribing to an event:
booksSettingsValidationEventHandler;
I created a fork in Microsoft's documentation (open source on Github.com) and within twenty-four hours Microsoft accepted the change and merged the code:
Saturday, October 15, 2022
C#: Twitter Volume Stream Coding Challenge (Getting Started cURL/Postman)
Overview
I accepted a C# coding challenge targeting Twitter's Volume Streams API (a RESTful web service). This post demonstrates:
- Requirements of the coding challenge
- How to create a Twitter account and a Twitter developer account
- This includes acquiring a bearer token facilitating access to the Twitter API
- Using cUrl and Postman (online) to access Twitter's API
Requirements
The application developed with regard to the coding challenge should generate the following analytics:
- total number of Twitter tweets
- top ten hashtags
Setup
The steps to access Twitter's API are well documented but the basic steps are:
- Create a Twitter account: for readers (like me) who did not have a Twitter account, you can figure it out
- Create a developer account: Developer Account - Twitter Developer
- As part of creating a developer account, Twitter also requires an application to be created and for the application Twitter provides:
- API Key
- API Key Secret
- Bearer Token
The speicfic Twitter API V2 to access for this challenge is Volume Streams:
Sample Code
C#
cURL
Postman
- Require the user to log in to Postman
- Require the user to create a fork: Twitter's Public Workspace for Postman is a Git repo. Each user runs their own fork and this allows users to contribute to the project. This also isolates a user's instance.
- Require the user to create a Postman workspace