Video: Automatically Migrate your Scripts from AzureRM to the Az PowerShell Module

As many of you know, I’m a Senior Content Developer for Azure PowerShell at Microsoft. Today we announced the Az.Tools.Migration PowerShell module which is a toolkit for automatically migrating your PowerShell scripts and modules from AzureRM to the Az PowerShell module. The video shown below demonstrates how to use this module: For more information, see the official announcement that I wrote on the Microsoft Tech Community blog site. In addition to the PowerShell module, there is also a VS Code extension for performing the migration.

How many Services does Microsoft Azure Offer?

I’ve recently wondered how many service offerings Azure has. I’ve read anywhere from 150 to 600 and I even went so far as to ask an Azure Product Manager but still didn’t receive a clear answer. What I did find out is that Microsoft maintains an Azure services directory on their Azure products website. I figured that was a good place to start looking and while the website is informative, it didn’t provide a count of the service offerings.

AzureRM PowerShell Commands that Don’t Exist when Enabling Compatibility Aliases in the Az Module

On Twitter, I recently asked if anyone was still using the AzureRM PowerShell module and what was keeping them from transitioning to the Az PowerShell module. One of the responses I received was due to the amount of work and time invested in scripts based on the AzureRM module. The Az PowerShell module includes compatibility aliases for scripts written using the AzureRM PowerShell module. The compatibility aliases are enabled using the Enable-AzureRmAlias command.

How to Install the Azure Az PowerShell Module

The Az PowerShell module was released in December of 2018 and is now the recommended module for managing Microsoft Azure. AzureRM is the previous PowerShell module for managing Azure which has been deprecated but will continue to be supported until December of 2020. Windows PowerShell 5.1, PowerShell Core 6, PowerShell 7, and higher are supported by the Az PowerShell module. Windows 10 version 1607 and higher has Windows PowerShell 5.1 installed by default.

Setting Dependencies on the Azure PowerShell Module

I recently saw a tweet from Joel Bennett about the Az (Azure) PowerShell module being nothing more than an empty module that imports all of the modules for each Azure product. I decided to investigate. Get-Content -Path (Get-Module -Name az).Path | Select-String -SimpleMatch 'Import-Module' Joel’s statement is 100% accurate. Off-Topic: The searched for term is highlighted in each result when the previous command is run in PowerShell 7.

Initial Setup of a CanaKit Raspberry Pi 4 4GB Starter Kit

For Christmas, I received a CanaKit Raspberry Pi 4 4GB Starter Kit with Clear Case (4GB RAM). The kit contains everything you need minus an HDMI monitor and USB keyboard/mouse. It includes the Raspberry Pi 4b (I received the one with 4GB of RAM, but it’s also available with 1GB or 2GB of RAM), heatsinks, a power supply with a removable inline switch, case (I ordered the one with a clear case), case fan, micro HDMI to HDMI cable, micro SD card with NOOBS preinstalled (I ordered the one with a 32GB card), and a USB micro SD card reader in case you need to reload NOOBS on the SD card.

Using PowerShell to Retrieve Exchange Mailbox Statistics for Office 365 Migrations

Recently, I’ve been working on trying to finish up a migration from Exchange Server 2010 to Office 365. There are potentially numerous mailboxes that aren’t used and those won’t be migrated to Office 365 because there’s no sense in paying for licensing for them. How do you determine what mailboxes are in use? First, use implicit remoting to load the Exchange cmdlets locally. Years ago, I would install the Exchange cmdlets locally, but it was brought to my attention that it’s unsupported, at least according to this article: Directly Loading Exchange 2010 or 2013 SnapIn Is Not Supported.

PowerShell Productivity Hacks: How I use Get-Command

If you’ve been using PowerShell for very long at all, then you should already be familiar with Get-Command and Get-Help. While I like to say that Get-Command is for finding commands and Get-Help is for learning how to use those commands once you’ve found them, there is overlap between these two commands depending on how you use them. I believe in following the best practice of not using aliases or positional parameters in any code that I save or share with others, but in this blog article, I’m going to show how things work in the real world.

Parallel and ThrottleLimit Parameters added to ForEach-Object in PowerShell 7 Preview 3

Preview 3 of PowerShell 7 was released yesterday. It can be downloaded from the PowerShell repository on GitHub. Be sure to choose the preview version for the appropriate operating system. It should go without saying that anything with preview in its name should NOT be installed on a mission-critical production system. The examples shown in this blog article are being run on a system running Windows 10 (x64). Your mileage may vary with other operating systems and/or versions.

PowerShell Function to Find Parameter Aliases

While sitting through Jeff Hicks' Advanced PowerShell Scripting Workshop at PowerShell on the River in Chattanooga today, he mentioned there being a “Cn” alias for the ComputerName parameter of commands in PowerShell. I’ve previously written a one-liner to find parameter aliases and at one time Microsoft had starting adding parameter aliases to the help for commands as referenced in that same blog article, but it appears that they’ve discontinued adding them to the help and removed the ones they previously added to it.

Where are Untitled Tabs in VSCode Saved on a Windows System?

Ever wonder how VSCode (Visual Studio Code) maintains those untitled tabs between sessions? They’re stored as files underneath your user’s profile in appdata on Windows based systems as shown in the following example. Get-ChildItem -Path $env:APPDATA\Code\Backups\*\untitled -Recurse The previous command could be piped to Get-Content to view the contents of all of code in the open untitled tabs of VSCode. You could also use Select-String to find something specific. I can see that three of my open tabs contain ‘mikefrobbins’.

What’s in your PowerShell $PSDefaultParameterValues Preference Variable?

The $PSDefaultParameterValues preference variable, which was introduced in Windows PowerShell version 3.0, provides a mechanism for specifying default values for parameters. I thought I would share what I’ve added to mine and ask the community to share theirs. $PSDefaultParameterValues = @{ 'Out-Default:OutVariable' = 'LastResult' 'Out-File:Encoding' = 'utf8' 'Export-Csv:NoTypeInformation' = $true 'ConvertTo-Csv:NoTypeInformation' = $true 'Receive-Job:Keep' = $true 'Install-Module:AllowClobber' = $true 'Install-Module:Force' = $true 'Install-Module:SkipPublisherCheck' = $true } The first one in the list ('Out-Default:OutVariable' = 'LastResult') is one I picked up from Joel Bennett to store the results of the last command in a variable named $LastResult.

Install PowerShell 7 with Jeff Hicks’ PSReleaseTools Module

PowerShell version 7 is currently in preview and while it can be installed on Windows, Linux, and macOS, the examples shown in this blog article focus on installing it on a Windows based system, specifically Windows 10 using Windows PowerShell version 5 or higher which ships by default with Windows 10. Your mileage may vary with other operating systems, other versions of Windows, and/or other versions of Windows PowerShell. The easiest way that I’ve found to install the preview of PowerShell version 7 is to first install Jeff Hicks' PSReleaseTools PowerShell module from the PowerShell Gallery using Windows PowerShell.

Import a Hyper-V Virtual Machine with PowerShell

I recently ran into a problem where an exported VM from Windows Server 2016 running Hyper-V wasn’t able to be imported on Windows Server 2019 running Hyper-V. When attempting to perform the import, the GUI stated “No virtual machines files found” as shown in the following image. This problem may have been due to using Hyper-V manager on a remote system running Windows Server 2012 R2, although the same system was used for the export.

Determine the Generation of a Hyper-V VM with PowerShell

Ever need to determine what generation all of the virtual machines are on your Hyper-V servers? This is simple using the Get-VM command that installs as part of the Hyper-V module for Windows PowerShell. Get-WindowsOptionalFeature -FeatureName *hyper*powershell -Online While the previous command will work on both clients and servers, the following command could also be used on a Windows server. Get-WindowsFeature -Name *hyper*powershell The generation of the VM is one of the properties from the results of Get-VM.

Mitigating BlueKeep with PowerShell

When it comes to security, most people normally approach it at one extreme or the other. Some people do nothing and don’t worry about it. All I can say for those folks is good luck with that and I hope your resume is updated. Others go into full blown panic mode, especially those who don’t take the time to understand vulnerabilities. Many security folks and articles on the Internet don’t help much either because they often blow things out of proportion which puts many of the people in the second category into panic mode.