Followers

Thursday, 14 December 2023

9.Create Azure Migrate project using windows PowerShell (Az Module) with user inputs.

# Install and import the Az module (if not already installed)

if (-not (Get-Module -Name Az -ListAvailable)) {

    Install-Module -Name Az -Force -AllowClobber -Scope CurrentUser

}

Import-Module Az

#use windows powershell to run this script

# Prompt the user for Azure Migrate project details

$azureMigrateProjectName = Read-Host -Prompt 'Enter Azure Migrate Project Name'

$subscriptionId = Read-Host -Prompt 'Enter Subscription ID'

$region = Read-Host -Prompt 'Enter Azure region for the Azure Migrate project'

$location = Read-Host -Prompt 'Enter location for the Azure Migrate project'

$resourceGroupName = Read-Host -Prompt 'Enter Resource Group Name for Azure Migrate project'


# Connect to Azure (Interactive login)

Connect-AzAccount -UseDeviceAuthentication


# Set the subscription context

Set-AzContext -Subscription $subscriptionId


# Create a new resource group

New-AzResourceGroup -Name $resourceGroupName -Location $region

# Create an Azure Migrate project

New-AzMigrateProject -Name $azureMigrateProjectName -ResourceGroupName $resourceGroupName -Location $location 

  Write-Host "Azure Migrate project '$azureMigrateProjectName' has been created successfully!" 

  #This script is tested on windows PowerShell 5.1 on Windows 11

 

No comments:

Post a Comment

12. Creating a Hub and Spoke Network with a DMZ and Allowing Access to Azure Arc and Other Microsoft URLs from the Azure Portal

12. Creating a Hub and Spoke Network with a DMZ and Allowing Access to Azure Arc and Other Microsoft URLs from the Azure Portal. 1. Create a...