-
Notifications
You must be signed in to change notification settings - Fork 64
/
Configure_Standalone_WDS.ps1
83 lines (64 loc) · 2.81 KB
/
Configure_Standalone_WDS.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#Author: Kurt De Greeff
$ScriptPath = Split-path -parent $MyInvocation.MyCommand.Definition
$ScriptPath = $ScriptPath.Replace("\","")
cd $ScriptPath
Import-Module ServerManager # Must be run as Administrator console
#region Function Extract-Zip
Function Extract-Zip
{
param([string]$zipfilename,[string]$destination)
if (Test-Path($zipfilename))
{
$shellApplication = New-Object -ComObject shell.application
$zipPackage = $shellApplication.NameSpace($zipfilename)
$destinationFolder = $shellApplication.NameSpace($destination)
$destinationFolder.CopyHere($zipPackage.Items())
}
}
#endregion
#region Install Windows AIK 2.0
#endregion
#region Install DHCP (scope will be created by other script)
if ((Get-WindowsFeature DHCP | add-WindowsFeature).exitCode -eq "success")
{ Write-Host "DHCP Server successfully installed" -BackgroundColor DarkGreen
}
else
{ Write-Host "DHCP Server already installed" -BackgroundColor DarkGreen
}
#endregion
#region Add WDS Transport Server role
if ((Get-WindowsFeature WDS-Transport | add-WindowsFeature).exitCode -eq "success")
{ Write-Host "WDS Transport Server successfully installed" -BackgroundColor DarkGreen
}
else
{ Write-Host "WDS Transport Server already installed" -BackgroundColor DarkGreen
}
#endregion
#region Create & share RemoteInstall folder structure
Write-Host "Creating & sharing WDS Remoteinstall older" -BackgroundColor DarkGreen
New-Item -Path d:\ -Name RemoteInstall -ItemType Directory -Force
$share = [wmiclass]"win32_share"
$Results = $share.create("d:\remoteinstall","REMINST",0,0, "WDS Remote Install")
if ($Results.returnvalue -eq "0") {Write-Host "WDS Share successfully created" -BackgroundColor DarkGreen}
#endregion
start-sleep -Seconds 2
#region unzip the x86/x64 boot files and images
Write-Host "Creating folder structure..." -BackgroundColor DarkGreen
Extract-Zip "$ScriptPath\wds.zip" "D:\RemoteInstall" | Write-Host "Extracting.."
#endregion
#region Configure the WDS Providers
#WDS Provider Order
New-ItemProperty -Path HKLM:\System\CurrentControlSet\services\WDSServer\Providers\WDSPXE -Name ProvidersOrder -PropertyType MultiString -Value WDSSIPR
#Configure TFTP root folder
New-ItemProperty -Path HKLM:\System\CurrentControlSet\services\WDSServer\Providers\WDSTFTP -Name RootFolder -PropertyType String -Value D:\RemoteInstall
#endregion
#region Configure the Policies
Write-Host "Copying wdssipr.dll.conf.ini ..." -BackgroundColor DarkGreen
Copy-Item "D:\RemoteInstall\wdssipr.dll.conf.ini" -Destination "c:\windows\system32\" -Force
#endregion
#region Additional DHCP/WDS Provider Configuration
WDSUTIL /Set-TransportServer /ObtainIPv4From:DHCP
Set-ItemProperty -Path HKLM:\System\CurrentControlSet\services\WDSServer\Providers\WDSPXE -Name UseDhcpPorts -Value 0
WDSUTIL /Start-TransportServer
#endregion
Write-Host "WDS Successfully installed" -BackgroundColor DarkGreen