Automatic configuration of windows servers with Hyper-V

Procedure of the automatic configuration of windows servers with Hyper-V

This tutorial describes the procedure of the configuration of windows servers with Hyper-V by an automated PowerShell-script. All steps can alternatively be executed manually. The exact procedure for the manual configuration is described in Creation of shared directories for Windows Server with Hyper-V and Creation of a Scheduled Task for Windows Server with Hyper-V

Introduction

The script relies on user inputs, which are described in the following sections. If all user inputs were successful, the script will do the following actions:

  • A shared directory for the output (csv file) of the Hyper-V-scripts will be created on all specified windows servers.
  • A scheduled task will be created on all specified windows servers. This scheduled task will run every 30 minutes and create a csv file which contains information of PowerShell-commands for Hyper-V.

The script for the automatic configuration can be downloaded here.

Image: Interface of the automation script

Preparation

The scripts for the standalone mode and cluster mode must be downloaded one time and saved in a windows network ressource. The scripts execute reading PowerShell-commands for Hyper-V-systems. The output will be created as a csv file by a scheduled task (which will be created by the automation-script).

Hint: Please do not rename the scripts because they are used in other scripts!

1. Choose operation mode of Hyper-V instances

In the first step the operation mode of the Hyper-V-servers (which are configured in the following) can be chosen. It is not possible to mix servers with different operation modes here. Possible user inputs are:

  • 1 for Hyper-V-servers in cluster mode
  • 2 for Hyper-V-servers in standalone mode

2. File path of a text file with a list of servers

In the second step the path of a text file must be entered. The text file should contain a list of servers which should be configured by the script. The scheme must be the hostnames of the servers separated by a linebreak. The text file should look like this:

Image: Example text file with list of servers

After this, the script will list all servers retrieved from the text file. It will prompt the user to confirm that the displayed data is correct.

Hint: All Hyper-V-servers in the text file must be run in the same operation mode.

3. File path of the collector script

In the third step the network path of the downloaded Hyper-V-script must be entered. The script checks if the path exists. An example for an input is: \Domainname\netlogon\Scripts\cc-collector

Hint: The directory must contain the matching script for the operation mode (standalone mode or cluster mode) chosen in step 1.

4. Target path for the shared folder and Hyper-V-scripts

In the fourth step a target path must be entered. In this path the script will put a copy of the Hyper-V-script and create a directory for the output file of the Hyper-V-scripts. The created directory for the output file will be configured with the same share permissions as described in Creation of shared directories for Windows Server with Hyper-V. An example for an input is: C:\Scripts\cc-collector

5. Enter the cockpit user

In the fifth step the cockpit user must be entered. The user will be granted access to the created directory which contains the output files. This user is the same user as configured for the Hyper-V-datacollectors. An example for an input is: domain\COCKPITUSER

6. Check of the user inputs

In the final step the whole user inputs will be summarized. The user is prompted to confirm or deny the inputs.

Image: Summarized user inputs

Image: Summary of the created scheduled task

Back to Top