-
Notifications
You must be signed in to change notification settings - Fork 7
/
startup.ps1
78 lines (64 loc) · 2.44 KB
/
startup.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
$Host.UI.RawUI.WindowTitle = "PowerShell v$($PSVersionTable.PSVersion) :: Windows PE v$([Environment]::OSVersion.Version)"
Clear-Host
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
trap {
Write-Output "ERROR: $_"
Write-Output (($_.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
Write-Output (($_.Exception.ToString() -split '\r?\n') -replace '^(.*)$','ERROR EXCEPTION: $1')
while ($true) {
Start-Sleep -Seconds 3
}
Exit 1
}
function Write-Title($title) {
Write-Output "#`n# $title`n#"
}
# NB this was rendered by http://patorjk.com/software/taag/#p=display&f=Standard&t=Windows%20PE
@'
__ ___ _ ____ _____
\ \ / (_)_ __ __| | _____ _____ | _ \| ____|
\ \ /\ / /| | '_ \ / _` |/ _ \ \ /\ / / __| | |_) | _|
\ V V / | | | | | (_| | (_) \ V V /\__ \ | __/| |___
\_/\_/ |_|_| |_|\__,_|\___/ \_/\_/ |___/ |_| |_____| {0}
'@ -f @((Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ReleaseId)
Write-title Firmware
Get-ComputerInfo `
-Property `
BiosFirmwareType,
BiosManufacturer,
BiosVersion `
| Format-List
Write-Title SMBIOS
$info = Get-WmiObject Win32_ComputerSystemProduct
New-Object PSObject -Property @{
DmiSystemVendor = $info.Vendor
DmiSystemProduct = $info.Name
DmiSystemVersion = $info.Version
DmiSystemSerial = $info.IdentifyingNumber
DmiSystemUuid = $info.UUID
}
Write-Title DISKS
'list disk' | diskpart
Write-Output ''
Write-Title Network
ipconfig
Write-Output 'Mounting Artifacts Drive...'
$artifactsRemoteHost = '10.3.0.2'
$artifactsRemotePath = "\\$artifactsRemoteHost\artifacts"
# NB this uses net.exe because New-SmbMapping is quite unreliable.
$result = net.exe use S: $artifactsRemotePath
if ($result -ne 'The command completed successfully.') {
throw "net.exe use failed with $result"
}
net use
# see https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-setup-technical-reference
# see https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-setup-command-line-options
Write-Output @'
To install Windows execute one of:
s:\windows-server-2022.iso\sources\setup.exe /noreboot /unattend:s:\winpe\unattend-bios.xml
s:\windows-server-2022.iso\sources\setup.exe /noreboot /unattend:s:\winpe\unattend-uefi.xml
Then restart the computer:
Restart-Computer
'@