Table of Contents
Suppressing warnings in a PowerShell script
In some cases, when you run a PowerShell cmdlet or execute a PowerShell script. You got the yellow warning and the script or command run normally.
You want to suppressing or hiding the yellow warning to make your script look clean.
$subnet = New-AzVirtualNetworkSubnetConfig -Name 'default' -AddressPrefix "172.16.1.0/24"
WARNING: Upcoming breaking changes in the cmdlet 'New-AzVirtualNetworkSubnetConfig' :
Update Property Name
Cmdlet invocation changes :
Old Way : -ResourceId
New Way : -NatGatewayId
Update Property Name
Cmdlet invocation changes :
Old Way : -InputObject
New Way : -NatGateway
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.
To achieve that goal, let’s add -WarningAction SilentlyContinue parameter into your command in the script.
$subnet = New-AzVirtualNetworkSubnetConfig `
-Name 'default' `
-AddressPrefix "172.16.1.0/24" `
-WarningAction silentlyContinue
ADVERTISEMENT
5/5 - (2 votes)