Tag: PowerShell

How to Manage Hyper-V VM Checkpoints with PowerShell

How to Manage Hyper-V VM Checkpoints with PowerShell

In this blog post we are going to have a look at how you can create, manage, apply, and remove VM Checkpoints in Hyper-V using PowerShell. Hyper-V virtual machine (VM) checkpoints are one of the great benefits of virtualization. Before Windows Server 2012 R2, they were known as virtual machine snapshots. VM Checkpoints in Hyper-V allow you to save the system state of a VM to a specific time and then revert back to that state if you need to. This is great if you are testing software and configuration changes, or if you have a demo environment, which you want to reset.

Hyper-V VM Checkpoint Types

Before we got on how you can manage Hyper-V VM Checkpoints with PowerShell, let me first explain the two different types. Since Windows Server 2016 and Windows 10, Hyper-V includes two types of checkpoints, Standard Checkpoints, and Production Checkpoints.

  • Standard Checkpoints: takes a snapshot of the virtual machine and virtual machine memory state at the time the checkpoint is initiated. A snapshot is not a full backup and can cause data consistency issues with systems that replicate data between different nodes such as Active Directory. Hyper-V only offered standard checkpoints (formerly called snapshots) prior to Windows 10.
  • Production Checkpoints: uses Volume Shadow Copy Service or File System Freeze on a Linux virtual machine to create a data-consistent backup of the virtual machine. No snapshot of the virtual machine memory state is taken.

You can set up these settings in Hyper-V Manager or in PowerShell.

Hyper-V VM Checkpoint Types

Hyper-V VM Checkpoint Types

If you are using PowerShell to configure Checkpoints for virtual machines these commands may help you.

Configure and set VM for Standard Checkpoints

Set-VM -Name "Windows10" -CheckpointType Standard

Set VM to Production Checkpoints, if the production checkpoint fails a Standard Checkpoint is created

 Set-VM -Name "Windows10" -CheckpointType Production

Set VM to only use Production Checkpoints

 Set-VM -Name "Windows10" -CheckpointType ProductionOnly

Disable VM Checkpoints for the Hyper-V virtual machine

 Set-VM -Name "Windows10" -CheckpointType Disabled

Managing Hyper-V VM Checkpoints using PowerShell

Create VM Checkpoints

You can create a new VM Checkpoint with PowerShell, you can round the following command:

Checkpoint-VM -Name "Windows10"

You can find more on the cmdlet on Microsoft Docs.

You can list the VM Checkpoints of a Hyper-V VM:

Get-VMCheckpoint -VMName "Windows10"
How to Manage Hyper-V VM Checkpoints with PowerShell

How to Manage Hyper-V VM Checkpoints with PowerShell

Applying Hyper-V VM checkpoints using PowerShell

If you want to revert your virtual machine state to a previous point-in-time, you can apply an existing checkpoint, using the following PowerShell command.

Restore-VMCheckpoint -Name "checkpoint name" -VMName "Windows10" -Confirm:$false

You can find more information about the cmdlet here.

Renaming checkpoints

To rename a checkpoint you can use the following command

Rename-VMCheckpoint -VMName "Windows10" -Name "Checkpointname" -NewName "MyNewCheckpointName"

Deleting checkpoints

You can also delete or remove a Hyper-V VM checkpoint with the following PowerShell command. This will merge the .avhdx files in the background.

Remove-VMCheckpoint -VMName "Windows10" -Name "Checkpointname"

Conclusion

I hope this blog post gives you a great overview on how you can manage, apply, restore, and remove Hyper-V VM Checkpoints using PowerShell. You can learn more about Hyper-V virtual machine checkpoints on Microsoft Docs. If you have any questions, feel free to leave a comment.



Windows 10 on ARM PowerShell 7 Windows Terminal ARM64

How to Install PowerShell 7 on Windows 10 on ARM

As you know I am running Surface Pro X as my daily driver, which comes with Windows 10 on ARM. With the release of PowerShell 7.0.2, I want to show you how you can install PowerShell 7 on Windows 10 on ARM and the Surface Pro X. The ARM64 release is still marked as a preview. The PowerShell team is working on bringing PowerShell 7 to the Microsoft Store, which will create a much ns smoother experience. However, if you are like me and want to try out PowerShell 7 on your Surface Pro X today, you can do that.

Windows 10 on ARM runs on PCs powered by ARM processors, like the Surface Pro X. And if you want to know more about what’s new in PowerShell 7, check out my blog post. ℹ

How to Install PowerShell 7 on Windows 10 on ARM and the Surface Pro X

With the release 7.0.2 of PowerShell 7, the ARM64 build arrived again. You can download a new .msix file with an ARM64 version from the GitHub release page.

PowerShell 7 on Windows 10 on ARM Surface Pro X

PowerShell 7 on Windows 10 on ARM Surface Pro X

If your Windows 10 machine has developer mode enabled, you can now add the MSIX package to your Windows installation. You can use the Add-AppxPackage to add the .msix package.

Add-AppxPackage .\PowerShell-7.0.2-win-arm64.msix

After that, you can find PowerShell 7 in your start menu, or directly in the new Windows Terminal.

Windows 10 on ARM PowerShell 7 Windows Terminal ARM64

Windows 10 on ARM PowerShell 7 Windows Terminal ARM64

Conclusion

I hope this helped you an explained to you how you can install PowerShell 7 on Windows 10 on ARM. If you want to know more about installing and updating PowerShell 7, check out my blog post. And if you need more information, here is the official documentation on Microsoft Docs.

You can find more information about what’s new in PowerShell 7 on my blog. If you have any questions, please let me know in the comments.



How to Install a Windows Server Container Host

How to Install a Windows Server Container Host

In this blog post, I want to quickly guide you through how you can install a Windows Server Container Host running Docker. This guide will help you set up, install, and run Windows Containers on Windows Server. In my example, I will install a container host on a Windows Server, version 2004, which is a Semi-Annual Channel (SAC) release. Windows Server SAC releases are released twice a year and are optimized for containers. In the Windows Server, version 2004 release, the team continued improving fundamentals for the core container platform such as performance and reliability.

If you want to learn more about the differences of Windows Server Semi-Annual Channel (SAC) vs. Long-Term Servicing Channel (LTSC), check out my blog post.

Requirements

  • A virtual or physical server running Windows Server 2016 or higher (Also including Semi-Annual Channel (SAC) releases. In my blog post, I will use the latest available releases and run the latest Windows Server SAC release, which offers the latest enhancements on the container host.
  • You can also use the Windows Server 2019 LTSC version

Set up and install the Windows Server Container Host

Since I am using the latest SAC release of Windows Server, the server is available as Windows Server Core only. This means I am going to use a tool called “sconfig” to set up my server for the first time. Of course, you can also use existing methods like unattend.xml files or PowerShell scripts to set up your server.

Windows Server Core

Windows Server Core

With sconfig, you can run all the simple configuration tasks to configure your Windows Server.

Windows Server SCONFIG

Windows Server SCONFIG

After the Windows Server is configured and patched, we can now install Docker, which is required to work with Windows containers. Docker consists of the Docker Engine and the Docker client. You can simply install Docker on Windows Server using the following commands.

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
Install Docker on Windows Server

Install Docker on Windows Server

After these commands, you will need to restart the server.

Restart-Computer -Force

If you want to learn more about installing Docker on Windows Server, check out Microsoft Docs.

Run Windows Container Docker Images on Windows Server

Run Windows Container Docker Images on Windows Server

Now you can start pulling your docker container images to your Windows Server. I will use the latest Windows Container images, which came with Windows Server, version 2004. You can read more about the improved container images here.

docker pull mcr.microsoft.com/windows/servercore:2004 
docker pull mcr.microsoft.com/windows/nanoserver:2004 
docker pull mcr.microsoft.com/windows:2004

You can now use the docker client to manage your containers on your Windows Server, or you can also use the new Windows Admin Center Container extension, which was released a couple of weeks ago.

Manage Windows Server Containers with Windows Admin Center

Manage Windows Server Containers with Windows Admin Center

And yes, if you have a standalone Windows Server Core, you can also directly install Windows Admin Center on your Windows Server Core.

Conclusion

I hope this blog post gives you a great overview of how to install and set up a Windows Server container host. If you have any questions, feel free to leave a comment.



List Azure Arc Machines Agent Version in Azure Cloud Shell

Get the Azure Connected Machine Agent (Azcmagent) Version

Azure Arc Enabled Servers just got another update enabling extensions. This also includes an updated version of the Azure Arc agent or Azure Connected Machine Agent (Azcmagent). To get an overview of what Azure Arc Azure Connected Machine Agent is installed on your machines, you can use several different ways. In this blog post, we are going to have a look at how you can get installed Azure Connected Machine Agent (Azcmagent) version for Azure Arc Enabled Servers.

On the Azure Arc Enabled Server

If you want to check the Azure Connected Machine Agent (Azcmagent) version directly on your Azure Arc enabled server, you can simply run the following command in PowerShell.

azcmagent version

This will list the installed version.

Azure Connected Machine Agent azcmagent Version

Azure Connected Machine Agent azcmagent Version

In the Azure Portal

You can also see the agent version in the Azure Portal. If you browse to your Azure Arc Enabled Server, you can find the agent version on the overview page.

Azure Portal - Azure Arc Enabled Server

Azure Portal – Azure Arc Enabled Server

However, if you want to see the agent version for your Azure Arc enabled servers at scale, this isn’t an ideal option.

List Azure Connected Machine Agent (Azcmagent) version for all Azure Arc machines

If you want to see the installed Azure Connected Machine Agent (Azcmagent) version for all your Azure Arce enabled servers at scale, you can use Azure Resource Graph Queries.

This query lists all the Azure Arc enabled machines and shows the installed agent version.

List Azure Arc Machines with Agent Version

List Azure Arc Machines with Agent Version

You can run the following query in the Azure Resource Graph Explorer in the Azure Portal.

 resources
| where type == "microsoft.hybridcompute/machines"
| extend agentversion = properties.agentVersion
| project name, agentversion, location, resourceGroup, subscriptionId
| order by name

You can also run the query directly in Azure Cloud Shell or on your local machine using Azure PowerShell or the Azure CLI.

List Azure Arc Machines Agent Version in Azure Cloud Shell

List Agent Version in Azure Cloud Shell

Azure CLI

az graph query -q "Resources | where type =~ 'microsoft.hybridcompute/machines' | extend agentversion = properties.agentVersion | project name, agentversion, location, resourceGroup, subscriptionId"

Azure PowerShell

Search-AzGraph -Query "Resources | where type =~ 'microsoft.hybridcompute/machines' | extend agentversion = properties.agentVersion | project name, agentversion, location, resourceGroup, subscriptionId"

If you need an overview of what Azure Connected Machine Agents we have installed and which versions do exist in our environment, you can just use the following Azure Resource Graph query.

Azure Resource Graph Explorer Chart - Azure Arc Server Agent Version

Azure Resource Graph Explorer Chart

Azure Resource Graph Explorer

 resources
| where type == "microsoft.hybridcompute/machines"
| extend agentversion = properties.agentVersion
| summarize count() by tostring(agentversion)

Azure PowerShell

Search-AzGraph -Query "Resources | where type =~ 'microsoft.hybridcompute/machines' | summarize count() by tostring(properties.agentVersion)"

Azure CLI

az graph query -q "Resources | where type =~ 'microsoft.hybridcompute/machines' | summarize count() by tostring(properties.agentVersion)"

Conclusion

I hope this blog post provides you with a short overview of how you can make sure which agent versions you have installed on your Azure Arc enabled servers. To learn more about Azure Arc for servers, check out Microsoft Docs. If you have any questions, feel free to leave a comment.



Windows Terminal Color Schemes -Themes

My Windows Terminal Color Schemes

The Windows Terminal became generally available at the Microsoft Build 2020 virtual conference a couple of weeks ago. I already blogged about how you can customize your Windows Terminal settings and shared my settings.json file. Many people asked me about the different Windows Terminal Color Schemes I use. So I thought a blog post would be a good way of sharing my Windows Terminal Schemes.

Windows Terminal 1.0 was released on May 19, you can find more documentation here on Microsoft Docs.

I already shared a couple of blog posts on how you can customize your Windows Terminal experience:

My Windows Terminal Color Schemes

Here is my Windows Terminal Color Schemes. Since I use the acrylic effect, I post a picture when the Windows Terminal window is active and one where it is inactive.

Vibrant Tom

Vibrant Tom

Vibrant Tom

Vibrant Tom Inactive

Vibrant Tom Inactive

This one I use for my default shell (PowerShell 7).

{
            // Color Scheme: VibrantTom
            "background" : "#16171D",
            "black" : "#878787",
            "blue" : "#44B4CC",
            "brightBlack" : "#E373C8",
            "brightBlue" : "#0000FF",
            "brightCyan" : "#19D1D8",
            "brightGreen" : "#81EC0D",
            "brightPurple" : "#FF00FF",
            "brightRed" : "#FF0000",
            "brightWhite" : "#E5E5E5",
            "brightYellow" : "#FFD93D",
            "cyan" : "#19D1D8",
            "foreground" : "#FFFFFF",
            "green" : "#CCFF04",
            "name" : "VibrantTom",
            "purple" : "#9933CC",
            "red" : "#FF6600",
            "white" : "#F5F5F5",
            "yellow" : "#FFD93D"
        },

Windows PowerShell Tom

Windows PowerShell Tom

Windows PowerShell Tom

Windows PowerShell Tom Inactive

Windows PowerShell Tom Inactive

{
            // Color Scheme: PowerShellTom
            "background" : "#012456",
            "black" : "#000000",
            "blue" : "#0000ff",
            "brightBlack" : "#AAAAAA",
            "brightBlue" : "#44B4CC",
            "brightCyan" : "#19D1D8",
            "brightGreen" : "#81EC0D",
            "brightPurple" : "#FF00FF",
            "brightRed" : "#FF0000",
            "brightWhite" : "#E5E5E5",
            "brightYellow" : "#FFD93D",
            "cyan" : "#19D1D8",
            "foreground" : "#FFFFFF",
            "green" : "#00ff00",
            "name" : "PowerShellTom",
            "purple" : "#9933CC",
            "red" : "#FF6600",
            "white" : "#F5F5F5",
            "yellow" : "#FFD93D"
        },

Retro Command Prompt

Retro Command Prompt

Retro Command Prompt

Dracula

Dracula

Dracula

Dracula Inactive

Dracula Inactive

{
            // Color Scheme: Dracula
            "background" : "#282A36",
            "black" : "#21222C",
            "blue" : "#BD93F9",
            "brightBlack" : "#6272A4",
            "brightBlue" : "#D6ACFF",
            "brightCyan" : "#A4FFFF",
            "brightGreen" : "#69FF94",
            "brightPurple" : "#FF92DF",
            "brightRed" : "#FF6E6E",
            "brightWhite" : "#FFFFFF",
            "brightYellow" : "#FFFFA5",
            "cyan" : "#8BE9FD",
            "foreground" : "#F8F8F2",
            "green" : "#50FA7B",
            "name" : "Dracula",
            "purple" : "#FF79C6",
            "red" : "#FF5555",
            "white" : "#F8F8F2",
            "yellow" : "#F1FA8C"
        },

Ubuntu Legit

UbuntuLegit

UbuntuLegit

UbuntuLegit Inactive

UbuntuLegit Inactive

This one I saw first at Scott Hanselman’s blog. This one I use for my Windows Subsystem for Linux 2 (WSL 2) running Ubuntu.

{
            // Color Scheme: UbuntuLegit
            "background":  "#2C001E",
            "black":  "#4E9A06",
            "blue":  "#3465A4",
            "brightBlack":  "#555753",
            "brightBlue":  "#729FCF",
            "brightCyan":  "#34E2E2",
            "brightGreen":  "#8AE234",
            "brightPurple":  "#AD7FA8",
            "brightRed":  "#EF2929",
            "brightWhite":  "#EEEEEE",
            "brightYellow":  "#FCE94F",
            "cyan":  "#06989A",
            "foreground":  "#EEEEEE",
            "green":  "#300A24",
            "name":  "UbuntuLegit",
            "purple":  "#75507B",
            "red":  "#CC0000",
            "white":  "#D3D7CF",
            "yellow":  "#C4A000"
        },

Vibrant Tom Light

Vibrant Tom Light

Vibrant Tom Light

Vibrant Tom Light Inactive

Vibrant Tom Light Inactive

This one I am still working on. I am not 100 percent happy, so let me know if you have any ideas.

{
            // Color Scheme: VibrantInkTom Light
            "background" : "#EEEEEE",
            "black" : "#878787",
            "blue" : "#44B4CC",
            "brightBlack" : "#595e68",
            "brightBlue" : "#0000FF",
            "brightCyan" : "#19D1D8",
            "brightGreen" : "#3f953a",
            "brightPurple" : "#FF00FF",
            "brightRed" : "#FF0000",
            "brightWhite" : "#E5E5E5",
            "brightYellow" : "#FF6600",
            "cyan" : "#44B4CC",
            "foreground" : "#16171D",
            "green" : "#3f953a",
            "name" : "VibrantTomLight",
            "purple" : "#9933CC",
            "red" : "#FF6600",
            "white" : "#F5F5F5",
            "yellow" : "#FFD93D"
        },

Conclusion

I hope this blog post helps you to customize your Windows Terminal and I hope you like my Windows Terminal color schemes. Let me know in the comments which Windows Terminal Theme you like best.



How to Change the Windows Terminal Default Shell Profile

How to Change the Windows Terminal Default Shell Profile

The Windows Terminal is now generally available as version 1.0. I already shared a blog post on how to customize the Windows Terminal and shared my personal settings.json file with a lot of different examples, like the integration of PowerShell Remoting, SSH Remoting, changing the background image and much more. One question I got is, how to change the Windows Terminal default shell or default profile from PowerShell to the Windows Subsystem for Linux (WSL) or the command line (cmd).

By default, the Windows Terminal takes PowerShell 7 (if it is installed) as the primary shell when you open the Windows Terminal. However, if you want to change that you can simply configure the default shell in Windows Terminal, in the settings.json file. On the top, you can find the “defaultProfile” setting with a GUID

{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
....
}

The GUID is the GUID of your profile. For example, if you want to change it to cmd, you can use the following GUID “0caa0dad-35be-5f56-a8ff-afceeeaa6101”.

Windows Terminal Default Profile - Default Shell

Windows Terminal settings.json

I hope this blog post gives you a look on how to switch the default shell in Windows Terminal. I recommend that you check out my other blog post where I share even more details on how to customize the Windows Terminal. You can also read the full announcement blog for the version 1.0 here or check out the documentation on Microsoft Docs.

If you have any questions, feel free to leave a comment.



Install WinGet - Windows Package Manager

How to Install WinGet Windows Package Manager

For a long time, people have been asking for a package manager on Windows. Today at Microsoft Build, Microsoft announced the preview of the Windows Package Manager called WinGet. A package manager can help you to save time and quickly install software and tools on to your machine. Developers and IT Pros have wanted a native package manager in Windows for a long time and with WinGet, you will get that.

You can read more about the Windows Package Manager Preview announcement here.

How to install WinGet Windows Package Manager

The Windows Package Manager is currently in preview. To install the preview of Windows Package Manager, you basically have two options. Since WinGet is open source, you can clone, build, run, and test the code from the GitHub repository (https://github.com/microsoft/winget-cli). You can also become a Windows Insider an join the Windows Package Manager Insider program by sending your Microsoft Account (MSA) to [email protected] and request to be included in the preview.

App Installer in the Windows Store

App Installer in the Windows Store

After you have joined either Insider program, head over to the Microsoft Store and get the App Installer. The Windows Package manager will be available after you get the update.

How to install software using the Windows Package Manager

Now you can start using winget in the Windows Terminal, Windows command line, or PowerShell. The command line client “winget.exe” is already pre-configured to point to the Microsoft community repository.

winget install Windows Package Manager

winget install Windows Package Manager

Search for available packages

winget search APPLICATION

Display information about the packages

winget show APPLICATION

Install packages

winget install APPLICATION

Manage sources for packages

winget source (add/list/update/remove/reset)

Here is a quick look at some of the packages in the Microsoft Community repository.

winget show

winget show

Contribute and Feedback

Since the Windows Package Manager is open source, you can also contribute by sharing your feedback and suggestions on GitHub.

More information

You can find more information about the WinGet Windows Package Manager check out the Microsoft Docs and the preview announcement blog post. If you have any questions, feel free to leave a comment below.