Last active
August 29, 2015 14:22
-
-
Save BladeFireLight/39d8577425c5fa928526 to your computer and use it in GitHub Desktop.
Template FirstRun script for use with Start-ImageBuild.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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' | |
Trigger = New-ScheduledTaskTrigger -AtStartup | |
Settings = New-ScheduledTaskSettingsSet | |
} | |
$TaskObject = New-ScheduledTask @Paramaters | |
Register-ScheduledTask AtStartup -InputObject $TaskObject -User 'nt authority\system' -Verbose | |
Start-Sleep -Seconds 20 | |
Restart-Computer -Verbose -Force | |
Stop-Transcript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment