Skip to content

Instantly share code, notes, and snippets.

Test-connection localhost
@BladeFireLight
BladeFireLight / WinUpdate.ps1
Last active August 29, 2015 14:22
WindowsUpdate script for use with Start-ImageBuild.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 / Template-FirstRun.ps1
Last active August 29, 2015 14:22
Template FirstRun script for use with Start-ImageBuild.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 / SysPrep.ps1
Last active August 29, 2015 14:22
SysPrep script for use with Start-ImageBuild.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 / Source-FeaturesIncludingSub.txt
Created June 1, 2015 21:15
Feature with all Sub Features for Soruce.wim
DNS
DHCP
File-Services
RSAT
@BladeFireLight
BladeFireLight / Source-Features.txt
Created June 1, 2015 21:14
Feature list for Source.wim
AD-Domain-Services
AD-Certificate
ADCS-Cert-Authority
@BladeFireLight
BladeFireLight / Convert-WindowsIMage.ps1
Created June 1, 2015 21:13
Convert-WindowsImage Modified for use with Start-ImageBuild
<#
.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 / Update-SourceAndTemplate.ps1
Last active August 29, 2015 14:22
Update-SourceAndTempldate.ps1 for use with Start-ImageBuild.ps1
#requires -Version 3 -Modules Dism, Hyper-V
#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]
[ValidateNotNullOrEmpty()]
@BladeFireLight
BladeFireLight / verbose.ps1
Last active August 29, 2015 14:27
verbose example
function test-function
{
[CmdletBinding()]
Param()
$key = 'template'
$IsoPath = 'c:\iso\win2012r2.iso'
$UnattendPath = 'g:\temp\unattent.xml'
$Configdata = @{Template = @{ IsoEdition = 4} }
$CwiParamaters = @{
@BladeFireLight
BladeFireLight / 1-readme.txt
Last active August 29, 2015 14:27
MountImage Test
I have tested on Windows 10 and Hyper-V server 2012 R2
When a drive is mounted from a function inside a moduel the drive is not avalible to the module.
but if the function is part of a script or dot sorced it works.
Run Fails.ps1 first. (Fails)
Run Always-works.ps1 (Works)
the run Fails.ps1 again (Works)