Automating the connection of your servers in Azure (PowerShell script) – English Version

Automating the connection of your servers in Azure (PowerShell script) – English Version

After several days of thinking, I was wondering how to make it even easier to integrate servers into Azure.

That’s why I decided to set up a little script that can take care of that for us.

Infrastructure

Our test infrastructure has a Domain Controller and two « DATA » servers that are in this domain:

AD server:

  • AD-SRV.info.local / IP= 192.168.1.62

DATA Server

  • SRV-DATA.info.local / IP=192.168.1.65
  • SRV-DATA02.info.local/ IP=192.168.1.64

Script creation

The idea would be to reference all our servers in a .csv file that we will import in our script:

$CSV = Import-CSV -Path « C:\Users\AdministratorDesktop\script.csv » -Delimit « , »

Once this task is done, we will connect to Azure using the command :

connect-azaccount

Now we can create our loop:

for resume:

If you want the script is available on my github here:

scriptazurearcserver/finalscriptarc.ps1 at main · technicalandcloud/scriptazurearcserver (github.com)

Execution

We will run our script on our DC, here is the CSV:

and our script:

Now we run, we are asked to connect:

After successful authentication, the script runs:

After a few minutes of patience, the servers are back in Azure:

I hope the script helps you, as it helps me!

Nicolas VACCARO

Passionnée par l'environnement Cloud, je propose des articles qui pourront aider débutant comme expert.

Related Posts