How to obtain Image details of unpublished images - azure-powershell

I have been using the Azure PowerShell module and I use this cmdlet to obtain either published or unpublished image details:
Get-AzureVMImage | where-object { $_.Label -like "$ImageName" }
I need to move to the Az module. The replacement cmdlet seems to be Get-AzVMImage. And that does not seem to provide a way to list unpublished images.
So, how do you obtain a list of unpublished images and their details?

According to my understanding, you want to get the custom image. If so you can use the command "Get-AzImage" to get it. For example:
Connect-AzAccount -Subscription "your subscrition id" -Tenant "your tenant id"
Get-AzImage -ImageName "" -ResourceGroupName ""

Related

How to update existing routing rule in Azure Frontdoor using PowerShell?

I need to update the backend pool (Maintenance) used by an existing routing rule in Azure Frontdoor to a different existing backend pool (Maintenance2). Here is the UI screen from where it can be done. Can someone advise on how to do this via PowerShell. I have tried via the cmdlets (https://learn.microsoft.com/en-us/powershell/module/az.frontdoor/set-azfrontdoor?view=azps-9.0.1 ) but unable to get the correct set of commands.
I have tried via the cmdlets (https://learn.microsoft.com/en-us/powershell/module/az.frontdoor/set-azfrontdoor?view=azps-9.0.1 ) but unable to get the correct set of commands.
In order to update the backend pool (Poo1) used by an existing routing rule in Azure Front Door to a different existing backend pool (Pool2).
Created a Front Door environment with backend Pools [Pool1/Pool2] which they are pointing to routing rules
Pool1 -> Rule1 and Pool2 -> Rules2
Click on Rule1
WorkAround:
Login into Powershell
tag to the current subscription where Front Door was created. using below command
az account set --subscription "******-****-****-****-*********"
Verify the Backend Pool on Front Door using this command
az network front-door backend-pool list --front-door-name "FrontDoorName" --resource-group "ResoruceGroupName"
Update Backend Pool for Rule1 from pool1 to pool2
using below command
az network front-door routing-rule update --front-door-name "Front Door Name" --name "Rule Name" --resource-group "Resource Group Name" --backend-pool "New Backend Pool"
example:
az network front-door routing-rule update --front-door-name "testfrontdoor" --name "Rule1" --resource-group "rg-testdemo" --backend-pool "pool2"
Output:
Resulted output on Front Door Rule1
Now Rule1 is points to Backend Pool "Pool2" instead of original one "Pool1".
Thank you Swarna. The solution provided is in CLI and the question was for powershell.
I was able to figure out how to do this in PowerShell. It requires the use of 3 Azure PS cmdlets- Get-AzFrontDoor, New-AzFrontDoorRoutingRuleObject and Set-AzFrontDoor. The way it works in the background is that when an update is performed on the Routing Rule, the routing rule is deleted and recreated with the changes. In-order to do this via PS, we have to get the existing frontdoor properties, routing rule properties and put the changes in New-AzFrontDoorRoutingRuleObject. Lastly use Set-AzFrontDoor to apply the changes to frontdoor.
$subscription='Sub1'
Select-AzSubscription $Sub1
$frontdoorName='Frontdoor1'
$resourcegroupname='fdrrg'
$MaintenanceBackPool='Maintenance2'
$PrimaryBackPool='Maintenance1'
$RoutingRuleName='Route1'
#get the current frontdoor property object
$frontdoorobj=Get-AzFrontDoor -ResourceGroupName $resourcegroupname -Name $frontdoorName
#get the Routing Rules and filter the one which needs to be modified
$RoutingRuleUpdate=$frontdoorobj.RoutingRules
$RoutingRuleUpdate2=$RoutingRuleUpdate|Where-Object {$_.Name -contains $RoutingRuleName}
#get the list of all frontendendpointIds as an array (this is required to account for more than 1 frontends/domains associated with the routing rule)
#Perform string manipulation to get the frontend/domain name from the ID
[String[]] $frontdoorHostnames=$RoutingRuleUpdate2.FrontendEndpointIds | ForEach-Object {"$PSItem" -replace '.*/'}
#get the position of the Routing Rule (to be modified) in the Routing Rules collection
$i=[array]::indexof($RoutingRuleUpdate.Name,$RoutingRuleName)
#Update the Routing Rule object with the changes needed- in this case a different backendpool
$updatedRouteObj=New-AzFrontDoorRoutingRuleObject -Name $RoutingRuleUpdate[$i].Name  -FrontDoorName $frontDoorName -ResourceGroupName $resourcegroupname -FrontendEndpointName $frontdoorHostnames -BackendPoolName $MaintenanceBackPool
$RoutingRuleUpdate[$i]=$updatedRouteObj
#Finally update the frontdoor object with the change in Routing Rule
Set-AzFrontDoor -InputObject $frontdoorobj -RoutingRule $RoutingRuleUpdate
Write-Output "Successfully Updated RoutingRule:$RoutingRuleName to backendpool:$MaintenanceBackPool"**

Get-AzureADUser - ALL - PowerShell Slow Get all users and users who made changes to account

I am working with Azure AD and need to get all users and export it into csv file and finally put it into SQL.
At this moment we have about 10,000 users. The problem is the PowerShell command [Get-AzureADUser – ALL] it’s SUPER SLOW!! It takes about 58 minutes to complete the task. Today we noticed that some users made changes to their account. I need to update the whole list to find the changes made.
My questions is:
1) Is there a faster way I can get ALL users?
2) How can I only find users who made changes to their account?
Powershell script:
$aadUsers = Get-AzureADUser -All $true | Select DisplayName, ObjectId, userType,GivenName
According to my research, if we want to get the users' changes, we have two ways to do that
Track changes to users with Users audit logs.
We can use Azure AD Powershell command Get-AzureADAuditDirectoryLogs to get Users audit logs. For more details, please refer to https://learn.microsoft.com/en-us/powershell/module/azuread/get-azureadauditdirectorylogs?view=azureadps-2.0-preview
Install-module AzureADPreview
Connect-AzureAD
Get-AzureADAuditDirectoryLogs -All $true -Filter "Category eq 'UserManagement' and result eq 'success'"
Track changes to users with Microsoft Graph delta query
The API is as below
Get https://graph.microsoft.com/v1.0/users/delta
For example
GET https://graph.microsoft.com/v1.0/users/delta?$select=displayName,givenName,surname
If your response is too big, it will return #odata.nextLink in the response. Then you can directly use the link to get the next page response. At the last page response, it will return #odata.deltaLink in the response. You can save it and directly use the link to get the changes in next time. For more details, please refer to https://learn.microsoft.com/en-us/graph/delta-query-users
Get-msoluser -all | select DisplayName, ObjectId, userType, FirstName
Get-msoluser -all | select *
Get-msoluser -all | Where {$_.city -eq 'chicago'}
This module seems quite a bit faster.

Getting 'Minimum TLS Version' setting of Azure webapp with Az PowerShell

I have a PowerShell script that uses Az PowerShell modules to retrieve properties of all webapps within a resource group. Now, I also need to fetch the MinTlsVersion property as in below. Can I do it using one of Az modules?
When a call to Get-AzWebApp command is made in the script, a request is sent to /subscriptions/<s>/resourceGroups/<rg>/providers/Microsoft.Web/sites endpoint. The response object has property siteConfig set to null. Is there a way to call Get-AzWebApp such that the property is not null so I can use the minTlsVersion sub-property under the siteConfig object?
If there's no way to above:
I see that the client receives minTlsVersion by sending a GET request to /subscriptions/<s>/resourceGroups/<rg>/providers/Microsoft.Web/sites/<st>/config/web endpoint. Can we hit the same endpoint by using one of the Az PowerShell modules? Though, I would prefer a request that can return minTlsVersion of all webapps in a resource group in a single call.
You need to iterate through each app, try the command as below, it works on my side.
$grouname = "<resource-group-name>"
$apps = Get-AzWebApp -ResourceGroupName $grouname
$names = $apps.Name
foreach($name in $names){
$tls = (Get-AzWebApp -ResourceGroupName $grouname -Name $name).SiteConfig.MinTlsVersion
Write-Host "minTlsVersion of web app" $name "is" $tls
}

Solarwinds API Poll Now

In the SolarWinds user interface, there is a button you can click within a switch or interface view to "Poll Now", instead of waiting for the regularly scheduled poll. I have been trying to figure out a way to recreate this functionality using the SolarWinds API. I've looked through this page, and it seems like I will need to use either the 'invoke' or 'update' operations, but there is almost no information on the actual usage. I have also tried examining the Javascript in the user interface, and can't make heads or tails of it.
I'm wondering if someone can point me towards some useful documentation as to what operations are actually available in the API (the 'invoke' operation requires you to give a 'verb' as an argument, but I can't find any kind of list or documentation as to what verbs are available). Does anyone know of any resources?
If you look at Orion.Nodes SWIS Entity you can see in the bottom "PollNow" SWIS Verb. Unfortunatelly it is not so well documented what parameters it actually has (it can be seen in SWQL Studio though). But you should be able to do it this way using Powershell:
$orionHost = "<hostname where orion is installed>"
$orionUsername = "Admin" # fill login username to orion
$orionPassword = "Pass" # fill login password to orion, this example counts that this is not empty string
$nodeIdToPoll = 1; # put id of the node
$Entity = "Orion.Nodes"
$Verb = "PollNow"
$Data = #($nodeIdToPoll)
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$credentials = new-object PSCredential ($orionUsername , (ConvertTo-SecureString $orionPassword -AsPlainText -Force))
Invoke-RestMethod "https://$($orionHost):17778/SolarWinds/InformationService/v3/Json/Invoke/$Entity/$Verb" `
-Method POST `
-Body (ConvertTo-Json -InputObject $Data) `
-Credential $credentials `
-ContentType "application/json"

Clear/change CustomDomainName for storage account using Powershell

I want to setup a custom domain for a azure storage account(v2?, not classic).
With this answer I managed to use powershell to set it up for one domain and one storage account.
For another domain and another storage account I thought I had it configured correctly but when I try to configure it now I get this error:
Set-AzureRmStorageAccount -ResourceGroupName "ExampleGroup" -Name "test" -CustomDomainName test.example.com -UseSubDomain $true
Set-AzureRmStorageAccount : CustomDomainNameAlreadySet: Custom domain name is already set. Current value must be cleared before setting a new value.
+ Set-AzureRmStorageAccount -ResourceGroupName "ExampleGroup" -Name " ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzureRmStorageAccount], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Management.Storage.SetAzureStorageAccountCommand
The only answer I've found implies that one should use the classical portal which is not an option as v2 storage accounts does not show up there.
How can I clear the CustomDomainName value?
At the moment if you have a custom domain name set and want to replace it, you have to unregister it first. To unregister it, set the CustomDomainName to an empty string and don't send UseSubDomain.