Starting in December 2018, the Azure PowerShell Az module is in general release and now the intended PowerShell module for interacting with Azure. Az offers shorter commands, improved stability, and cross-platform support. Az also offers feature parity and an easy migration path from AzureRM.
Az uses the .NET Standard library, which means it runs on PowerShell 5.x and PowerShell 6.x. Since PowerShell 6.x can run on Linux, macOS, and Windows, Azure PowerShell is now available for all platforms. Using .NET Standard allows us to unify the code base of Azure PowerShell with minimal impact on users.
First of all we need to be aware that it requires .NET Framework version 4.7.2, but with that in place lets get started with this new module.
You can download the MSI version of the AZ module for use with Intune or SCCM here
https://github.com/Azure/azure-powershell/releases
If you have been using the existing AzureRM module you should uninstall this before installing the AZ module.
If you installed the Azure PowerShell AzureRM modules using the MSI package, you must uninstall through the Windows UI rather than PowerShell.
Go to Start > Settings > Apps, find the Azure PowerShell module and select Uninstall:
Confirm the uninstall:
If not installed using the MSI, you can uninstall with PowerShell, in order to uninstall all Azure, AzureRM and AzureAD modules you can use the following code. Then we are good to start allover with the the new Azure module (AzureAD must be reinstalled).
PowerShell must be elevated.
foreach ($module in (Get-Module -ListAvailable Azure*).Name |Get-Unique) {
write-output “Uninstalling Module $module”
Uninstall-module $module
}
Now we can install the new module using the MSI file or PowerShell.
MSI installation:
Install from a elevated PowerShell:
Install-Module Az
Now let try to connect and get some data from Log Analytics.
You can of course connect with a Managed Service Identity or certificate but for this test we will just use Device Login:
Connect-AzAccount
Enter the device code.
Sign in.
And finally lets get some test data:
$res = Invoke-AzOperationalInsightsQuery -Query “Event” -WorkspaceId “44c8715f-d406-4bb8-aa04-d1618af328b1” -Timespan (New-TimeSpan -Hours 12)
$res.Results.RenderedDescription
More information and also how to use existing scripts with Az:
https://docs.microsoft.com/en-us/powershell/azure/new-azureps-module-az?view=azps-1.1.0