Cloud Pen-testing Part-1
## Microsoft Azure & O365 CLI Tool Cheatsheet
### Az PowerShell Module
Import-Module Az
### Authentication
Connect to Azure with account credentials
```powershell
Connect-AzAccountAlternatively, if MFA restrictions are in place
$credential = Get-Credential
Connect-AzAccount -Credential $credentialImport a context file
Import-AzContext -Profile 'C:\Temp\Live Tokens\StolenToken.json'Export a context file
Save-AzContext -Path C:\Temp\AzureAccessToken.jsonAccount Information
List the current Azure contexts available
Get-AzContext -ListAvailableGet context details
$context = Get-AzContext
$context.Name
$context.AccountList subscriptions
Get-AzSubscriptionChoose a subscription
Select-AzSubscription -SubscriptionID "SubscriptionID"Get the current user's role assignment
Get-AzRoleAssignmentList all resources and resource groups
Get-AzResource
Get-AzResourceGroupList storage accounts
Get-AzStorageAccountWebApps & SQL
List Azure web applications
Get-AzAdApplication
Get-AzWebAppList SQL servers
Get-AzSQLServerIndividual databases can be listed with information retrieved from the previous command
Get-AzSqlDatabase -ServerName $ServerName -ResourceGroupName $ResourceGroupNameList SQL Firewall rules
Get-AzSqlServerFirewallRule –ServerName $ServerName -ResourceGroupName $ResourceGroupNameList SQL Server AD Admins
Get-AzSqlServerActiveDirectoryAdminstrator -ServerName $ServerName -ResourceGroupName $ResourceGroupNameRunbooks
List Azure Runbooks
Get-AzAutomationAccount
Get-AzAutomationRunbook -AutomationAccountName <AutomationAccountName> -ResourceGroupName <ResourceGroupName>Export a runbook
Export-AzAutomationRunbook -AutomationAccountName $AccountName -ResourceGroupName $ResourceGroupName -Name $RunbookName -OutputFolder .\Desktop\Last updated
Was this helpful?