Tag: create

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.



Run Azure Container Instances from the Docker CLI

Run Azure Container Instances from the Docker CLI

Earlier Docker announced the partnership with Microsoft to bring support to run Azure Container Instances (ACI) from the Docker CLI. Yesterday, Docker announced and released the first Docker Desktop Edge version (2.3.2), which allows you to try out that new feature. Azure Container Instances (ACI) allow you to run Docker containers on-demand in a managed, serverless Azure environment. Azure Container Instances is a solution for any scenario that can operate in isolated containers, without orchestration.

Run Azure Container Instances from the Docker CLI

To be able to run ACI containers using the Docker CLI, Docker expanded the existing docker context command to support ACI as a new backend. To start using this new feature you will need to run Docker Desktop Edge version 2.3.2 and an Azure subscription. You can create a free Azure account with 12 months of free services, $200 credit, and over 25 services which are always free.

Docker Desktop Azure ACI Integration

Docker Desktop Azure ACI Integration

Now you can start your Docker CLI and login to Azure:

docker login azure

After you are logged in, you will need to create a new ACI context. You can simply use “docker context create aci” command and add your Azure subscription and Resource Group, or the CLI will provide you with an Interactive experience.

docker context create aci myazure

With “docker context ls” you can see the added ACI context.

docker context ls
Docker Desktop CLI create Azure Container Instance ACI Context Integration

Docker Desktop CLI create Azure Container Instance ACI Context Integration

Now you can switch to the newly added ACI context.

docker context use myazure

Now you can start running containers directly on Azure Container Instance using the Docker CLI.

docker run -d -p 80:80 mycontainer

You can also see the running containers using docker ps.

docker ps
Run Azure Container Instances from the Docker CLI

Run Azure Container Instances from the Docker CLI

This will also show you the public IP address of your running container to access it. In my example I used a demo container, however, you can also use your own container which you pushed to a container registry like Docker Hub.

You can also run multi-container applications using Docker Compose. You can find an example for that here.

Try Azure Container Instances from the Docker CLI

This new experience is now available as part of Docker Desktop Edge 2.3.2 . To get started, simply download the latest Edge release or update if you are already on Desktop Edge and create a free Azure account with 12 months of free services, $200 credit, and over 25 services which are always free.

Conclusion

I hope this gives you a short overview of how you can use the Docker CLI to directly run Docker containers in Azure Container Instances (ACI). If you have any questions, feel free to leave a comment.

There are also many other great examples like running Docker Linux containers on Windows, using the Windows Subsystem for Linux 2 (WSL 2).



Visual Studio Code Azure Virtual Machines Extension

Create and Manage Azure VMs from VS Code

With the new Azure Virtual Machines (VMs) extension for Visual Studio Code (VS Code), you can now create and manage Azure VMs directly from VS Code. This is a great new extension if you are working with VS Code and Microsoft Azure. The extension is currently in preview and lets you view, create, delete, start and stop Azure Virtual machines, as well as adding SSH keys to existing Azure VMs.

Get started

To get started with the Azure Virtual Machine extension in Visual Studio Code, simply follow these steps:

  1. Download and install the Azure Virtual Machines extension for Visual Studio Code
  2. Once complete, you’ll see an Azure icon in the Activity Bar
  3. Sign in to your Azure account by clicking Sign in to Azure. If you don’t have an Azure account yet, you can create a free Azure account here.

Free Azure Account

If you don’t have an Azure account yet, you can sign up today for your free Azure account and receive 12 months of free popular services, $200 free credit, and 25+ always free services.

Create an Azure VM in VS Code

You can now create Azure VMs directly from Visual Studio Code. The wizard will ask you for a VM name, username, Azure region, and passphrase.

VS Code creating Azure Virtual Machines

VS Code creating Azure Virtual Machines

This will create an Azure VM Standard D2s V3 (2 CPU Cores & 8 GB of ram) with the image Ubuntu 18.04-LTS. An SSH key will be created, and your SSH Config file (~/.ssh/config) will be updated so you can immediately connect via SSH ($ ssh vm-name) or using the Remote-SSH extension. You can find more information about how you can connect to Azure VM using Visual Studio Code in my blog post.

Azure VM management in VS Code

Azure VM management in VS Code

Having the possibility to manage Azure VMs and connect with them directly within Visual Studio makes working with these tools and Azure much more convenient.

I hope you can go and try out the Azure VM extension for VS Code. If you have any questions, please feel free to leave a comment.



Presenting and Creating Great Tech Demos

How to Create Great Tech Demos and Presentations

I didn’t keep track of the exact number, but I did many presentations at different conferences around the world. Since I am doing a lot of tech presentations and demos, I am always looking at how I can improve and get better. I start to realize that there are a lot of things you need to consider when delivering tech demos during presentations, to make it better for the audience. I started to work on my demos a lot, and I realized that these things also work when you are recording demo videos or screencasts. That is why I came up with the idea to write this blog post with tips and tricks on how you can create great tech demos and presentations.

Create and tell a story, make sure people can see the result 🎬

People have a short attention span, so if you are switching to your tech demo, and in the first couple of seconds, your audience is already lost because they cannot read what is on the screen or they have no context at all, you lost them for good. You need to make sure you create and tell a story, and you show them how to solve a specific challenge. A tech demo is not just good if you can show how you address a particular challenge, but people need to understand it. For example, I have seen many tech demos, that tell you here is the problem, here is the setting to solve it, and done. They didn’t complete the full demo and showed that it is now working. Yes, of course, sometimes showing the setting is enough, but a lot of times you want to show here is the challenge, it is not working now, I do this, and now you can see it is working. This gives attendees a way better experience and understanding of your demo.

Create video recordings of your demos 📽

Live demos are great, but sometimes it is just not possible, or the experience of the attendees isn’t great. For example, if you start a task that takes 5-10 minutes to complete, you don’t want to wait for it to complete as your time is limited in a session. Which leaves you with three options. The first option, you prepare an already finished scenario to jump on like they do in cooking shows. Secondly, you show something else and let the task complete in the background, and jump back to it once it’s done. And the third one, you cut a video before and use your video editing skills to make the waiting time shorter. While option one and two, often work, I realized that jumping away from a specific scenario or using another object which already completed, may confuse people, they lose context and doesn’t give them a great experience. Recording a video can help with that. For example, one of my demos is replicating a virtual machine named VM1, and these can take 30mins to even a couple of hours. I could have prepared a VM2, which would have been already replicated and move on with that one. However, during a lot of presentations, I realized it makes it easier to follow for people if I can use the exact same VM name, during the whole demo.

Creating videos also has an advantage when you run into issues. This can be due to lousy conference Wi-Fi or something just broke out of your control. Even if you plan to do the demo live, it is always great to have a backup, especially if you are doing a demo-heavy presentation, where things build on top of each other.

Resolution and Scaling 💻

You can have the most fabulous demo of all time, but if people can’t see it, it doesn’t matter at all. Rule number one, if you have to ask if people can read it, people can’t read it. So make sure that you are 100% sure that people can see what is going on. My recommendation is, please set your screen resolution to whatever the projector supports. Most of the time, this will be Full HD 1080p (1920×1080) resolution.

Presentation Demo Screen Resolution and Scaling

Presentation Demo Screen Resolution and Scaling

Early in the days, we didn’t have scaling in Windows, so people were using lower resolutions to make everything appear bigger. Guess what, Windows 10 supports scaling, so I usually use Full HD (1920×1080) and 150% scaling, this makes an excellent size to see what is going on the screen but also makes the picture sharp and not blurry. Most of the applications can handle it, and most of the web portals also work the ways they should. That said, I know that not all applications and scenario scale very well. Depending on what you are showing, you need to decide how you want to present it.

Use ZoomIT, and use it wisely 🔎

One of the most excellent tools for presentations is Sysinternals ZoomIT by Mark Russinovich (not PowerShell this time, sorry Jeffrey 😉). ZoomIT is a screen zoom and annotation tool for technical presentations, and as the name says, it lets you zoom. This helps you not just to make things more readable, but also to highlight a specific part of the screen, to show people where they need to focus on.

ZoomIt is a screen zoom and annotation tool for technical presentations that include application demonstrations. ZoomIt runs unobtrusively in the tray and activates with customizable hotkeys to zoom in on an area of the screen, move around while zoomed, and draw on the zoomed image. I wrote ZoomIt to fit my specific needs and use it in all my presentations.

ZoomIt works on all versions of Windows and you can use pen input for ZoomIt drawing on tablet PCs.

ZoomIt

ZoomIt

While ZoomIT is excellent, you need to know how to use it right. Place the mouse where you want to zoom and then zoom in, don’t move the mouse too much after you have zoomed in, you don’t want people to become sick 😵. As you can see, ZoomIT also allows you to do screen annotations, to mark specific things on the screen. Again, use this feature wisely before you start painting on the screen. The great thing about it, you can also use a pen, like the Surface Pen, to draw on your screen.

Font Size and Editor Light Theme 🔠

Okay, one of the many problems I see with many tech presentations is happening when people show code. Coming back to what I said earlier, if you have to ask the audience if they can read it, they can’t read it, so please use a font size they can easily read. Even in Notepad and Terminal, you can easily zoom these days with CTRL + Mousewheel.

Notepad Zoom

Notepad Zoom

If you are showing code in an editor or even in a web portal, a dark theme makes you look cool. However, it is horrible to read. So please help the audience and use a light theme in your editor like Visual Studio Code or in the Azure portal.

Light Theme Editor

Light Theme Editor

By the way, I am not saying that you only should use light PowerPoint slides. Dark PowerPoint slides can be a very powerful tool if they are used right. However, for editors, it is just very simple and way better to view if you are using a light theme. One of my favorite Visual Studio Code themes to present is the PowerShell ISE theme. This theme gives you a simple and light theme, with great color options for syntax highlighting.

Clean up 🧹

You want to make sure that people in your presentation and during your demonstration are focusing on the right thing and don’t get distracted by any clutter. So before your presentation, make sure you clean up:

Close all unnecessary applications

Especially any messengers like Microsoft Teams or Slack, you don’t want to receive any notifications at all during your presentation (Except you are showing Microsoft Teams demos 😉). By shutting down all these applications, you also make sure that you have enough resources like Memory available.

Turn off notifications

Focus assist

Focus assist

In Windows 10, you have a feature called Focus assist, and this allows you to pause all notifications on your PC.

Hide all icons from your desktop

Hide Desktop Icons

Hide Desktop Icons

Yes, there is an option for that! Right-click on your desktop -> View -> Show Desktop Icons.

Browser

Browser

Browser

If you are doing a demo using a browser, make sure your browser is also cleaned up, hide your Favorites Bar, and any additional browser extensions, which might take the focus away.

Taskbar

Keep your taskbar clean, you don’t want people to focus on all the icons there and the program you have installed. You want to make sure there is as little distraction as possible.

Hide System Icons and Time

Windows 10 Turn system icons off

Windows 10 Turn system icons off

This might not always be needed, but if you want to make it cleaner and especially during video recordings, you can also hide the system icons and time. If you are opening the settings app and search for system icons, you can go and hide them.

Full screen

This is a simple one, but if you do a presentation, you don’t want your windows overlapping each other and be confusing, so run your applications in full screen. Exception for this is when you want to show two things in comparison to each other.

Use the Azure Mask browser extension for your Azure demos

If you are doing demos in the Microsoft Azure Portal, you want to have a look at the Azure Mask browser extension. This is a browser extension that will mask GUIDs (such as Subscription IDs), email addresses, keys, and connection strings with a blur. The extension intends to make it easier to do screen recordings without revealing sensitive personal account information that may show up on the screen. It will only run and apply against Azure portal URLs. It’s available in Chrome, Firefox, and also works with the new Microsoft Edge (Chromium).

Virtual Desktops to switch to your tech demo 💻

I am a huge fan of the Virtual Desktop feature in Windows 10. This basically gives you unlimited desktops on your Windows 10 PC, which is excellent for productivity. But I am also using Virtual Desktops during presentations, for example, for switching between the PowerPoint deck to a demo. One the first desktop, I keep my PowerPoint presentation in full screen open, and with CONTROL + WINDOWS + ARROW RIGHT/LEFT, I can switch to other desktops where I, for example, already have my demos ready. You can create new Virtual Desktops by pressing WINDOWS + TAB. This makes switching between PowerPoint and demonstrations, less messy.

Virtual Desktop

Virtual Desktop

If you are presenting somewhere, where you can plug in two devices, you can also use the display switch to switch from your presentation machine to your secondary demo machine, which will have a similar effect. However, a lot of smaller events, don’t have that setup. By using the Virtual Desktops feature, you can clean up the process of switching to different technical demonstrations.

Change Desktop Backgrounds and console colors 🎨

Use different Colors

Use different Colors

If you do a presentation with multiple systems or consoles, you want to make sure people can follow on which system you are working. For example, if you have two different systems deployed to servers, you want to make sure people can easily identify which server runs which application. For example, you can change the color of the terminal or desktop background of VM1 to blue and the one of VM2 to red. If you are working with Windows, you might also use Sysinternals BgInfo, to write the name of the system on the desktop wallpaper.

The mighty Mouse pointer 🖱

Mouse Pointer

Mouse Pointer

If you want to explain something and point to something on the screen, the mouse cursor is a natural option. However, you can also do a lot of damage by using it wrong. First, make sure people can see the mouse pointer. In Windows 10, you can change the size and color of the mouse pointer, so people can easily identify it on the screen. Next, don’t move it fast and don’t go crazy. Move the mouse cursor slow and don’t try to circle things or jump around the screen with it; people will go nuts.

In many cases, it is better to use a tool like ZoomIT, to annotate on the screen.

Laser pointer in PowerPoint 👉

PowerPoint Laser Pointer

PowerPoint Laser Pointer

Many people use PowerPoint for their presentations. However, not many people know that PowerPoint can be an excellent presentation tool. It comes with a lot of features people don’t even know about, and with many of them, it is with any tool in the world; if you are using it wrong, it will not help you at all. One of the tools I want to highlight is the laser point feature in PowerPoint. If you are a presenter, you might have these remote presenters with a laser pointer on it, where you can point on a wall or projected screen. However, in many cases, that is not a good idea. Often the laser pointer is too small for people to see it or in some locations, you have multiple projectors, and you can’t point at all of them at once. PowerPoint can help you with that. You can use a simple on-screen laser pointer to highlight parts of your slides. This comes handy when you show a large technical diagram, which we often try to avoid, but in some cases, it is necessary.

Get prepared 🔧

To deliver great demos, you will need to practice them. First of all, you need to make sure that they actually work, but also that the timing is right. No one wants to wait and watch at the screen for five minutes until something has completed. I usually run through the demo at least twice before my presentations, to make sure that the demo also works multiple times. I usually also run through it a couple of minutes or hours before I go on stage. Especially with demos running in the cloud, I want to make sure that they are still working. It is not just about cloud technologies that can change fast; for example, I also saw software and container images expire.

What if something goes wrong? 👻

Even if you did prepare like crazy, there can always something go wrong. Don’t worry, people understand that things can break. As long as you are prepared, handle it the right way and have a backup plan, you will be fine. If something doesn’t work, you can try to troubleshoot it quickly. But don’t spend too much time on it and move on to the next one, because the audience doesn’t want to see you troubleshooting for minutes. In some cases, the audience can’t even see or doesn’t even realize that the demo didn’t work. In that case, don’t point it out, just move on if the demo is not essential to your presentation.

Conclusion to create Tech Demos and Presentations 😎

I hope you enjoyed my tips on how you can create great technical (tech) demonstrations (demos) and presentations. Let me know what your favorite tips and tricks for great tech demos are!



PowerShell New-Guid

Create GUID on Windows using PowerShell

For many different scenarios, you need to create or generate a new GUID on Windows. With PowerShell, you can simply create and generate a new GUID on Windows, but also on Linux.

Create GUID using .NET

Before we had this cmdlet we had to use the .NET command to create a new GUID:

[guid]::newguid()

Create and generate GUID on Windows using PowerShell

PowerShell version 5 brings a lot of new cmdlets that make our lives easier and our code cleaner. One of them is the New-GUID cmdlet, which allows you to easily create a new GUID using PowerShell on Windows. Now with PowerShell 5 or higher, we can use simply the new cmdlet:

New-Guid

You can read more about the cmdlet here on Microsoft Docs.

Conclusion

I hope this does the trick for you and helps you with PowerShell going forward. Let me know in the comments if you have any questions. Also, check out my blog post on how to install and update PowerShell 7.



Microsoft WebMatrix and Microsoft WebPlatform Installer

Microsoft WebMatrixFor a project at KTSI we needed a platform to quick deploy PHP and MySQL applications. There are a lot of solutions out there in the web, for example XAMPP. After testing some options I had a closer look at the Microsoft WebPlatform Installer and Microsoft WebMatrix. Those two tools do exactly what I need. With the WebPlatform Installer you can easily install a local instance of IIS Express with ASP.NET, PHP, MSSQL and MySQL support with in 5-10 minutes.

But the coolest tool in my opinion is WebMatrix. Webmatrix lets developers create, manage and deploy Web Applications very very easy. And if you need to to more Webmatrix lets you also work with Visual Studio on the same project.



Powershell: Working with XML part 2

Powershell Header

After my first post (Powershell: Parsing XML part 1) about working with XML and Powershell, I have create this second post which describes how to create a XML file, Add content to the XML file, remove content from the XML file and save the XML objects as a file.

While I was writing a script which communicates with a webserver, I realized that I need some error handling if the server can not anwser a request from my script. For example if the webserver is down or has to much load.

I created a little retry part (Powershell: Simple retry logic) which retries several times. But if the Server is down for several hours or days your script hangs in a retry loop. Obviously this cant be the solution. After a little bit of thinking a decided to write the data, which I was trying to send, down in a XML file. And the next time the script runs it reads the XML file and tries to send the data again.

Thats the story behind my idea for saving data in a XML file.

Creating a XML object

<pre lang="xml">$FruitList = "&lt;Box&gt;
&lt;Fruit&gt;
&lt;Name&gt;Banana&lt;/Name&gt;
&lt;Color&gt;yellow&lt;/Color&gt;
&lt;/Fruit&gt;
&lt;/Box&gt;"

Save a XML object as a XML file

$FruitList.Save("./myfruitlist.xml")

XML:

<Box>
	<Fruit>
		<Name>Banana</Name>
		<Color>yellow</Color>
	</Fruit>
</Box>

Open a saved XML file

<pre lang="xml">$FruitList = Get-Content ./myfruitlist.xml

Add data to XML object and save it in a XML file

# Copy Object from Banana
[Object]$CopyFruit = FruitList.Box.Fruit | Where-Object {$_.Name -eq "Banana"}
$NewFruit = $CopyFruit.Clone()
# Add Fruit to new Object
$NewFruit.Name = "Apple"
$NewFruit.Color = "green"
# Add Fruit to XML Object
$FruitList.Box.AppendChild($NewFruit)
#Save to XML object ot XML file
$FruitList.Save("./myfruitlist.xml")

XML:

<Box>
	<Fruit>
		<Name>Banana</Name>
		<Color>yellow</Color>
	</Fruit>
	<Fruit>
		<Name>Apple</Name>
		<Color>green</Color>
	</Fruit>
</Box>

Change data from XML Object and save it as XML file

# Change Apple Color
$FruitList.Box.Fruit | Where-Object {$_.Name -eq "Apple"} | ForEach-Object { $_.Color = "red" }
#Save to XML object ot XML file
$FruitList.Save("./myfruitlist.xml")

XML:

<Box>
	<Fruit>
		<Name>Banana</Name>
		<Color>yellow</Color>
	</Fruit>
	<Fruit>
		<Name>Apple</Name>
		<Color>red</Color>
	</Fruit>
</Box>

Remove data from XML Object and save it as XML file

# Remove Banana from Object
$RemoveFruit = $FruitList.Box.Fruit | Where-Object {$_.Name -eq "Banana"}
$FruitList.Box.RemoveChild($RemoveFruit)
#Save to XML object ot XML file
$FruitList.Save("./myfruitlist.xml")

XML:

<Box>
	<Fruit>
		<Name>Apple</Name>
		<Color>green</Color>
	</Fruit>
</Box>