Skip to content

Instantly share code, notes, and snippets.

@BladeFireLight
BladeFireLight / Start-ImageBuild.ps1
Last active Aug 29, 2015
Automaticaly build Template vhdx and Source.wim
View Start-ImageBuild.ps1
#requires -Version 3 -Modules Dism, Hyper-V, ScheduledTasks
#Wrapper arround Convert-WindowsImage script to it acts like a function.
function Convert-WindowsImage
{
Param
(
[Parameter(ParameterSetName = 'SRC', Mandatory = $true, ValueFromPipeline = $true)]
[Alias('WIM')]
[string]
@BladeFireLight
BladeFireLight / Convert-WindowsIMage.ps1
Created Jun 1, 2015
Convert-WindowsImage Modified for use with Start-ImageBuild
View Convert-WindowsIMage.ps1
<#
.NOTES
Copyright (c) Microsoft Corporation. All rights reserved.
Use of this sample source code is subject to the terms of the Microsoft
license agreement under which you licensed this sample source code. If
you did not accept the terms of the license agreement, you are not
authorized to use this sample source code. For the terms of the license,
please see the license agreement between you and Microsoft or, if applicable,
see the LICENSE.RTF on your install media or the root of your tools installation.
@BladeFireLight
BladeFireLight / Source-Features.txt
Created Jun 1, 2015
Feature list for Source.wim
View Source-Features.txt
AD-Domain-Services
AD-Certificate
ADCS-Cert-Authority
@BladeFireLight
BladeFireLight / Source-FeaturesIncludingSub.txt
Created Jun 1, 2015
Feature with all Sub Features for Soruce.wim
View Source-FeaturesIncludingSub.txt
DNS
DHCP
File-Services
RSAT
@BladeFireLight
BladeFireLight / Source-FirstRun.ps1
Last active Dec 26, 2020
Source FirstRun script for use with Start-ImageBuild.ps1
View Source-FirstRun.ps1
#requires -Version 3 -Modules ScheduledTasks, ServerManager
# Add any features required.
Start-Transcript -Path $PSScriptRoot\FirstRun.log
Get-WindowsFeature |
Where-Object -Property InstallState -EQ -Value Removed |
Install-WindowsFeature -Source D:\sources\sxs -Verbose
$features = Get-Content -Path $PSScriptRoot\Features.txt
Install-WindowsFeature $features -Verbose
$features = Get-Content -Path $PSScriptRoot\FeaturesIncludingSub.txt
@BladeFireLight
BladeFireLight / SysPrep.ps1
Last active Aug 29, 2015
SysPrep script for use with Start-ImageBuild.ps1
View SysPrep.ps1
#requires -Version 1 -Modules ScheduledTasks, ServerManager
#region cleanup
Start-Transcript -Path c:\sysprep.log
Get-ScheduledTask -TaskName AtStartup | Unregister-ScheduledTask -Confirm:$false
Remove-Item -Path c:\unattend.xml
Get-ChildItem -Path c:\pstemp\ -Exclude AtStartup.ps1 | Remove-Item
Get-WindowsFeature |
Where-Object -FilterScript {
$_.Installed -eq 0 -and $_.InstallState -eq 'Available'
} |
@BladeFireLight
BladeFireLight / Template-FirstRun.ps1
Last active Aug 29, 2015
Template FirstRun script for use with Start-ImageBuild.ps1
View Template-FirstRun.ps1
#requires -Version 2 -Modules ScheduledTasks, ServerManager
# Add any features required.
Start-Transcript -Path $PSScriptRoot\FirstRun.log
$features = Get-Content -Path $PSScriptRoot\Features.txt
Install-WindowsFeature $features -IncludeAllSubFeature -Verbose
$features = Get-Content -Path $PSScriptRoot\FeaturesIncludingSub.txt
Install-WindowsFeature $features -Verbose
$Paramaters = @{
Action = New-ScheduledTaskAction -Execute '%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe' -Argument '-NoProfile -ExecutionPolicy Bypass -File C:\PSTemp\AtStartup.ps1'
@BladeFireLight
BladeFireLight / WinUpdate.ps1
Last active Aug 29, 2015
WindowsUpdate script for use with Start-ImageBuild.ps1
View WinUpdate.ps1
#requires -Version 2
Function Add-WindowsUpdate
{
param (
[string]$Criteria = "IsInstalled=0 and Type='Software'" ,
[switch]$AutoRestart,
[Switch]$ShutdownAfterUpdate,
[switch]$ForceRestart,
[Switch]$ShutdownOnNoUpdate
@BladeFireLight
BladeFireLight / unattend.xml
Created Jun 4, 2015
Unattend.xml used with Start-ImageBuild.ps1
View unattend.xml
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="oobeSystem">
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<InputLocale>en-us</InputLocale>
<SystemLocale>en-us</SystemLocale>
<UILanguage>en-us</UILanguage>
<UserLocale>en-us</UserLocale>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">