-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate-LAB.ps1
63 lines (41 loc) · 1.65 KB
/
Create-LAB.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Assuming Set-ExecutionPolicy RemoteSigned
# Loading Modules
. "C:\Users\mverm\OneDrive\Tools\PowerShell Scripts and Commandlets\Get-FileName.ps1"
. "C:\Users\mverm\OneDrive\Tools\PowerShell Scripts and Commandlets\Convert-WindowsImage.ps1"
# Setting Variables
$domainController = "MivexLab-DC1"
$memberServersCount = 2
$ISOlocation = $null
$ethernet = Get-NetAdapter -Name Ethernet
$wifi = Get-NetAdapter -Name Wi-Fi
# Set Administrator Password
$adminUsername = "Administrator"
$adminPassword = "Passw0rd"
$adminPasswordNano = ConvertTo-SecureString -String $adminPassword -AsPlainText -Force
$secstr = New-Object -TypeName System.Security.SecureString
$adminPassword.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $adminUsername, $secstr
if (!$ISOlocation)
{
$ISOlocation = Get-FileName -initialDirectory "G:\ISO's" -FileType "ISO"
While ($ISOlocation -notlike ".iso")
{
$msgBoxInput = [System.Windows.MessageBox]::Show('Selected file is not an ISO','Invalid File','OkCancel','Error')
switch ($msgBoxInput)
{
'OK'
{
## Do something
}
'Cancel'
{
# Without the ISO we can't continue
break
}
}
}
}
$mountResult = Mount-DiskImage -ImagePath "C:\Users\m.vermeer\Downloads\ISO\Windows Server 2016.ISO" -PassThru
$driveLetter = ($mountResult | Get-Volume).DriveLetter + ":"
If (! (Test-Path $destination)) { mkdir $destination }
Set-Location $destination