Blog Post

#PowershellBasics: Warnings and how to hide them.

,

One of my favorite parts of having a new job is that I learn a ton. (No really, my brain feels like there is a ton of information just sitting on it and compressing it into a little brain shaped ball.) Right now I’m doing a lot of Powershell and since Powershell is fairly new to me I’m learning quite a bit. Today I was working with Get-AzSqlInstance (used to get a list of Managed Instances). As it turns out there is a breaking change coming up and Microsoft has been kind enough to warn me about it every time I run it.

WARNING: Upcoming breaking changes in the cmdlet ‘Get-AzSqlInstance’ :

  • The output type ‘Microsoft.Azure.Commands.Sql.ManagedInstance.Model.AzureSqlManagedInstanceModel’ is changing
  • The following properties in the output type are being deprecated : ‘BackupStorageRedundancy’
  • The following properties are being added to the output type : ‘CurrentBackupStorageRedundancy’ ‘RequestedBackupStorageRedundancy’
  • The change is expected to take effect from the version : ‘4.0.0’
    Note : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.

Ok, great! Good information. Not something that affects me right now but still helpful to know. And I really appreciate the fact that going forward I can expect this type of information.

I found this information less useful and less appreciated after I put it into a loop and it ran ~40 times in a row, hiding any real information beneath a pile of warnings. Fortunately, right there in the warning there is a helpful note on how to suppress it :). Fair warning that link takes you to a Github repository. Regardless, it suggests running this piece of code to turn off the warnings.

Update-AzConfig -DisplayBreakingChangeWarning $false

Yay! Now I can run my script without all of those annoying messages. That’s fantastic right? Well .. yes and no. It’s nice for right now, but those warnings are important. What if one comes across for another command and is actually going to break my code? Unfortunately, I don’t see a way to say Yes, I’ve seen this warning, thank you for letting me know, and you can stop showing me this particular warning for this particular command. So personally, as soon as I am done developing this piece of code (the warning won’t matter once it goes into automation) I’m going to turn the breaking change warnings back on again.

Original post (opens in new tab)
View comments in original post (opens in new tab)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating