removed microsoft.graph

This commit is contained in:
Alexander (Sasha) Nosov
2025-05-20 15:20:48 -07:00
parent 593ba9a04c
commit 86cf4305e3
2 changed files with 6 additions and 18 deletions
@@ -0,0 +1,2 @@
"TenantID","SubID","ResourceName","ResourceType","Status","OriginalLicenseType","ResourceGroup","Location"
"72f988bf-86f1-41af-91ab-2d7cd011db47","fa58cf66-caaf-4ba9-875d-f310d3694845","SQL2012EEArc","WindowsAgent.SqlServer","Connected","PAYG","ajayj","westus2"
1 TenantID SubID ResourceName ResourceType Status OriginalLicenseType ResourceGroup Location
2 72f988bf-86f1-41af-91ab-2d7cd011db47 fa58cf66-caaf-4ba9-875d-f310d3694845 SQL2012EEArc WindowsAgent.SqlServer Connected PAYG ajayj westus2
@@ -39,7 +39,7 @@
Optional. If specified, excludes the resources that have this tag assigned.
.PARAMETER TenantId
Optional. If specified, this tenant id to log in both PowerShell and CLI. Otherwise, the current login context is used.
Required. If specified, this tenant id to log in both PowerShell and CLI. Otherwise, the current login context is used.
.PARAMETER ReportOnly
Optional. If true, generates a csv file with the list of resources that are to be modified, but doesn't make the actual change.
@@ -81,7 +81,7 @@ param (
[Parameter (Mandatory= $false)]
[object] $ExclusionTags,
[Parameter (Mandatory= $false)]
[Parameter (Mandatory= $true)]
[string] $TenantId,
[Parameter (Mandatory= $false)]
@@ -123,6 +123,7 @@ function Connect-Azure {
}
Write-Output "Connected to Azure PowerShell as: $($ctx.Account)"
}
@@ -152,21 +153,7 @@ if ($UseManagedIdentity) {
}
# Ensure the required modules are imported
try{
# Check if Microsoft.Graph module is installed
if (-not (Get-Module -ListAvailable -Name Microsoft.Graph)) {
Write-Host "Microsoft.Graph module not found. Installing..."
Install-Module -Name Microsoft.Graph -Scope CurrentUser -Force
}else {
Write-Host "Microsoft.Graph module is already installed."
}
# Import the module
Import-Module Microsoft.Graph
}
catch{
Write-Output "Can't import module Microsoft.Graph"
}
try{
Import-Module Az.Accounts
}catch{
@@ -190,7 +177,6 @@ $modifiedResources = @()
if ($SubId -like "*.csv") {
$subscriptions = Import-Csv $SubId
}elseif($SubId -ne "") {
Write-Output "Passed Subscription $($SubId)"
$subscriptions = Get-AzSubscription -SubscriptionId $SubId
}else {
$subscriptions = Get-AzSubscription | Where-Object { $_.TenantId -eq $tenantId }
@@ -264,7 +250,7 @@ foreach ($sub in $subscriptions) {
| project machineName, extensionName, resourceGroup, location, subscriptionId, extensionPublisher, extensionType
"
Write-Output $query
#Write-Output $query
$resources = Search-AzGraph -Query "$($query)"
Write-Output "Found $($resources.Count) resource(s) to update"