You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Manages NetworkAccessPolicy and PublicNetworkAccess on all managed disks (OS + data) attached to Azure VMs.
Features
Three actions: Disable (DenyAll/Disabled), Enable (AllowAll/Enabled), Report (read-only).
Two modes: batch (CSV) for bulk operations, interactive for single VMs.
Parallel processing: subscription groups run concurrently via ForEach-Object -Parallel (configurable ThrottleLimit).
Batch API optimisation: VMs and disks are fetched per resource group rather than individually, drastically reducing API calls.
Skip-compliant: disks already in the desired state are skipped — no unnecessary writes.
Ephemeral resource handling: gracefully skips VMs and disks that no longer exist (e.g. Databricks workers).
Structured output: every disk produces a PSCustomObject with Subscription, ResourceGroup, VM, Disk, Action, Status, NetworkAccessPolicy, PublicNetworkAccess, Detail — pipe to Export-Csv, Where-Object, etc.
SupportsShouldProcess: full -WhatIf and -Confirm support.
Progress & summary: Write-Progress during execution, per-subscription and overall summary tables at completion.
Requirements
Requirement
Minimum
PowerShell
7.0
Az.Accounts
latest
Az.Compute
latest
Azure login
Connect-AzAccount before running
Parameters
Parameter
Set
Required
Description
-CsvPath
Csv
Yes
Path to a CSV file with columns: SubscriptionName, ResourceGroupName, VMName, Action.
-SubscriptionName
Interactive / ReportInteractive
Yes
Azure subscription name.
-ResourceGroupName
Interactive / ReportInteractive
Yes
Resource group containing the VM.
-VMName
Interactive / ReportInteractive
Yes
Virtual machine name.
-Action
Interactive
Yes
Enable, Disable, or Report.
-ReportOnly
ReportInteractive
Yes
Report current state without requiring -Action.
-ThrottleLimit
Csv
No
Max parallel subscriptions (1–16, default 4). Set to 1 to disable parallelism.
CSV input
│
├─ Validate columns & Action values
├─ Group rows by SubscriptionName
├─ Pre-create Az contexts (one per subscription)
│
└─ ForEach-Object -Parallel (per subscription group)
│
├─ Phase 1: Batch-fetch VMs per unique resource group
├─ Phase 2: Parse disk info from VMs, batch-fetch disks per unique RG
└─ Phase 3: Process rows using cached data
├─ Report → hashtable lookup only
├─ Enable → lookup + Update-AzDisk (if non-compliant)
└─ Disable → lookup + Update-AzDisk (if non-compliant)
Performance Notes
The batch-fetch approach replaces individual Get-AzVM and Get-AzDisk calls with bulk per-resource-group calls. For 200 VMs across 5 subscriptions this reduces ~700 individual REST calls to ~25 bulk calls, bringing execution from ~1:35 down to ~0:18 (5× speedup). The improvement scales with VM density per resource group.
About
Manages NetworkAccessPolicy and PublicNetworkAccess on Azure VM managed disks