Author Archives: Besdima

Powershell script to pull all prefixes by ASN

A short script to get all prefixes from AS by number:

$ASN = Read-Host "Enter AS Number numerals"

# Replace 'API_URL' with the actual URL of the API.
$apiUrl = "$ASN/prefixes"

# Perform the GET request and convert the JSON response into a PowerShell object.
$response = Invoke-RestMethod -Uri $apiUrl -Method Get

# Extract the 'prefix' field from each element in the 'ipv4_prefixes' array.
$prefixes = $ | ForEach-Object { $_.prefix }

# Print the prefixes with desired format.

foreach ($prefix in $prefixes) {
    Write-Output "/ip route add dst-address=$prefix gateway= comment=AS$ASN"

How to change country or region on your Azure account

It might not be a common issue for everyone, but I was travelling a lot in my life, and at some point when I was in New Zealand – I happened to create an Azure account to use with my MSDN offer, and it was created in NZD. It was fine until I moved to Ireland, and now, to keep the books tidy, I wanted to change my currency to EUR.

Microsoft docos and support stand firm that this is not possible to change your billing profile residency. However, looking under the hood, it appears to be possible with some digging in and PowerShell magic.

Continue reading

ADConnect permission issues with adminCount accounts

Once I was working on migrating Azure AD Connect from one server to another. After the migration, no matter that the account had rights on the SDadmin folder, some accounts failed to be updated with an insufficient rights error.

After some digging, I found that some accounts historically have adminCount set to 1 and inheritance turned off, so to fix that, I used the following script below:

Continue reading

Unable to promote a server to a domain controller

During one of the activities with the demo environment I faced an issue that I was unable to promote any server to DC, and was giving the errors:

ADPrep execution failed –> System.ComponentModel.Win32Exception (0x80004005): A device attached to the system is not functioning.
Check the log files in the C:\Windows\debug\adprep\logs\20220518075032 directory for detailed information.

Continue reading

How to activate the configuration server for disaster Azure recovery

By the standard way of imputing the new key into the activation form, you’ll get an error that this edition could not be upgraded. However, the MS guide stands for if you’d like to activate your Azure configuration server you’d need to do that through DISM:

And the command is simple as that:

Continue reading