# 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