Search for occurrences of Azure Service Management PowerShell cmdlets using a regular expression

I got an e-mail from Microsoft Azure today warning me of the imminent retirement of the Service Management REST APIs for Azure Automation. It will be no longer supported on April 30, 2019:

Required action

Migrate any Service Management REST APIs and PowerShell cmdlets for Azure Automation to Resource Manager REST APIs or the latest PowerShell cmdlets by April 30, 2019, to take advantage of advanced capabilities and avoid any service disruptions.

More information

If you’re unsure whether you’re using Service Management REST APIs, check the URI referenced in your code or service. If it’s https://management.core.windows.net, you’re using Service Management REST APIs and you should migrate to Resource Manager REST APIs.

If you’re unsure whether you’re using Service Management PowerShell cmdlets, check whether the cmdlet name includes AzureRM (for example, Get-AzureRmAutomationAccount) or Az (for example, Get-AzAutomationAccount). If it doesn’t include AzureRM or Az (for example, Get-AzureAutomationAccount), you should migrate to Resource Manager PowerShell cmdlets.

Searching for ‘Get-Azure’ not followed by ‘Rm’ using a regular expression

I checked our collection of Powershell scripts used in our Build & Release pipeline for this with the following regular expression:

1
Get-Azure(?!Rm)

This returns all occurrences of Get-Azure not followed by Rm.

(?!) is a ‘negative lookahead’.

I wrote my regex in Rad Software Regular Expression Designer (which has a website that no longer works but can still be downloaded - read a review of it on a www.red-gate.com blog post):

Searching for this regular expression in Visual Studio only returned multiple occurrences of Get-AzureDeployment, like this:

1
$productionSlot = Get-AzureDeployment -ServiceName $serviceName -Slot Production