Skip to content

Instantly share code, notes, and snippets.

View SvenAelterman's full-sized avatar

Sven Aelterman SvenAelterman

View GitHub Profile
@SvenAelterman
SvenAelterman / Remove-UnattachedNIC.ps1
Last active May 12, 2022 02:28
Remove-Unattached-NICs
$deleteUnattachedNICs = $false
# List all unattached NICs
$unattachedNICs = Get-AzNetworkInterface | `
Where-Object { $_.VirtualMachine -eq $null -and ($_.PrivateEndpointText -eq $null -or $_.PrivateEndpointText -eq 'null') }
# Iterate over the unattached NICs
foreach ($nic in $unattachedNICs) {
# Find a lock for the NIC (or resource group/subscription/...)
$lock = Get-AzResourceLock -ResourceName $nic.Name -ResourceGroupName $nic.ResourceGroupName -ResourceType 'Microsoft.Network/networkInterfaces'
@SvenAelterman
SvenAelterman / Uninstall-OutdatedModules.ps1
Last active January 22, 2024 16:14
Uninstall-OutdatedModules.ps1
[CmdletBinding(SupportsShouldProcess = $True)]
Param(
[Parameter(Mandatory, Position = 1)]
[string]$ModuleName,
[Parameter(Position = 2)]
[bool]$DeleteChildModules = $true
)
$Latest = Get-InstalledModule $ModuleName -ErrorAction Ignore;
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"background": "#0077c2",
"foreground": "#ffffff",
"leading_diamond": "",
@SvenAelterman
SvenAelterman / WVDConnections_byUser_byClientVersion,kql
Created April 27, 2023 13:33
Query Azure Virtual Desktop (AVD) connection logs for client versions used by users over time
let startTime = ago(30d);
WVDConnections
| where TimeGenerated > startTime
| summarize min(TimeGenerated), max(TimeGenerated) by UserName, ClientOS, ClientType, ClientVersion
| sort by UserName, min_TimeGenerated
@SvenAelterman
SvenAelterman / deploy.ps1
Created November 12, 2023 22:35
DeploymentSlotVNetIntegration
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]$TargetSubscriptionId,
[Parameter(Mandatory)]
[string]$TargetResourceGroup,
[Parameter(Mandatory)]
[string]$DeploymentLocation
)
@SvenAelterman
SvenAelterman / Remove-ArcExtension.ps1
Last active May 4, 2024 20:58
Removes a specified extension from all Arc-enabled machines in a resource group
# A PowerShell script using the Az PowerShell module to remove a specific extension WindowsPatchExtension from all Azure Arc enabled machines in a specific resource group.
# The script will remove the extension from all machines in the resource group, regardless of the extension status.
# Parameters
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $ResourceGroupName,
[Parameter()]
[string] $ExtensionName = "WindowsPatchExtension"