-
Notifications
You must be signed in to change notification settings - Fork 0
/
Specialize.ps1
47 lines (39 loc) · 1.68 KB
/
Specialize.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
$ErrorActionPreference = "Stop"
try
{
$temp = "$ENV:SystemRoot\Temp"
$baseUrl = "https://raw.github.com/cloudbase/windows-openstack-imaging-tools/master"
# Put the wallpaper in place
$wallpaper_dir = "$ENV:SystemRoot\web\Wallpaper\Cloudbase"
if (!(Test-Path $wallpaper_dir))
{
mkdir $wallpaper_dir
}
$Host.UI.RawUI.WindowTitle = "Downloading wallpaper..."
$wallpaper = "Wallpaper-Cloudbase-2013.png"
(new-object System.Net.WebClient).DownloadFile("$baseUrl/$wallpaper", "$wallpaper_dir\$wallpaper")
$Host.UI.RawUI.WindowTitle = "Configuring GPOs..."
$gpoZipFile = "GPO.zip"
$gpoZipPath = "$temp\$gpoZipFile"
(new-object System.Net.WebClient).DownloadFile("$baseUrl/$gpoZipFile", $gpoZipPath)
foreach($item in (New-Object -com shell.application).NameSpace($gpoZipPath).Items())
{
$yesToAll = 16
(New-Object -com shell.application).NameSpace("$ENV:SystemRoot\System32\GroupPolicy").copyhere($item, $yesToAll)
}
del $gpoZipPath
# Enable ping (ICMP Echo Request on IPv4 and IPv6)
# TODO: replace with with a netsh advfirewall command
# possibly avoiding duplicates with "File and printer sharing (Echo Request - ICMPv[4,6]-In)"
netsh firewall set icmpsetting 8
$Host.UI.RawUI.WindowTitle = "Downloading FirstLogon script..."
#Make sure that in case of exception the FirstLogon script will not be executed.
#Being the last instruction this is already ok
(new-object System.Net.WebClient).DownloadFile("$baseUrl/FirstLogon.ps1", "$temp\FirstLogon.ps1")
}
catch
{
$host.ui.WriteErrorLine($_.Exception.ToString())
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
throw
}