├── .gitattributes ├── Functions └── IMFFunctions │ ├── IMFFunctions.psd1 │ └── IMFFunctions.psm1 ├── IMF.ps1 ├── IMF.xml ├── Image Factory 4.lnk ├── Image.png ├── MDTApps ├── Action - Generate OSReport │ └── Generate-OSReport.ps1 ├── Action - Set OSRoleIndex │ └── SetOSRoleIndex.ps1 ├── Configure - Disable Services in Windows Server 2016 Desktop Edition │ └── Configure-DisableServicesforWindowsServer.ps1 ├── Configure - Windows Client │ └── Configure-WindowsClient.ps1 ├── Configure - Windows Server │ └── Configure-WindowsServer.ps1 ├── Install - C++ Runtime v14 framework package for Desktop Bridge │ └── Install-C++Runtimev14.ps1 ├── Install - Microsoft BGInfo - x86-x64 │ ├── Install-MicrosoftBGInfox86x64.wsf │ └── Source │ │ ├── Bginfo.lnk │ │ └── Custom.bgi ├── Install - Microsoft Visual C++ │ └── Install-MicrosoftVisualC++x86x64.wsf └── Install - Roles and Features │ └── InstallRolesAndFeatures.ps1 ├── ReadME.md ├── RunMe.ps1 ├── SampleScript.ps1 ├── Scripts ├── Convert-VIAWIM2VHD.ps1 ├── IMF-Archive.ps1 ├── IMF-Build.ps1 ├── IMF-Configure.ps1 ├── IMF-ConvertToVHD.ps1 ├── IMF-Display.ps1 ├── IMF-Display.txt ├── IMF-GenerateReport.ps1 ├── IMF-ImportISO.ps1 ├── IMF-Install.ps1 ├── IMF-Publish.ps1 ├── IMF-SCVMMImport.ps1 ├── IMF-Uninstall.ps1 ├── IMF-UpdateBootImage.ps1 ├── IMF-VerifyBuild.ps1 ├── IMF-VerifyCleanupVMs.ps1 ├── SampleScripts.ps1 └── ZTIBackup.wsf ├── Template ├── Bootstrap.ini └── CustomSettings.ini └── deploymentbunny-w175.ico /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /Functions/IMFFunctions/IMFFunctions.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeploymentBunny/IMF4/445174060bf86f1efe55ae9b592d907da2607dde/Functions/IMFFunctions/IMFFunctions.psd1 -------------------------------------------------------------------------------- /Functions/IMFFunctions/IMFFunctions.psm1: -------------------------------------------------------------------------------- 1 | Function Update-Log 2 | { 3 | Param( 4 | [Parameter( 5 | Mandatory=$true, 6 | ValueFromPipeline=$true, 7 | ValueFromPipelineByPropertyName=$true, 8 | Position=0 9 | )] 10 | [string]$Data, 11 | 12 | [Parameter( 13 | Mandatory=$false, 14 | ValueFromPipeline=$true, 15 | ValueFromPipelineByPropertyName=$true, 16 | Position=0 17 | )] 18 | [string]$Solution = $Solution, 19 | 20 | [Parameter( 21 | Mandatory=$false, 22 | ValueFromPipeline=$true, 23 | ValueFromPipelineByPropertyName=$true, 24 | Position=1 25 | )] 26 | [validateset('Information','Warning','Error')] 27 | [string]$Class = "Information" 28 | 29 | ) 30 | $global:ScriptLogFilePath = $Log 31 | $LogString = "$Solution, $Data, $Class, $(Get-Date)" 32 | $HostString = "$Solution, $Data, $(Get-Date)" 33 | 34 | 35 | Add-Content -Path $Log -Value $LogString 36 | switch ($Class) 37 | { 38 | 'Information'{ 39 | Write-Host $HostString -ForegroundColor Gray 40 | } 41 | 'Warning'{ 42 | Write-Host $HostString -ForegroundColor Yellow 43 | } 44 | 'Error'{ 45 | Write-Host $HostString -ForegroundColor Red 46 | } 47 | Default {} 48 | } 49 | } 50 | Function Test-VIAHypervConnection 51 | { 52 | Param( 53 | $Computername, 54 | $ISOFolder, 55 | $VMFolder, 56 | $VMSwitchName 57 | ) 58 | #Verify SMB access 59 | $Result = Test-NetConnection -ComputerName $Computername -CommonTCPPort SMB 60 | If ($Result.TcpTestSucceeded -eq $true){Write-Verbose "SMB Connection to $Computername is ok"}else{Write-Warning "SMB Connection to $Computername is NOT ok";Return $False} 61 | 62 | #Verify WinRM access 63 | $Result = Test-NetConnection -ComputerName $Computername -CommonTCPPort WINRM 64 | If ($Result.TcpTestSucceeded -eq $true){Write-Verbose "WINRM Connection to $Computername is ok"}else{Write-Warning "WINRM Connection to $Computername is NOT ok";Return $False} 65 | 66 | #Verify that Microsoft-Hyper-V-Management-PowerShell is installed 67 | Invoke-Command -ComputerName $Computername -ScriptBlock { 68 | $Result = (Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell) 69 | Write-Verbose "$($Result.DisplayName) is $($Result.State)" 70 | If($($Result.State) -ne "Enabled"){Write-Warning "$($Result.DisplayName) is not Enabled";Return $False} 71 | } 72 | 73 | #Verify that Microsoft-Hyper-V-Management-PowerShell is installed 74 | Invoke-Command -ComputerName $Computername -ScriptBlock { 75 | $Result = (Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V) 76 | If($($Result.State) -ne "Enabled"){Write-Warning "$($Result.DisplayName) is not Enabled";Return $False} 77 | } 78 | 79 | #Verify that Hyper-V is running 80 | Invoke-Command -ComputerName $Computername -ScriptBlock { 81 | $Result = (Get-Service -Name vmms) 82 | Write-Verbose "$($Result.DisplayName) is $($Result.Status)" 83 | If($($Result.Status) -ne "Running"){Write-Warning "$($Result.DisplayName) is not Running";Return $False} 84 | } 85 | 86 | #Verify that the ISO Folder is created 87 | Invoke-Command -ComputerName $Computername -ScriptBlock { 88 | Param( 89 | $ISOFolder 90 | ) 91 | $result = New-Item -Path $ISOFolder -ItemType Directory -Force 92 | } -ArgumentList $ISOFolder 93 | 94 | #Verify that the VM Folder is created 95 | Invoke-Command -ComputerName $Computername -ScriptBlock { 96 | Param( 97 | $VMFolder 98 | ) 99 | $result = New-Item -Path $VMFolder -ItemType Directory -Force 100 | } -ArgumentList $VMFolder 101 | 102 | #Verify that the VMSwitch exists 103 | Invoke-Command -ComputerName $Computername -ScriptBlock { 104 | Param( 105 | $VMSwitchName 106 | ) 107 | if(((Get-VMSwitch | Where-Object -Property Name -EQ -Value $VMSwitchName).count) -eq "1"){Write-Verbose "Found $VMSwitchName"}else{Write-Warning "No switch with the name $VMSwitchName found";Return $False} 108 | } -ArgumentList $VMSwitchName 109 | Return $True 110 | } 111 | Function Start-Log 112 | { 113 | [CmdletBinding()] 114 | param ( 115 | [ValidateScript({ Split-Path $_ -Parent | Test-Path })] 116 | [string]$FilePath 117 | ) 118 | 119 | try 120 | { 121 | if (!(Test-Path $FilePath)) 122 | { 123 | ## Create the log file 124 | New-Item $FilePath -Type File | Out-Null 125 | } 126 | 127 | ## Set the global variable to be used as the FilePath for all subsequent Write-Log 128 | ## calls in this session 129 | $global:ScriptLogFilePath = $FilePath 130 | } 131 | catch 132 | { 133 | Write-Error $_.Exception.Message 134 | } 135 | } 136 | Function Write-Log 137 | { 138 | param ( 139 | [Parameter(Mandatory = $true)] 140 | [string]$Message, 141 | 142 | [Parameter()] 143 | [ValidateSet(1, 2, 3)] 144 | [string]$LogLevel = 1 145 | ) 146 | 147 | $TimeGenerated = "$(Get-Date -Format HH:mm:ss).$((Get-Date).Millisecond)+000" 148 | $Line = '' 149 | $LineFormat = $Message, $TimeGenerated, (Get-Date -Format MM-dd-yyyy), "$($MyInvocation.ScriptName | Split-Path -Leaf):$($MyInvocation.ScriptLineNumber)", $LogLevel 150 | #$LineFormat = $Message, $TimeGenerated, (Get-Date -Format MM-dd-yyyy), "$($MyInvocation.ScriptName | Split-Path -Leaf)", $LogLevel 151 | $Line = $Line -f $LineFormat 152 | Add-Content -Value $Line -Path $ScriptLogFilePath 153 | 154 | if($writetoscreen -eq $true){ 155 | switch ($LogLevel) 156 | { 157 | '1'{ 158 | Write-Host $Message -ForegroundColor Gray 159 | } 160 | '2'{ 161 | Write-Host $Message -ForegroundColor Yellow 162 | } 163 | '3'{ 164 | Write-Host $Message -ForegroundColor Red 165 | } 166 | Default {} 167 | } 168 | } 169 | 170 | if($writetolistbox -eq $true){ 171 | $result1.Items.Add("$Message") 172 | } 173 | } 174 | Function Get-VIARefTaskSequence 175 | { 176 | Param( 177 | $RefTaskSequenceFolder 178 | ) 179 | $RefTaskSequences = Get-ChildItem $RefTaskSequenceFolder 180 | Foreach($RefTaskSequence in $RefTaskSequences){ 181 | New-Object PSObject -Property @{ 182 | TaskSequenceID = $RefTaskSequence.ID 183 | Name = $RefTaskSequence.Name 184 | Comments = $RefTaskSequence.Comments 185 | Version = $RefTaskSequence.Version 186 | Enabled = $RefTaskSequence.enable 187 | LastModified = $RefTaskSequence.LastModifiedTime 188 | } 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /IMF.ps1: -------------------------------------------------------------------------------- 1 | $DLL = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);' 2 | Add-Type -MemberDefinition $DLL -name NativeMethods -namespace Win32 3 | $Process = (Get-Process PowerShell | Where-Object MainWindowTitle -like '*Image Factory*').MainWindowHandle 4 | # Minimize window 5 | [Win32.NativeMethods]::ShowWindowAsync($Process, 2) 6 | 7 | #Pick up the logs 8 | $Global:writetolistbox = $true 9 | 10 | #region Constructor 11 | 12 | [void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") 13 | [void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") 14 | 15 | #endregion 16 | 17 | #Set Font 18 | $Font = "Consolas" 19 | 20 | #Set base values 21 | #Inititial Settings 22 | $CurrentPath = Split-Path -parent $MyInvocation.MyCommand.Path 23 | $RootPath = Split-Path -parent $CurrentPath 24 | $Global:ScriptLogFilePath = "$RootPath\IMF.log" 25 | $XMLFile = "$CurrentPath\IMF.xml" 26 | $Global:writetoscreen = $true 27 | 28 | #ReadData from XML 29 | [xml]$XMLdata = Get-Content -Path $XMLFile 30 | 31 | #region Form Creation 32 | #~~< Form1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 33 | $Form1 = New-Object System.Windows.Forms.Form 34 | $Form1.ClientSize = New-Object System.Drawing.Size(1300, 600) 35 | $Form1.Text = "IMF 4.0" 36 | $Form1.Icon = "$CurrentPath\deploymentbunny-w175.ico" 37 | #~~< Button1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 38 | $Button1 = New-Object System.Windows.Forms.Button 39 | $Button1.Location = New-Object System.Drawing.Point(1150, 550) 40 | $Button1.Size = New-Object System.Drawing.Size(100, 23) 41 | $Button1.TabIndex = 1 42 | $Button1.Text = "Close" 43 | $Button1.UseVisualStyleBackColor = $true 44 | $Button1.add_Click({Button1Click($Button1)}) 45 | #~~< result1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 46 | 47 | $Global:Result1 = New-Object System.Windows.Forms.ListBox 48 | $Global:Result1.Size = New-Object System.Drawing.Size(1260, 150) 49 | $Global:Result1.Location = New-Object System.Drawing.Point(20, 380) 50 | $Global:Result1.Font = New-Object System.Drawing.Font($font, 10) 51 | $Global:Result1.Items.Add("IMF 4.0 is ready.") 52 | 53 | #~~< PictureBox1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 54 | $PictureBox1 = New-Object system.Windows.Forms.PictureBox 55 | $PictureBox1.width = 90 56 | $PictureBox1.height = 90 57 | $PictureBox1.location = New-Object System.Drawing.Point(20,515) 58 | $PictureBox1.imageLocation = "$CurrentPath\image.png" 59 | $PictureBox1.SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::zoom 60 | 61 | #~~< TabControl1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 62 | $TabControl1 = New-Object System.Windows.Forms.TabControl 63 | $TabControl1.Font = New-Object System.Drawing.Font($font, 12) 64 | $TabControl1.Location = New-Object System.Drawing.Point(20, 20) 65 | $TabControl1.Size = New-Object System.Drawing.Size(1260, 350) 66 | $TabControl1.TabIndex = 0 67 | $TabControl1.Text = "" 68 | 69 | #region begin GUI{ 70 | #~~< TabPage1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 71 | $TabPage1 = New-Object System.Windows.Forms.TabPage 72 | $TabPage1.Font = New-Object System.Drawing.Font($font, 10) 73 | $TabPage1.Location = New-Object System.Drawing.Point(4, 22) 74 | $TabPage1.Padding = New-Object System.Windows.Forms.Padding(3) 75 | $TabPage1.Size = New-Object System.Drawing.Size(100, 400) 76 | $TabPage1.TabIndex = 0 77 | $TabPage1.Text = "Main" 78 | $TabPage1.UseVisualStyleBackColor = $true 79 | #~~< Label1Tab1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 80 | $Label1Tab1 = New-Object System.Windows.Forms.Label 81 | $Label1Tab1.Location = New-Object System.Drawing.Point(20, 30) 82 | $Label1Tab1.Size = New-Object System.Drawing.Size(500, 23) 83 | $Label1Tab1.Text = "Update and distribute the bootimage" 84 | #~~< Label2Tab1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 85 | $Label2Tab1 = New-Object System.Windows.Forms.Label 86 | $Label2Tab1.Location = New-Object System.Drawing.Point(20, 60) 87 | $Label2Tab1.Size = New-Object System.Drawing.Size(500, 23) 88 | $Label2Tab1.Text = "Remove Reference/Validation VMs" 89 | #~~< Label3Tab1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 90 | $Label3Tab1 = New-Object System.Windows.Forms.Label 91 | $Label3Tab1.Location = New-Object System.Drawing.Point(20, 90) 92 | $Label3Tab1.Size = New-Object System.Drawing.Size(500, 23) 93 | $Label3Tab1.Text = "Create reference image(s) WU Enable" 94 | #~~< Label4Tab1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 95 | $Label4Tab1 = New-Object System.Windows.Forms.Label 96 | $Label4Tab1.Location = New-Object System.Drawing.Point(20, 120) 97 | $Label4Tab1.Size = New-Object System.Drawing.Size(500, 23) 98 | $Label4Tab1.Text = "Create reference image(s) WU Disabled" 99 | #~~< Label4Tab1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 100 | $Label5Tab1 = New-Object System.Windows.Forms.Label 101 | $Label5Tab1.Location = New-Object System.Drawing.Point(20, 150) 102 | $Label5Tab1.Size = New-Object System.Drawing.Size(500, 23) 103 | $Label5Tab1.Text = "Validate reference image(s)" 104 | #~~< Label5Tab1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 105 | $Label6Tab1 = New-Object System.Windows.Forms.Label 106 | $Label6Tab1.Location = New-Object System.Drawing.Point(20, 180) 107 | $Label6Tab1.Size = New-Object System.Drawing.Size(500, 23) 108 | $Label6Tab1.Text = "Generate OS reports" 109 | #~~< Label7Tab1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 110 | $Label7Tab1 = New-Object System.Windows.Forms.Label 111 | $Label7Tab1.Location = New-Object System.Drawing.Point(20, 210) 112 | $Label7Tab1.Size = New-Object System.Drawing.Size(500, 23) 113 | $Label7Tab1.Text = "Archive WIM files" 114 | #~~< Button1Tab1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 115 | $Button1Tab1 = New-Object System.Windows.Forms.Button 116 | $Button1Tab1.Location = New-Object System.Drawing.Point(410, 30) 117 | $Button1Tab1.Size = New-Object System.Drawing.Size(100, 23) 118 | $Button1Tab1.TabIndex = 1 119 | $Button1Tab1.Text = "Run" 120 | $Button1Tab1.UseVisualStyleBackColor = $true 121 | $Button1Tab1.add_Click({Button1Tab1Click($Button1Tab1)}) 122 | #~~< Button2Tab1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 123 | $Button2Tab1 = New-Object System.Windows.Forms.Button 124 | $Button2Tab1.Location = New-Object System.Drawing.Point(410, 60) 125 | $Button2Tab1.Size = New-Object System.Drawing.Size(100, 23) 126 | $Button2Tab1.TabIndex = 2 127 | $Button2Tab1.Text = "Run" 128 | $Button2Tab1.UseVisualStyleBackColor = $true 129 | $Button2Tab1.add_Click({Button2Tab1Click($Button2Tab1)}) 130 | #~~< Button3Tab1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 131 | $Button3Tab1 = New-Object System.Windows.Forms.Button 132 | $Button3Tab1.Location = New-Object System.Drawing.Point(410, 90) 133 | $Button3Tab1.Size = New-Object System.Drawing.Size(100, 23) 134 | $Button3Tab1.TabIndex = 3 135 | $Button3Tab1.Text = "Run" 136 | $Button3Tab1.UseVisualStyleBackColor = $true 137 | $Button3Tab1.add_Click({Button3Tab1Click($Button3Tab1)}) 138 | #~~< Button4Tab1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 139 | $Button4Tab1 = New-Object System.Windows.Forms.Button 140 | $Button4Tab1.Location = New-Object System.Drawing.Point(410, 120) 141 | $Button4Tab1.Size = New-Object System.Drawing.Size(100, 23) 142 | $Button4Tab1.TabIndex = 3 143 | $Button4Tab1.Text = "Run" 144 | $Button4Tab1.UseVisualStyleBackColor = $true 145 | $Button4Tab1.add_Click({Button4Tab1Click($Button4Tab1)}) 146 | #~~< Button5Tab1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 147 | $Button5Tab1 = New-Object System.Windows.Forms.Button 148 | $Button5Tab1.Location = New-Object System.Drawing.Point(410, 150) 149 | $Button5Tab1.Size = New-Object System.Drawing.Size(100, 23) 150 | $Button5Tab1.TabIndex = 4 151 | $Button5Tab1.Text = "Run" 152 | $Button5Tab1.UseVisualStyleBackColor = $true 153 | $Button5Tab1.add_Click({Button5Tab1Click($Button5Tab1)}) 154 | #~~< Button6Tab1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 155 | $Button6Tab1 = New-Object System.Windows.Forms.Button 156 | $Button6Tab1.Location = New-Object System.Drawing.Point(410, 180) 157 | $Button6Tab1.Size = New-Object System.Drawing.Size(100, 23) 158 | $Button6Tab1.TabIndex = 4 159 | $Button6Tab1.Text = "Run" 160 | $Button6Tab1.UseVisualStyleBackColor = $true 161 | $Button6Tab1.add_Click({Button6Tab1Click($Button6Tab1)}) 162 | #~~< Button7Tab1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 163 | $Button7Tab1 = New-Object System.Windows.Forms.Button 164 | $Button7Tab1.Location = New-Object System.Drawing.Point(410, 210) 165 | $Button7Tab1.Size = New-Object System.Drawing.Size(100, 23) 166 | $Button7Tab1.TabIndex = 4 167 | $Button7Tab1.Text = "Run" 168 | $Button7Tab1.UseVisualStyleBackColor = $true 169 | $Button7Tab1.add_Click({Button7Tab1Click($Button7Tab1)}) 170 | 171 | 172 | $TabPage1.Controls.Add($Button1Tab1) 173 | $TabPage1.Controls.Add($Button2Tab1) 174 | $TabPage1.Controls.Add($Button3Tab1) 175 | $TabPage1.Controls.Add($Button4Tab1) 176 | $TabPage1.Controls.Add($Button5Tab1) 177 | $TabPage1.Controls.Add($Button6Tab1) 178 | $TabPage1.Controls.Add($Button7Tab1) 179 | $TabPage1.Controls.Add($Label1Tab1) 180 | $TabPage1.Controls.Add($Label2Tab1) 181 | $TabPage1.Controls.Add($Label3Tab1) 182 | $TabPage1.Controls.Add($Label4Tab1) 183 | $TabPage1.Controls.Add($Label5Tab1) 184 | $TabPage1.Controls.Add($Label6Tab1) 185 | $TabPage1.Controls.Add($Label7Tab1) 186 | $TabPage1.add_Click({TabPage1Click($TabPage1)}) 187 | 188 | #endregion GUI } 189 | 190 | #region begin GUI{ 191 | #~~< TabPage2 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 192 | $TabPage2 = New-Object System.Windows.Forms.TabPage 193 | $TabPage2.Font = New-Object System.Drawing.Font($font, 10) 194 | $TabPage2.Location = New-Object System.Drawing.Point(4, 22) 195 | $TabPage2.Padding = New-Object System.Windows.Forms.Padding(3) 196 | $TabPage2.Size = New-Object System.Drawing.Size(100, 400) 197 | $TabPage2.TabIndex = 1 198 | $TabPage2.Text = "Import OS" 199 | $TabPage2.UseVisualStyleBackColor = $true 200 | #~~< Label1Tab2 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 201 | $Label1Tab2 = New-Object System.Windows.Forms.Label 202 | $Label1Tab2.Location = New-Object System.Drawing.Point(20, 30) 203 | $Label1Tab2.Size = New-Object System.Drawing.Size(180, 23) 204 | $Label1Tab2.Text = "ISO Image" 205 | #~~< Label2Tab2 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 206 | $Label2Tab2 = New-Object System.Windows.Forms.Label 207 | $Label2Tab2.Location = New-Object System.Drawing.Point(20, 60) 208 | $Label2Tab2.Size = New-Object System.Drawing.Size(180, 23) 209 | $Label2Tab2.Text = "MDT Folder name" 210 | #~~< TextBox1Tab2 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 211 | $TextBox1Tab2 = New-Object System.Windows.Forms.TextBox 212 | $TextBox1Tab2.Location = New-Object System.Drawing.Point(200, 30) 213 | $TextBox1Tab2.Size = New-Object System.Drawing.Size(600, 20) 214 | $TextBox1Tab2.TabIndex = 1 215 | $TextBox1Tab2.Text = "ISO File Name and path" 216 | #~~< TextBox2Tab2 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 217 | $TextBox2Tab2 = New-Object System.Windows.Forms.TextBox 218 | $TextBox2Tab2.Location = New-Object System.Drawing.Point(200, 60) 219 | $TextBox2Tab2.Size = New-Object System.Drawing.Size(600, 20) 220 | $TextBox2Tab2.TabIndex = 3 221 | $TextBox2Tab2.Text = "Foldername" 222 | #~~< Button1Tab2 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 223 | $Button1Tab2 = New-Object System.Windows.Forms.Button 224 | $Button1Tab2.Location = New-Object System.Drawing.Point(820, 30) 225 | $Button1Tab2.Size = New-Object System.Drawing.Size(100, 23) 226 | $Button1Tab2.TabIndex = 2 227 | $Button1Tab2.Text = "Browse" 228 | $Button1Tab2.UseVisualStyleBackColor = $true 229 | $Button1Tab2.add_Click({Button1Tab2Click($Button1Tab2)}) 230 | #~~< Button2Tab2 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 231 | $Button2Tab2 = New-Object System.Windows.Forms.Button 232 | $Button2Tab2.Location = New-Object System.Drawing.Point(1120, 280) 233 | $Button2Tab2.Size = New-Object System.Drawing.Size(100, 23) 234 | $Button2Tab2.TabIndex = 17 235 | $Button2Tab2.Text = "Import" 236 | $Button2Tab2.UseVisualStyleBackColor = $true 237 | $Button2Tab2.add_Click({Button2Tab2Click($Button2Tab2)}) 238 | 239 | $TabPage2.Controls.Add($Button2Tab2) 240 | $TabPage2.Controls.Add($Button1Tab2) 241 | $TabPage2.Controls.Add($TextBox1Tab2) 242 | $TabPage2.Controls.Add($TextBox2Tab2) 243 | $TabPage2.Controls.Add($Label1Tab2) 244 | $TabPage2.Controls.Add($Label2Tab2) 245 | $TabPage2.add_Click({TabPage2Click($TabPage2)}) 246 | #endregion GUI } 247 | 248 | #region begin GUI{ 249 | 250 | #~~< TabPage3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 251 | $TabPage3 = New-Object System.Windows.Forms.TabPage 252 | $TabPage3.Font = New-Object System.Drawing.Font($font, 10) 253 | $TabPage3.Location = New-Object System.Drawing.Point(4, 22) 254 | $TabPage3.Padding = New-Object System.Windows.Forms.Padding(3) 255 | $TabPage3.Size = New-Object System.Drawing.Size(100, 400) 256 | $TabPage3.TabIndex = 2 257 | $TabPage3.Text = "Configuration" 258 | $TabPage3.UseVisualStyleBackColor = $true 259 | #~~< Label1Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 260 | $Label1Tab3 = New-Object System.Windows.Forms.Label 261 | $Label1Tab3.Location = New-Object System.Drawing.Point(20, 30) 262 | $Label1Tab3.Size = New-Object System.Drawing.Size(180, 23) 263 | $Label1Tab3.Text = "MDT DeploymentShare" 264 | #~~< Label2Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 265 | $Label2Tab3 = New-Object System.Windows.Forms.Label 266 | $Label2Tab3.Location = New-Object System.Drawing.Point(20, 60) 267 | $Label2Tab3.Size = New-Object System.Drawing.Size(180, 23) 268 | $Label2Tab3.Text = "Hyper-V Computername" 269 | #~~< Label3Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 270 | $Label3Tab3 = New-Object System.Windows.Forms.Label 271 | $Label3Tab3.Location = New-Object System.Drawing.Point(20, 90) 272 | $Label3Tab3.Size = New-Object System.Drawing.Size(180, 23) 273 | $Label3Tab3.Text = "Hyper-V Switch name" 274 | #~~< Label4Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 275 | $Label4Tab3 = New-Object System.Windows.Forms.Label 276 | $Label4Tab3.Location = New-Object System.Drawing.Point(20, 120) 277 | $Label4Tab3.Size = New-Object System.Drawing.Size(180, 23) 278 | $Label4Tab3.Text = "VLAN ID" 279 | #~~< Label4Tab2 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 280 | $Label5Tab3 = New-Object System.Windows.Forms.Label 281 | $Label5Tab3.Location = New-Object System.Drawing.Point(20, 150) 282 | $Label5Tab3.Size = New-Object System.Drawing.Size(180, 23) 283 | $Label5Tab3.Text = "VM Location" 284 | #~~< Label5Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 285 | $Label6Tab3 = New-Object System.Windows.Forms.Label 286 | $Label6Tab3.Location = New-Object System.Drawing.Point(20, 180) 287 | $Label6Tab3.Size = New-Object System.Drawing.Size(180, 23) 288 | $Label6Tab3.Text = "ISO Location" 289 | #~~< Label6Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 290 | $Label7Tab3 = New-Object System.Windows.Forms.Label 291 | $Label7Tab3.Location = New-Object System.Drawing.Point(20, 210) 292 | $Label7Tab3.Size = New-Object System.Drawing.Size(180, 23) 293 | $Label7Tab3.Text = "BuildAccount Name" 294 | #~~< Label7Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 295 | $Label8Tab3 = New-Object System.Windows.Forms.Label 296 | $Label8Tab3.Location = New-Object System.Drawing.Point(20, 240) 297 | $Label8Tab3.Size = New-Object System.Drawing.Size(180, 23) 298 | $Label8Tab3.Text = "BuildAccount Password" 299 | #~~< Label9Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 300 | $Label9Tab3 = New-Object System.Windows.Forms.Label 301 | $Label9Tab3.Location = New-Object System.Drawing.Point(20, 270) 302 | $Label9Tab3.Size = New-Object System.Drawing.Size(180, 23) 303 | $Label9Tab3.Text = "Customer Name" 304 | #~~< TextBox1Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 305 | $TextBox1Tab3 = New-Object System.Windows.Forms.TextBox 306 | $TextBox1Tab3.Location = New-Object System.Drawing.Point(200, 30) 307 | $TextBox1Tab3.Size = New-Object System.Drawing.Size(600, 20) 308 | $TextBox1Tab3.TabIndex = 15 309 | $TextBox1Tab3.Text = "$($XMLdata.Settings.MDT.DeploymentShare)" 310 | #~~< TextBox2Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 311 | $TextBox2Tab3 = New-Object System.Windows.Forms.TextBox 312 | $TextBox2Tab3.Location = New-Object System.Drawing.Point(200, 60) 313 | $TextBox2Tab3.Size = New-Object System.Drawing.Size(600, 20) 314 | $TextBox2Tab3.TabIndex = 14 315 | $TextBox2Tab3.Text = $XMLdata.Settings.HyperV.Computername 316 | #~~< TextBox3Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 317 | $TextBox3Tab3 = New-Object System.Windows.Forms.TextBox 318 | $TextBox3Tab3.Location = New-Object System.Drawing.Point(200, 90) 319 | $TextBox3Tab3.Size = New-Object System.Drawing.Size(600, 20) 320 | $TextBox3Tab3.TabIndex = 13 321 | $TextBox3Tab3.Text = $XMLdata.Settings.HyperV.SwitchName 322 | #~~< TextBox4Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 323 | $TextBox4Tab3 = New-Object System.Windows.Forms.TextBox 324 | $TextBox4Tab3.Location = New-Object System.Drawing.Point(200, 120) 325 | $TextBox4Tab3.Size = New-Object System.Drawing.Size(600, 20) 326 | $TextBox4Tab3.TabIndex = 9 327 | $TextBox4Tab3.Text = $XMLdata.Settings.HyperV.VLANID 328 | #~~< TextBox5Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 329 | $TextBox5Tab3 = New-Object System.Windows.Forms.TextBox 330 | $TextBox5Tab3.Location = New-Object System.Drawing.Point(200, 150) 331 | $TextBox5Tab3.Size = New-Object System.Drawing.Size(600, 20) 332 | $TextBox5Tab3.TabIndex = 9 333 | $TextBox5Tab3.Text = $XMLdata.Settings.HyperV.VMLocation 334 | #~~< TextBox6Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 335 | $TextBox6Tab3 = New-Object System.Windows.Forms.TextBox 336 | $TextBox6Tab3.Location = New-Object System.Drawing.Point(200, 180) 337 | $TextBox6Tab3.Size = New-Object System.Drawing.Size(600, 20) 338 | $TextBox6Tab3.TabIndex = 9 339 | $TextBox6Tab3.Text = $XMLdata.Settings.HyperV.ISOLocation 340 | #~~< TextBox7Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 341 | $TextBox7Tab3 = New-Object System.Windows.Forms.TextBox 342 | $TextBox7Tab3.Location = New-Object System.Drawing.Point(200, 210) 343 | $TextBox7Tab3.Size = New-Object System.Drawing.Size(600, 20) 344 | $TextBox7Tab3.TabIndex = 9 345 | $TextBox7Tab3.Text = $XMLdata.Settings.Security.BuildAccount.Name 346 | #~~< TextBox8Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 347 | $TextBox8Tab3 = New-Object System.Windows.Forms.TextBox 348 | $TextBox8Tab3.Location = New-Object System.Drawing.Point(200, 240) 349 | $TextBox8Tab3.Size = New-Object System.Drawing.Size(600, 20) 350 | $TextBox8Tab3.TabIndex = 9 351 | $TextBox8Tab3.Text = $XMLdata.Settings.Security.BuildAccount.Password 352 | #~~< TextBox9Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 353 | $TextBox9Tab3 = New-Object System.Windows.Forms.TextBox 354 | $TextBox9Tab3.Location = New-Object System.Drawing.Point(200, 270) 355 | $TextBox9Tab3.Size = New-Object System.Drawing.Size(600, 20) 356 | $TextBox9Tab3.TabIndex = 9 357 | $TextBox9Tab3.Text = $XMLdata.Settings.CustomerName 358 | 359 | 360 | #~~< Button1Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 361 | $Button1Tab3 = New-Object System.Windows.Forms.Button 362 | $Button1Tab3.Location = New-Object System.Drawing.Point(1000, 30) 363 | $Button1Tab3.Size = New-Object System.Drawing.Size(200, 50) 364 | $Button1Tab3.TabIndex = 17 365 | $Button1Tab3.Text = "Save configuration" 366 | $Button1Tab3.UseVisualStyleBackColor = $true 367 | $Button1Tab3.add_Click({Button1Tab3Click($Button1Tab3)}) 368 | 369 | #~~< Button2Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 370 | $Button2Tab3 = New-Object System.Windows.Forms.Button 371 | $Button2Tab3.Location = New-Object System.Drawing.Point(1000, 120) 372 | $Button2Tab3.Size = New-Object System.Drawing.Size(200, 50) 373 | $Button2Tab3.TabIndex = 17 374 | $Button2Tab3.Text = "Install IMF" 375 | $Button2Tab3.UseVisualStyleBackColor = $true 376 | $Button2Tab3.add_Click({Button2Tab3Click($Button2Tab3)}) 377 | 378 | #~~< Button3Tab3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 379 | $Button3Tab3 = New-Object System.Windows.Forms.Button 380 | $Button3Tab3.Location = New-Object System.Drawing.Point(1000, 210) 381 | $Button3Tab3.Size = New-Object System.Drawing.Size(200, 50) 382 | $Button3Tab3.TabIndex = 17 383 | $Button3Tab3.Text = "Uninstall IMF" 384 | $Button3Tab3.UseVisualStyleBackColor = $true 385 | $Button3Tab3.add_Click({Button3Tab3Click($Button3Tab3)}) 386 | 387 | 388 | $TabPage3.Controls.Add($Label1Tab3) 389 | $TabPage3.Controls.Add($Label2Tab3) 390 | $TabPage3.Controls.Add($Label3Tab3) 391 | $TabPage3.Controls.Add($Label4Tab3) 392 | $TabPage3.Controls.Add($Label4Tab3) 393 | $TabPage3.Controls.Add($Label5Tab3) 394 | $TabPage3.Controls.Add($Label6Tab3) 395 | $TabPage3.Controls.Add($Label7Tab3) 396 | $TabPage3.Controls.Add($Label8Tab3) 397 | $TabPage3.Controls.Add($Label9Tab3) 398 | $TabPage3.Controls.Add($TextBox1Tab3) 399 | $TabPage3.Controls.Add($TextBox2Tab3) 400 | $TabPage3.Controls.Add($TextBox3Tab3) 401 | $TabPage3.Controls.Add($TextBox4Tab3) 402 | $TabPage3.Controls.Add($TextBox5Tab3) 403 | $TabPage3.Controls.Add($TextBox6Tab3) 404 | $TabPage3.Controls.Add($TextBox7Tab3) 405 | $TabPage3.Controls.Add($TextBox8Tab3) 406 | $TabPage3.Controls.Add($TextBox9Tab3) 407 | $TabPage3.Controls.Add($Button1Tab3) 408 | $TabPage3.Controls.Add($Button2Tab3) 409 | $TabPage3.Controls.Add($Button3Tab3) 410 | $TabPage3.add_Click({TabPage3Click($TabPage3)}) 411 | 412 | #endregion GUI} 413 | 414 | #region begin GUI{ 415 | $TabControl1.Controls.Add($TabPage1) 416 | $TabControl1.Controls.Add($TabPage2) 417 | $TabControl1.Controls.Add($TabPage3) 418 | $TabControl1.SelectedIndex = 0 419 | $Form1.Controls.Add($Button1) 420 | $Form1.Controls.Add($TabControl1) 421 | $Form1.Controls.Add($result1) 422 | $Form1.Controls.Add($PictureBox1) 423 | 424 | #endregion GUI} 425 | 426 | #~~< OpenFileDialog1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 427 | $OpenFileDialog1 = New-Object System.Windows.Forms.OpenFileDialog 428 | $OpenFileDialog1.Filter = "ISO Images (*.iso)|*.iso|All files (*.*)|*.*" 429 | $OpenFileDialog1.CheckFileExists 430 | 431 | #~~< FolderBrowserDialog1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 432 | $FolderBrowserDialog1 = New-Object System.Windows.Forms.FolderBrowserDialog 433 | 434 | function Main{ 435 | [System.Windows.Forms.Application]::EnableVisualStyles() 436 | [System.Windows.Forms.Application]::Run($Form1) 437 | } 438 | 439 | #region Event Handlers 440 | 441 | function TabPage1Click( $object ){ 442 | 443 | } 444 | 445 | function TabPage2Click( $object ){ 446 | 447 | } 448 | 449 | function TabPage3Click( $object ){ 450 | 451 | } 452 | 453 | function Button1Click( $object ){ 454 | #Close 455 | $Form1.Close() 456 | } 457 | 458 | function Button1Tab1Click( $object ){ 459 | $result1.Items.Clear() 460 | $result1.Items.Add("Update and distribute the bootimage") 461 | Start-Sleep -Seconds 1 462 | Set-Location $CurrentPath 463 | $ScriptBlock = [ScriptBlock]::Create(".\Scripts\IMF-UpdateBootImage.ps1") 464 | Invoke-Command -ScriptBlock $ScriptBlock 465 | } 466 | 467 | function Button2Tab1Click( $object ){ 468 | $result1.Items.Clear() 469 | $result1.Items.Add("Remove Reference/Validation VMs") 470 | Start-Sleep -Seconds 1 471 | Set-Location $CurrentPath 472 | $ScriptBlock = [ScriptBlock]::Create(".\Scripts\IMF-VerifyCleanupVMs.ps1") 473 | Invoke-Command -ScriptBlock $ScriptBlock 474 | } 475 | 476 | function Button3Tab1Click( $object ){ 477 | $result1.Items.Clear() 478 | $result1.Items.Add("Create reference image(s) with patches") 479 | Start-Sleep -Seconds 1 480 | Set-Location $CurrentPath 481 | $ScriptBlock = [ScriptBlock]::Create(".\Scripts\IMF-Build.ps1 -EnableWSUS True") 482 | Invoke-Command -ScriptBlock $ScriptBlock 483 | } 484 | 485 | function Button4Tab1Click( $object ){ 486 | $result1.Items.Clear() 487 | $result1.Items.Add("Create reference image(s) without patches") 488 | Start-Sleep -Seconds 1 489 | Set-Location $CurrentPath 490 | $ScriptBlock = [ScriptBlock]::Create(".\Scripts\IMF-Build.ps1 -EnableWSUS False") 491 | Invoke-Command -ScriptBlock $ScriptBlock 492 | } 493 | 494 | function Button5Tab1Click( $object ){ 495 | $result1.Items.Clear() 496 | $result1.Items.Add("building validation VM(s)") 497 | Start-Sleep -Seconds 1 498 | Set-Location $CurrentPath 499 | $ScriptBlock = [ScriptBlock]::Create(".\Scripts\IMF-VerifyBuild.ps1 -KeepVMs False") 500 | Invoke-Command -ScriptBlock $ScriptBlock 501 | } 502 | 503 | function Button6Tab1Click( $object ){ 504 | $result1.Items.Clear() 505 | $result1.Items.Add("Generate OS reports") 506 | Start-Sleep -Seconds 1 507 | Set-Location $CurrentPath 508 | $ScriptBlock = [ScriptBlock]::Create(".\Scripts\IMF-GenerateReport.ps1") 509 | Invoke-Command -ScriptBlock $ScriptBlock 510 | } 511 | 512 | function Button7Tab1Click( $object ){ 513 | $result1.Items.Clear() 514 | $result1.Items.Add("Archive WIM files") 515 | Start-Sleep -Seconds 1 516 | Set-Location $CurrentPath 517 | $ScriptBlock = [ScriptBlock]::Create(".\Scripts\IMF-Archive.ps1") 518 | Invoke-Command -ScriptBlock $ScriptBlock 519 | } 520 | 521 | function Button1Tab2Click( $object ){ 522 | $result = $OpenFileDialog1.ShowDialog() 523 | if($result -eq "ok"){ 524 | $TextBox1Tab2.Text = $OpenFileDialog1.FileName 525 | } 526 | } 527 | 528 | function Button2Tab2Click( $object ){ 529 | $result1.Items.Clear() 530 | $result1.Items.Add("Import") 531 | Start-Sleep -Seconds 1 532 | Set-Location $CurrentPath 533 | $ScriptBlock = [ScriptBlock]::Create(".\Scripts\IMF-ImportISO.ps1 -ISOImage $($TextBox1Tab2.Text) -OSFolder $($TextBox2Tab2.Text) -OrgName $($Settings.Settings.CustomerName)") 534 | Invoke-Command -ScriptBlock $ScriptBlock 535 | } 536 | 537 | function Button1Tab3Click( $object ){ 538 | $result1.Items.Clear() 539 | $result1.Items.Add("Saving configuration") 540 | Start-Sleep -Seconds 1 541 | Set-Location $CurrentPath 542 | $ScriptBlock = [ScriptBlock]::Create(".\Scripts\IMF-Configure.ps1 -DeploymentShare $($TextBox1Tab3.Text) -StartUpRAM 3 -VLANID $($TextBox4Tab3.Text) -Computername $($TextBox2Tab3.Text) -SwitchName $($TextBox3Tab3.Text) -VMLocation $($TextBox5Tab3.Text) -ISOLocation $($TextBox6Tab3.Text) -BuildaccountName $($TextBox7Tab3.Text) -BuildaccountPassword $($TextBox8Tab3.Text) -CustomerName $($TextBox9Tab3.Text)") 543 | Invoke-Command -ScriptBlock $ScriptBlock 544 | } 545 | 546 | function Button2Tab3Click( $object ){ 547 | $result1.Items.Clear() 548 | $result1.Items.Add("Installing") 549 | Start-Sleep -Seconds 1 550 | Set-Location $CurrentPath 551 | $ScriptBlock = [ScriptBlock]::Create(".\Scripts\IMF-Install.ps1") 552 | Invoke-Command -ScriptBlock $ScriptBlock 553 | } 554 | 555 | function Button3Tab3Click( $object ){ 556 | $result1.Items.Clear() 557 | $result1.Items.Add("Uninstalling") 558 | Start-Sleep -Seconds 1 559 | Set-Location $CurrentPath 560 | $ScriptBlock = [ScriptBlock]::Create(".\Scripts\IMF-UnInstall.ps1") 561 | Invoke-Command -ScriptBlock $ScriptBlock 562 | } 563 | 564 | Main # This call must remain below all other event functions 565 | 566 | #endregion 567 | 568 | 569 | -------------------------------------------------------------------------------- /IMF.xml: -------------------------------------------------------------------------------- 1 | 2 | 2 3 | ViaMonstra 4 | E:\Images 5 | E:\Images 6 | 7 | C:\MDTBuildLab 8 | Reference 9 | Validate 10 | Validate 11 | Validate 12 | Action - Generate OSReport 13 | 14 | 15 | 3 16 | 0 17 | HOST01 18 | UplinkSwitch 19 | C:\VMs 20 | C:\ISO 21 | 80 22 | 2 23 | 24 | 25 | 26 | MDT_BA 27 | Passw0rd 28 | LOCAL 29 | 30 | 31 | 32 | False 33 | SFASCVM01 34 | 35 | -------------------------------------------------------------------------------- /Image Factory 4.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeploymentBunny/IMF4/445174060bf86f1efe55ae9b592d907da2607dde/Image Factory 4.lnk -------------------------------------------------------------------------------- /Image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeploymentBunny/IMF4/445174060bf86f1efe55ae9b592d907da2607dde/Image.png -------------------------------------------------------------------------------- /MDTApps/Action - Generate OSReport/Generate-OSReport.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | ImageFactory 3.3 4 | .DESCRIPTION 5 | ImageFactory 3.3 6 | .EXAMPLE 7 | ImageFactoryV3-Verify-ShowContent.ps1 8 | .NOTES 9 | Created: 2016-11-24 10 | Version: 3.1 11 | 12 | Updated: 2017-02-23 13 | Version: 3.2 14 | 15 | Updated: 2017-09-27 16 | Version: 3.3 17 | 18 | Author - Mikael Nystrom 19 | Twitter: @mikael_nystrom 20 | Blog : http://deploymentbunny.com 21 | 22 | Disclaimer: 23 | This script is provided 'AS IS' with no warranties, confers no rights and 24 | is not supported by the author. 25 | 26 | This script uses the PsIni module: 27 | Blog : http://oliver.lipkau.net/blog/ 28 | Source : https://github.com/lipkau/PsIni 29 | http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 30 | 31 | .LINK 32 | http://www.deploymentbunny.com 33 | #> 34 | 35 | Function Import-SMSTSENV{ 36 | try 37 | { 38 | $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment 39 | Write-Output "$ScriptName - tsenv is $tsenv " 40 | $MDTIntegration = "YES" 41 | 42 | #$tsenv.GetVariables() | % { Write-Output "$ScriptName - $_ = $($tsenv.Value($_))" } 43 | } 44 | catch 45 | { 46 | Write-Output "$ScriptName - Unable to load Microsoft.SMS.TSEnvironment" 47 | Write-Output "$ScriptName - Running in standalonemode" 48 | $MDTIntegration = "NO" 49 | } 50 | Finally 51 | { 52 | if ($MDTIntegration -eq "YES"){ 53 | $Logpath = $tsenv.Value("LogPath") 54 | $LogFile = $Logpath + "\" + "$ScriptName.log" 55 | 56 | } 57 | Else{ 58 | $Logpath = $env:TEMP 59 | $LogFile = $Logpath + "\" + "$ScriptName.log" 60 | } 61 | } 62 | } 63 | Function Start-Logging{ 64 | start-transcript -path $LogFile -Force 65 | } 66 | Function Stop-Logging{ 67 | Stop-Transcript 68 | } 69 | Function Invoke-Exe{ 70 | [CmdletBinding(SupportsShouldProcess=$true)] 71 | 72 | param( 73 | [parameter(mandatory=$true,position=0)] 74 | [ValidateNotNullOrEmpty()] 75 | [string] 76 | $Executable, 77 | 78 | [parameter(mandatory=$false,position=1)] 79 | [string] 80 | $Arguments 81 | ) 82 | 83 | if($Arguments -eq "") 84 | { 85 | Write-Verbose "Running $ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru" 86 | $ReturnFromEXE = Start-Process -FilePath $Executable -NoNewWindow -Wait -Passthru 87 | }else{ 88 | Write-Verbose "Running $ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru" 89 | $ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru 90 | } 91 | Write-Verbose "Returncode is $($ReturnFromEXE.ExitCode)" 92 | Return $ReturnFromEXE.ExitCode 93 | } 94 | 95 | # Set vars 96 | $SCRIPTDIR = split-path -parent $MyInvocation.MyCommand.Path 97 | $SCRIPTNAME = split-path -leaf $MyInvocation.MyCommand.Path 98 | $SOURCEROOT = "$SCRIPTDIR\Source" 99 | $SettingsFile = $SCRIPTDIR + "\" + $SettingsName 100 | $LANG = (Get-Culture).Name 101 | $OSV = $Null 102 | $ARCHITECTURE = $env:PROCESSOR_ARCHITECTURE 103 | 104 | #Try to Import SMSTSEnv 105 | . Import-SMSTSENV 106 | 107 | # Set more vars 108 | $Make = $tsenv.Value("Make") 109 | $Model = $tsenv.Value("Model") 110 | $ModelAlias = $tsenv.Value("ModelAlias") 111 | $MakeAlias = $tsenv.Value("MakeAlias") 112 | $OSDComputername = $tsenv.Value("OSDComputername") 113 | 114 | #Start Transcript Logging 115 | . Start-Logging 116 | 117 | #Output base info 118 | Write-Output "" 119 | Write-Output "$ScriptName - ScriptDir: $ScriptDir" 120 | Write-Output "$ScriptName - SourceRoot: $SOURCEROOT" 121 | Write-Output "$ScriptName - ScriptName: $ScriptName" 122 | Write-Output "$ScriptName - Current Culture: $LANG" 123 | Write-Output "$ScriptName - Integration with MDT(LTI/ZTI): $MDTIntegration" 124 | Write-Output "$ScriptName - Log: $LogFile" 125 | Write-Output "$ScriptName - Model (win32_computersystem): $((Get-WmiObject Win32_ComputerSystem).model)" 126 | Write-Output "$ScriptName - Name (Win32_ComputerSystemProduct): $((Get-WmiObject Win32_ComputerSystemProduct).Name)" 127 | Write-Output "$ScriptName - Version (Win32_ComputerSystemProduct): $((Get-WmiObject Win32_ComputerSystemProduct).Version)" 128 | Write-Output "$ScriptName - Model (from TSENV): $Model" 129 | Write-Output "$ScriptName - ModelAlias (from TSENV): $ModelAlias" 130 | Write-Output "$ScriptName - OSDComputername (from TSENV): $OSDComputername" 131 | Write-Output "$ScriptName - ModelAlias (from TSENV): $ModelAlias" 132 | Write-Output "$ScriptName - OSDComputername (from TSENV): $OSDComputername" 133 | 134 | $CaptureTaskSequenceID = (Get-WMIObject –Class Microsoft_BDD_Info).CaptureTaskSequenceID 135 | $ReportRootFolderName = $tsenv.Value("ReportFolder") 136 | Write-Output "$ScriptName - ReportFolder (from TSENV): $ReportRootFolderName" 137 | Write-Output "$ScriptName - CaptureTaskSequenceID (from WMI): $CaptureTaskSequenceID" 138 | 139 | $ReportFolder = New-Item -Path $($ReportRootFolderName + "\" + $CaptureTaskSequenceID) -ItemType Directory -Force 140 | Write-Output "$ScriptName - $($ReportFolder.FullName)" 141 | 142 | Get-WMIObject –Class Microsoft_BDD_Info | ConvertTo-Csv -NoTypeInformation | Out-File -FilePath "$($ReportFolder.FullName)\Microsoft_BDD_Info.csv" -Force 143 | Get-WmiObject -Class Win32_OperatingSystem | ConvertTo-Csv -NoTypeInformation | Out-File -FilePath "$($ReportFolder.FullName)\Win32_OperatingSystem.csv" -Force 144 | Get-WmiObject -class Win32_QuickFixEngineering | ConvertTo-Csv -NoTypeInformation | Out-File -FilePath "$($ReportFolder.FullName)\Win32_QuickFixEngineering.csv" -Force 145 | Get-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -ne $null | ConvertTo-Csv -NoTypeInformation | Out-File -FilePath "$($ReportFolder.FullName)\UninstallKey.csv" -Force 146 | Get-ItemProperty -Path HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -ne $null | ConvertTo-Csv -NoTypeInformation | Out-File -FilePath "$($ReportFolder.FullName)\UninstallKeyWow6432Node.csv" -Force 147 | 148 | Get-AppxPackage | Select-Object Name,Version | ConvertTo-Csv -NoTypeInformation | Out-File -FilePath "$($ReportFolder.FullName)\AppxPackage.csv" -Force 149 | Get-WindowsOptionalFeature -Online -LogPath "C:\dismlog.log" | Where-Object State -EQ Enabled | ConvertTo-Csv -NoTypeInformation | Out-File -FilePath "$($ReportFolder.FullName)\WindowsOptionalFeature.csv" -Force 150 | -------------------------------------------------------------------------------- /MDTApps/Action - Set OSRoleIndex/SetOSRoleIndex.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | ImageFactory 3.3 4 | .DESCRIPTION 5 | ImageFactory 3.3 6 | .EXAMPLE 7 | ImageFactoryV3-Verify-ShowContent.ps1 8 | .NOTES 9 | Created: 2016-11-24 10 | Version: 3.1 11 | 12 | Updated: 2017-02-23 13 | Version: 3.2 14 | 15 | Updated: 2017-09-27 16 | Version: 3.3 17 | 18 | Author - Mikael Nystrom 19 | Twitter: @mikael_nystrom 20 | Blog : http://deploymentbunny.com 21 | 22 | Disclaimer: 23 | This script is provided 'AS IS' with no warranties, confers no rights and 24 | is not supported by the author. 25 | 26 | This script uses the PsIni module: 27 | Blog : http://oliver.lipkau.net/blog/ 28 | Source : https://github.com/lipkau/PsIni 29 | http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 30 | 31 | .LINK 32 | http://www.deploymentbunny.com 33 | #> 34 | 35 | Function Import-SMSTSENV{ 36 | try 37 | { 38 | $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment 39 | Write-Output "$ScriptName - tsenv is $tsenv " 40 | $MDTIntegration = "YES" 41 | 42 | #$tsenv.GetVariables() | % { Write-Output "$ScriptName - $_ = $($tsenv.Value($_))" } 43 | } 44 | catch 45 | { 46 | Write-Output "$ScriptName - Unable to load Microsoft.SMS.TSEnvironment" 47 | Write-Output "$ScriptName - Running in standalonemode" 48 | $MDTIntegration = "NO" 49 | } 50 | Finally 51 | { 52 | if ($MDTIntegration -eq "YES"){ 53 | $Logpath = $tsenv.Value("LogPath") 54 | $LogFile = $Logpath + "\" + "$ScriptName.log" 55 | 56 | } 57 | Else{ 58 | $Logpath = $env:TEMP 59 | $LogFile = $Logpath + "\" + "$ScriptName.log" 60 | } 61 | } 62 | } 63 | Function Start-Logging{ 64 | start-transcript -path $LogFile -Force 65 | } 66 | Function Stop-Logging{ 67 | Stop-Transcript 68 | } 69 | 70 | # Set vars 71 | $SCRIPTDIR = split-path -parent $MyInvocation.MyCommand.Path 72 | $SCRIPTNAME = split-path -leaf $MyInvocation.MyCommand.Path 73 | $SOURCEROOT = "$SCRIPTDIR\Source" 74 | $SettingsFile = $SCRIPTDIR + "\" + $SettingsName 75 | $LANG = (Get-Culture).Name 76 | $OSV = $Null 77 | $ARCHITECTURE = $env:PROCESSOR_ARCHITECTURE 78 | 79 | #Try to Import SMSTSEnv 80 | . Import-SMSTSENV 81 | 82 | # Set more vars 83 | $Make = $tsenv.Value("Make") 84 | $Model = $tsenv.Value("Model") 85 | $ModelAlias = $tsenv.Value("ModelAlias") 86 | $MakeAlias = $tsenv.Value("MakeAlias") 87 | $OSDComputername = $tsenv.Value("OSDComputername") 88 | 89 | #Start Transcript Logging 90 | . Start-Logging 91 | 92 | #Output base info 93 | Write-Output "" 94 | Write-Output "$ScriptName - ScriptDir: $ScriptDir" 95 | Write-Output "$ScriptName - SourceRoot: $SOURCEROOT" 96 | Write-Output "$ScriptName - ScriptName: $ScriptName" 97 | Write-Output "$ScriptName - Current Culture: $LANG" 98 | Write-Output "$ScriptName - Integration with MDT(LTI/ZTI): $MDTIntegration" 99 | Write-Output "$ScriptName - Log: $LogFile" 100 | Write-Output "$ScriptName - Model (win32_computersystem): $((Get-WmiObject Win32_ComputerSystem).model)" 101 | Write-Output "$ScriptName - Name (Win32_ComputerSystemProduct): $((Get-WmiObject Win32_ComputerSystemProduct).Name)" 102 | Write-Output "$ScriptName - Version (Win32_ComputerSystemProduct): $((Get-WmiObject Win32_ComputerSystemProduct).Version)" 103 | Write-Output "$ScriptName - Model (from TSENV): $Model" 104 | Write-Output "$ScriptName - ModelAlias (from TSENV): $ModelAlias" 105 | Write-Output "$ScriptName - OSDComputername (from TSENV): $OSDComputername" 106 | Write-Output "$ScriptName - ModelAlias (from TSENV): $ModelAlias" 107 | Write-Output "$ScriptName - OSDComputername (from TSENV): $OSDComputername" 108 | 109 | $ImageBuild = $tsenv.Value("IMAGEBUILD") 110 | switch ($ImageBuild.Substring(0,3)) 111 | { 112 | '10.' { 113 | $tsenv.Value("OSRoleIndex") = "10" 114 | } 115 | Default { 116 | $tsenv.Value("OSRoleIndex") = $ImageBuild.Substring(0,3) 117 | } 118 | } 119 | Write-Output "$ScriptName - OSRoleIndex is now $($tsenv.Value("OSRoleIndex"))" 120 | 121 | #Stop Transcript Logging 122 | . Stop-Logging 123 | -------------------------------------------------------------------------------- /MDTApps/Configure - Disable Services in Windows Server 2016 Desktop Edition/Configure-DisableServicesforWindowsServer.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Install Wrapper 2.0 3 | Author: Mikael Nystrom 4 | http://www.deploymentbunny.com 5 | #> 6 | 7 | [cmdletbinding(SupportsShouldProcess=$True)] 8 | Param( 9 | ) 10 | 11 | Function Get-VIAOSVersion([ref]$OSv){ 12 | $OS = Get-WmiObject -Class Win32_OperatingSystem 13 | Switch -Regex ($OS.Version) 14 | { 15 | "6.1" 16 | {If($OS.ProductType -eq 1) 17 | {$OSv.value = "Windows 7 SP1"} 18 | Else 19 | {$OSv.value = "Windows Server 2008 R2"} 20 | } 21 | "6.2" 22 | {If($OS.ProductType -eq 1) 23 | {$OSv.value = "Windows 8"} 24 | Else 25 | {$OSv.value = "Windows Server 2012"} 26 | } 27 | "6.3" 28 | {If($OS.ProductType -eq 1) 29 | {$OSv.value = "Windows 8.1"} 30 | Else 31 | {$OSv.value = "Windows Server 2012 R2"} 32 | } 33 | "10" 34 | {If($OS.ProductType -eq 1) 35 | {$OSv.value = "Windows 10"} 36 | Else 37 | {$OSv.value = "Windows Server 2016"} 38 | } 39 | DEFAULT { "Version not listed" } 40 | } 41 | } 42 | Function Import-VIASMSTSENV{ 43 | try{ 44 | $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment 45 | Write-Output "$ScriptName - tsenv is $tsenv " 46 | $MDTIntegration = $true 47 | 48 | #$tsenv.GetVariables() | % { Write-Output "$ScriptName - $_ = $($tsenv.Value($_))" } 49 | } 50 | catch{ 51 | Write-Output "$ScriptName - Unable to load Microsoft.SMS.TSEnvironment" 52 | Write-Output "$ScriptName - Running in standalonemode" 53 | $MDTIntegration = $false 54 | } 55 | Finally{ 56 | if ($MDTIntegration -eq $true){ 57 | $Logpath = $tsenv.Value("LogPath") 58 | $LogFile = $Logpath + "\" + "$ScriptName.txt" 59 | } 60 | Else{ 61 | $Logpath = $env:TEMP 62 | $LogFile = $Logpath + "\" + "$ScriptName.txt" 63 | } 64 | } 65 | Return $MDTIntegration 66 | } 67 | Function Start-VIALogging{ 68 | Start-Transcript -path $LogFile -Force 69 | } 70 | Function Stop-VIALogging{ 71 | Stop-Transcript 72 | } 73 | Function Invoke-VIAExe{ 74 | [CmdletBinding(SupportsShouldProcess=$true)] 75 | 76 | param( 77 | [parameter(mandatory=$true,position=0)] 78 | [ValidateNotNullOrEmpty()] 79 | [string] 80 | $Executable, 81 | 82 | [parameter(mandatory=$false,position=1)] 83 | [string] 84 | $Arguments 85 | ) 86 | 87 | if($Arguments -eq "") 88 | { 89 | Write-Verbose "Running Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru" 90 | $ReturnFromEXE = Start-Process -FilePath $Executable -NoNewWindow -Wait -Passthru 91 | }else{ 92 | Write-Verbose "Running Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru" 93 | $ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru 94 | } 95 | Write-Verbose "Returncode is $($ReturnFromEXE.ExitCode)" 96 | Return $ReturnFromEXE.ExitCode 97 | } 98 | Function Invoke-VIAMsi{ 99 | [CmdletBinding(SupportsShouldProcess=$true)] 100 | 101 | param( 102 | [parameter(mandatory=$true,position=0)] 103 | [ValidateNotNullOrEmpty()] 104 | [string] 105 | $MSI, 106 | 107 | [parameter(mandatory=$false,position=1)] 108 | [string] 109 | $Arguments 110 | ) 111 | 112 | #Set MSIArgs 113 | $MSIArgs = "/i " + $MSI + " " + $Arguments 114 | 115 | if($Arguments -eq "") 116 | { 117 | $MSIArgs = "/i " + $MSI 118 | 119 | 120 | } 121 | else 122 | { 123 | $MSIArgs = "/i " + $MSI + " " + $Arguments 124 | 125 | } 126 | Write-Verbose "Running Start-Process -FilePath msiexec.exe -ArgumentList $MSIArgs -NoNewWindow -Wait -Passthru" 127 | $ReturnFromEXE = Start-Process -FilePath msiexec.exe -ArgumentList $MSIArgs -NoNewWindow -Wait -Passthru 128 | Write-Verbose "Returncode is $($ReturnFromEXE.ExitCode)" 129 | Return $ReturnFromEXE.ExitCode 130 | } 131 | Function Invoke-VIAMsu{ 132 | [CmdletBinding(SupportsShouldProcess=$true)] 133 | 134 | param( 135 | [parameter(mandatory=$true,position=0)] 136 | [ValidateNotNullOrEmpty()] 137 | [string] 138 | $MSU, 139 | 140 | [parameter(mandatory=$false,position=1)] 141 | [string] 142 | $Arguments 143 | ) 144 | 145 | #Set MSIArgs 146 | $MSUArgs = $MSU + " " + $Arguments 147 | 148 | if($Arguments -eq "") 149 | { 150 | $MSUArgs = $MSU 151 | 152 | 153 | } 154 | else 155 | { 156 | $MSUArgs = $MSU + " " + $Arguments 157 | 158 | } 159 | 160 | Write-Verbose "Running Start-Process -FilePath wusa.exe -ArgumentList $MSUArgs -NoNewWindow -Wait -Passthru" 161 | $ReturnFromEXE = Start-Process -FilePath wusa.exe -ArgumentList $MSUArgs -NoNewWindow -Wait -Passthru 162 | Write-Verbose "Returncode is $($ReturnFromEXE.ExitCode)" 163 | Return $ReturnFromEXE.ExitCode 164 | } 165 | 166 | # Set Vars 167 | $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path 168 | $ScriptName = Split-Path -Leaf $MyInvocation.MyCommand.Path 169 | #[xml]$Settings = Get-Content "$ScriptDir\Settings.xml" 170 | $SOURCEROOT = "$SCRIPTDIR\Source" 171 | $LANG = (Get-Culture).Name 172 | $OSV = $Null 173 | $ARCHITECTURE = $env:PROCESSOR_ARCHITECTURE 174 | 175 | #Try to Import SMSTSEnv 176 | . Import-VIASMSTSENV 177 | 178 | #Start Transcript Logging 179 | . Start-VIALogging 180 | 181 | #Detect current OS Version 182 | . Get-VIAOSVersion -osv ([ref]$osv) 183 | 184 | #Output more info 185 | Write-Output "" 186 | Write-Output "$ScriptName - ScriptDir: $ScriptDir" 187 | Write-Output "$ScriptName - SourceRoot: $SOURCEROOT" 188 | Write-Output "$ScriptName - ScriptName: $ScriptName" 189 | Write-Output "$ScriptName - OS Name: $osv" 190 | Write-Output "$ScriptName - OS Architecture: $ARCHITECTURE" 191 | Write-Output "$ScriptName - Current Culture: $LANG" 192 | Write-Output "$ScriptName - Integration with MDT(LTI/ZTI): $MDTIntegration" 193 | Write-Output "$ScriptName - Log: $LogFile" 194 | 195 | #Generate more info 196 | if($MDTIntegration -eq "YES"){ 197 | $TSMake = $tsenv.Value("Make") 198 | $TSModel = $tsenv.Value("Model") 199 | $TSMakeAlias = $tsenv.Value("MakeAlias") 200 | $TSModelAlias = $tsenv.Value("ModelAlias") 201 | $TSOSDComputerName = $tsenv.Value("OSDComputerName") 202 | Write-Output "$ScriptName - Make:: $TSMake" 203 | Write-Output "$ScriptName - Model: $TSModel" 204 | Write-Output "$ScriptName - MakeAlias: $TSMakeAlias" 205 | Write-Output "$ScriptName - ModelAlias: $TSModelAlias" 206 | Write-Output "$ScriptName - OSDComputername: $TSOSDComputerName" 207 | } 208 | 209 | #Custom Code Starts-------------------------------------- 210 | 211 | #Disable Services 212 | $Services = 'CDPUserSvc','MapsBroker','PcaSvc','ShellHWDetection','OneSyncSvc','WpnService' 213 | foreach($Service in $Services){ 214 | Get-Service -Name $Service | Stop-Service -PassThru | Set-Service -StartupType Disabled 215 | Get-Service 216 | } 217 | 218 | #Start default Performance collector 219 | Start-SMPerformanceCollector -CollectorName 'Server Manager Performance Monitor' 220 | Write-Output "SMPerformanceCollector is $(Get-SMPerformanceCollector -CollectorName 'Server Manager Performance Monitor')" 221 | 222 | #Reconfigure Services 223 | $Services = 'ualsvc','dssvc' 224 | foreach($Service in $Services){ 225 | & Sc.exe config $Service type=own 226 | Get-Service -Name $Service | Restart-Service -Force 227 | Get-Service -Name $Service | select ServiceName,ServiceType,Starttype 228 | } 229 | 230 | #Custom Code Ends-------------------------------------- 231 | . Stop-VIALogging 232 | 233 | 234 | 235 | 236 | 237 | 238 | -------------------------------------------------------------------------------- /MDTApps/Configure - Windows Client/Configure-WindowsClient.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Baseconfig for W10 4 | .DESCRIPTION 5 | Baseconfig for W10 6 | .EXAMPLE 7 | Baseconfig for W10 8 | .NOTES 9 | ScriptName: Configure-WindowsClient.ps1 10 | Author: Mikael Nystrom 11 | Twitter: @mikael_nystrom 12 | Email: mikael.nystrom@truesec.se 13 | Blog: https://deploymentbunny.com 14 | 15 | Version History 16 | 1.0.0 - Script created [01/16/2019 13:12:16] 17 | 18 | Copyright (c) 2019 Mikael Nystrom 19 | 20 | Permission is hereby granted, free of charge, to any person obtaining a copy 21 | of this software and associated documentation files (the "Software"), to deal 22 | in the Software without restriction, including without limitation the rights 23 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 24 | copies of the Software, and to permit persons to whom the Software is 25 | furnished to do so, subject to the following conditions: 26 | 27 | The above copyright notice and this permission notice shall be included in all 28 | copies or substantial portions of the Software. 29 | 30 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36 | SOFTWARE. 37 | #> 38 | 39 | [cmdletbinding(SupportsShouldProcess=$True)] 40 | Param( 41 | ) 42 | 43 | Function Get-TSxTest { 44 | Return "OK" 45 | } 46 | Function Get-TSxOSVersion([ref]$OSv) { 47 | $OS = Get-WmiObject -Class Win32_OperatingSystem | Select * 48 | Switch -Regex ($OS.Version) 49 | { 50 | "6.1" 51 | {If($OS.ProductType -eq 1) 52 | {$OSv.value = "Windows 7 SP1"} 53 | Else 54 | {$OSv.value = "Windows Server 2008 R2"} 55 | } 56 | "6.2" 57 | {If($OS.ProductType -eq 1) 58 | {$OSv.value = "Windows 8"} 59 | Else 60 | {$OSv.value = "Windows Server 2012"} 61 | } 62 | "6.3" 63 | {If($OS.ProductType -eq 1) 64 | {$OSv.value = "Windows 8.1"} 65 | Else 66 | {$OSv.value = "Windows Server 2012 R2"} 67 | } 68 | "10.0.14" 69 | {If($OS.ProductType -eq 1) 70 | {$OSv.value = "Windows 10 1607"} 71 | Else 72 | {$OSv.value = "Windows Server 2016"} 73 | } 74 | "10.0.17" 75 | {If($OS.ProductType -eq 1) 76 | {$OSv.value = "Windows 10 1809"} 77 | Else 78 | {$OSv.value = "Windows Server 2019"} 79 | } 80 | DEFAULT { "Version not listed" } 81 | } 82 | } 83 | Function Get-TSxOSSKU { 84 | $Path = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Server\ServerLevels\' 85 | if(Test-Path -Path $Path) 86 | { 87 | $Test = Get-ItemProperty -Path $Path 88 | if(($Test.'ServerCore' -eq 1) -and ($Test.'Server-Gui-Shell' -eq 1)){$OSSKU = "DesktopExperience"} 89 | if(($Test.'ServerCore' -eq 1) -and ($Test.'Server-Gui-Shell' -ne 1)){$OSSKU = "Core"} 90 | Return $OSSKU 91 | } 92 | else 93 | { 94 | Return "Unknown" 95 | } 96 | } 97 | Function Invoke-TSxExe { 98 | [CmdletBinding(SupportsShouldProcess=$true)] 99 | 100 | param( 101 | [parameter(mandatory=$true,position=0)] 102 | [ValidateNotNullOrEmpty()] 103 | [string] 104 | $Executable, 105 | 106 | [parameter(mandatory=$false,position=1)] 107 | [string] 108 | $Arguments 109 | ) 110 | 111 | if($Arguments -eq "") 112 | { 113 | Write-Verbose "Running Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru" 114 | $ReturnFromEXE = Start-Process -FilePath $Executable -NoNewWindow -Wait -Passthru 115 | }else{ 116 | Write-Verbose "Running Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru" 117 | $ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru 118 | } 119 | Write-Verbose "Returncode is $($ReturnFromEXE.ExitCode)" 120 | Return $ReturnFromEXE.ExitCode 121 | } 122 | Function Start-TSxLog { 123 | [CmdletBinding()] 124 | param ( 125 | [ValidateScript({ Split-Path $_ -Parent | Test-Path })] 126 | [string]$FilePath 127 | ) 128 | 129 | try 130 | { 131 | if (!(Test-Path $FilePath)) 132 | { 133 | ## Create the log file 134 | New-Item $FilePath -Type File | Out-Null 135 | } 136 | 137 | ## Set the global variable to be used as the FilePath for all subsequent Write-Log 138 | ## calls in this session 139 | $global:ScriptLogFilePath = $FilePath 140 | } 141 | catch 142 | { 143 | Write-Error $_.Exception.Message 144 | } 145 | } 146 | Function Write-TSxLog { 147 | param ( 148 | [Parameter(Mandatory = $true)] 149 | [string]$Message, 150 | 151 | [Parameter()] 152 | [ValidateSet(1, 2, 3)] 153 | [string]$LogLevel = 1 154 | ) 155 | 156 | $TimeGenerated = "$(Get-Date -Format HH:mm:ss).$((Get-Date).Millisecond)+000" 157 | $Line = '' 158 | $LineFormat = $Message, $TimeGenerated, (Get-Date -Format MM-dd-yyyy), "$($MyInvocation.ScriptName | Split-Path -Leaf):$($MyInvocation.ScriptLineNumber)", $LogLevel 159 | #$LineFormat = $Message, $TimeGenerated, (Get-Date -Format MM-dd-yyyy), "$($MyInvocation.ScriptName | Split-Path -Leaf)", $LogLevel 160 | $Line = $Line -f $LineFormat 161 | Add-Content -Value $Line -Path $ScriptLogFilePath 162 | 163 | if($writetoscreen -eq $true){ 164 | switch ($LogLevel) 165 | { 166 | '1'{ 167 | Write-Host $Message -ForegroundColor Gray 168 | } 169 | '2'{ 170 | Write-Host $Message -ForegroundColor Yellow 171 | } 172 | '3'{ 173 | Write-Host $Message -ForegroundColor Red 174 | } 175 | Default {} 176 | } 177 | } 178 | } 179 | Function Get-TSxISVM { 180 | $Win32_computersystem = Get-WmiObject -Class Win32_computersystem 181 | switch ($Win32_computersystem.Model) 182 | { 183 | 'VMware Virtual Platform' {$IsVM = "True"} 184 | 'VMware7,1' {$IsVM = "True"} 185 | 'Virtual Machine' {$IsVM = "True"} 186 | 'Virtual Box' {$IsVM = "True"} 187 | Default {$IsVM = "True"} 188 | } 189 | Return $IsVM 190 | } 191 | Function Get-TSxISCoreServer { 192 | (Get-ItemProperty -Path "HKLM:\software\microsoft\windows nt\CurrentVersion").InstallationType -eq "Server Core" 193 | } 194 | 195 | # Set Vars 196 | $VerbosePreference = "continue" 197 | $writetoscreen = $true 198 | $osv = '' 199 | $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path 200 | $ScriptName = Split-Path -Leaf $MyInvocation.MyCommand.Path 201 | $ARCHITECTURE = $env:PROCESSOR_ARCHITECTURE 202 | 203 | # Import Microsoft.SMS.TSEnvironment 204 | $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment 205 | $Logpath = $tsenv.Value("LogPath") 206 | $LogFile = $Logpath + "\" + "$ScriptName.log" 207 | $DeployRoot = $tsenv.Value("DeployRoot") 208 | 209 | #Start logging 210 | Start-TSxLog -FilePath $LogFile 211 | Write-TSxLog "$ScriptName - Logging to $LogFile" 212 | 213 | # Generate Vars 214 | $OSSKU = Get-TSxOSSKU 215 | $TSMake = $tsenv.Value("Make") 216 | $TSModel = $tsenv.Value("Model") 217 | 218 | Write-TSxLog "$ScriptName - Get-TSxOSVersion" 219 | Get-TSxOSVersion -osv ([ref]$osv) 220 | 221 | Write-TSxLog "$ScriptName - Check if we are IsServerCoreOS" 222 | $IsServerCoreOS = Get-TSxISCoreServer 223 | Write-TSxLog "$ScriptName - IsServerCoreOS is now $IsServerCoreOS" 224 | 225 | #Output more info 226 | Write-TSxLog "$ScriptName - ScriptDir: $ScriptDir" 227 | Write-TSxLog "$ScriptName - ScriptName: $ScriptName" 228 | Write-TSxLog "$ScriptName - Log: $LogFile" 229 | Write-TSxLog "$ScriptName - OSSKU: $OSSKU" 230 | Write-TSxLog "$ScriptName - OSVersion: $osv" 231 | Write-TSxLog "$ScriptName - Make:: $TSMake" 232 | Write-TSxLog "$ScriptName - Model: $TSModel" 233 | 234 | #Custom Code Starts-------------------------------------- 235 | 236 | $CreateFolderStructure = $True 237 | $DoNotOpenServerManagerAtLogon = $False 238 | $EnableRemoteDesktop = $False 239 | $ConfigureServerManagerPerformanceMonitor = $False 240 | $DisableShowWelcomeTileforallusers = $False 241 | $EnableSmartScreen = $true 242 | $SetCrashControl = $true 243 | $ConfigureFirewallRules = $False 244 | $ConfigureEventlogs = $true 245 | $SetPowerSchemaSettingsHighPerformance = $false 246 | $SetConfirmDeleteQuestion = $False 247 | $AddingShortCutForNotepadToSendTofolder = $False 248 | $ConfigureScreenSaver = $false 249 | $ShowTaskbarSmallIcons = $false 250 | $ShowFileExt = $false 251 | $ShowHiddenFiles = $false 252 | $ShowSuperHiddenFiles = $false 253 | $AlwaysShowMenus = $false 254 | $AlwaysShowFullPath = $false 255 | $HideMergeConflicts = $false 256 | $HideDrivesWithNoMedia = $false 257 | $LaunchSeparateProcess = $True 258 | $ShowIconsOnlyNoThumbnails = $false 259 | $DontShowInfoTip = $True 260 | $ShowComputerOnDesktop = $True 261 | $ShowAllTaskbarIconsAndNotifcations = $false 262 | $SetControlPanelToSmallIconsView = $false 263 | $DisableVolumeIcon = $false 264 | $DisableAutosearch = $false 265 | $SetAutoDetectProxySettingsEmpty = $false 266 | $DisableServices = $false 267 | $DisableAdminCenterPopup = $false 268 | #Action 269 | 270 | Write-TSxLog "$ScriptName - $Action - Loading C:\Users\Default\NTUSER.DAT" 271 | REG LOAD HKEY_LOCAL_MACHINE\defuser "C:\Users\Default\NTUSER.DAT" 272 | 273 | 274 | if($DisableAdminCenterPopup -eq $True){ 275 | switch ($osv){ 276 | 'Windows Server 2019'{ 277 | #Action 278 | $Action = "Configure NoWindowsAdminPopup" 279 | Write-TSxLog "$ScriptName - $Action" 280 | try{ 281 | $Name = "DoNotPopWACConsoleAtSMLaunch" 282 | $Path = "HKLM:\SOFTWARE\Microsoft\ServerManager" 283 | $PropertyType = "DWORD" 284 | $Value = 1 285 | $Result = New-ItemProperty -Path $Path -Name $Name -PropertyType $PropertyType -Value $Value -Force 286 | Write-TSxLog "$ScriptName - $Path\$Name is now: $($Result.$Name)" 287 | } 288 | catch{ 289 | Write-TSxLog "$ScriptName - $Action - Fail" 290 | } 291 | } 292 | Default { 293 | } 294 | } 295 | } 296 | if($DisableServices -eq $true -and $IsServerCoreOS -eq $false){ 297 | switch ($osv){ 298 | 'Windows Server 2016'{ 299 | #Disable unneeded services in Windows Server 2016 Desktop Edition 300 | $Services = 'CDPUserSvc','MapsBroker','PcaSvc','ShellHWDetection','OneSyncSvc','WpnService' 301 | 302 | foreach($Service in $Services){ 303 | Set-Service -StartupType Disabled -Name $Service 304 | } 305 | } 306 | Default { 307 | } 308 | } 309 | } 310 | if($CreateFolderStructure -eq $True){ 311 | $Action = "Create folder structure" 312 | Write-TSxLog "$ScriptName - $Action" 313 | try 314 | { 315 | $Folders = "C:\Temp" 316 | foreach ($folder in $Folders){ 317 | $result = New-Item -Path -ItemType Directory -Force 318 | Write-TSxLog "$ScriptName - Created: $($Result.FullName)" 319 | } 320 | } 321 | catch{ 322 | Write-TSxLog "$ScriptName - $Action - Fail" 323 | } 324 | } 325 | if($DoNotOpenServerManagerAtLogon -eq $True){ 326 | #Action 327 | $Action = "Configure DoNotOpenServerManagerAtLogon" 328 | Write-TSxLog "$ScriptName - $Action" 329 | try 330 | { 331 | $Name = "DoNotOpenServerManagerAtLogon" 332 | $Path = "HKLM:\SOFTWARE\Microsoft\ServerManager" 333 | $PropertyType = "DWORD" 334 | $Value = 1 335 | $Result = New-ItemProperty -Path $Path -Name $Name -PropertyType $PropertyType -Value $Value -Force 336 | Write-TSxLog "$ScriptName - $Path\$Name is now: $($Result.$Name)" 337 | } 338 | catch{ 339 | Write-TSxLog "$ScriptName - $Action - Fail" 340 | } 341 | } 342 | if($EnableRemoteDesktop -eq $True){ 343 | #Action 344 | $Action = "Configure Remote Desktop" 345 | Write-TSxLog "$ScriptName - $Action" 346 | try 347 | { 348 | cscript.exe /nologo C:\windows\system32\SCregEdit.wsf /AR 0 349 | } 350 | catch{ 351 | Write-TSxLog "$ScriptName - $Action - Fail" 352 | } 353 | 354 | #Action 355 | $Action = "Configure Remote Destop Security" 356 | Write-TSxLog "$ScriptName - $Action" 357 | try 358 | { 359 | cscript.exe /nologo C:\windows\system32\SCregEdit.wsf /CS 1 360 | } 361 | catch{ 362 | Write-TSxLog "$ScriptName - $Action - Fail" 363 | } 364 | } 365 | if($ConfigureServerManagerPerformanceMonitor -eq $true){ 366 | #Server Manager Performance Monitor 367 | $Action = "Configure Server Manager Performance Monitor" 368 | Write-TSxLog "$ScriptName - $Action" 369 | try{ 370 | Start-SMPerformanceCollector -CollectorName 'Server Manager Performance Monitor' 371 | }catch{ 372 | Write-TSxLog "$ScriptName - $Action - Fail" 373 | } 374 | } 375 | if($DisableShowWelcomeTileforallusers -eq $true){ 376 | #Disable Show Welcome Tile for all users 377 | $Action = "Configure Show Welcome Tile" 378 | Write-TSxLog "$ScriptName - $Action" 379 | try{ 380 | $XMLBlock = @( 381 | ' 382 | 383 | 384 | 385 |
386 | 387 | 388 | 389 | 390 | 391 | Collapsed 392 | 393 | 394 | 395 | ' 396 | ) 397 | $XMLBlock | Out-File -FilePath C:\Windows\System32\ServerManager.exe.config -Encoding ascii -Force 398 | }catch{ 399 | Write-TSxLog "$ScriptName - $Action - Fail" 400 | } 401 | } 402 | if($EnableSmartScreen -eq $true){ 403 | # Enable SmartScreen 404 | $Action = "Configure SmartScreen" 405 | Write-TSxLog "$ScriptName - $Action" 406 | try{ 407 | $OptionType = 2 408 | $KeyPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" 409 | New-ItemProperty -Path $KeyPath -Name EnableSmartScreen -Value $OptionType -PropertyType DWord -Force 410 | }catch{ 411 | Write-TSxLog "$ScriptName - $Action - Fail" 412 | } 413 | } 414 | if($SetCrashControl -eq $true){ 415 | # Set CrashControl 416 | $Action = "Set CrashControl" 417 | Write-TSxLog "$ScriptName - $Action" 418 | try{ 419 | $Path = "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" 420 | $Name = "AutoReboot" 421 | $Value = 00000001 422 | $PropertyType = "DWORD" 423 | $Result = New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force 424 | Write-TSxLog "$ScriptName - $Path\$Name is now: $($Result.$Name)" 425 | 426 | $Path = "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" 427 | $Name = "CrashDumpEnabled" 428 | $Value = 00000001 429 | $PropertyType = "DWORD" 430 | $Result = New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force 431 | Write-TSxLog "$ScriptName - $Path\$Name is now: $($Result.$Name)" 432 | 433 | $Path = "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" 434 | $Name = "LogEvent" 435 | $Value = 00000001 436 | $PropertyType = "DWORD" 437 | $Result = New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force 438 | Write-TSxLog "$ScriptName - $Path\$Name is now: $($Result.$Name)" 439 | 440 | $Path = "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" 441 | $Name = "MinidumpsCount" 442 | $Value = 00000005 443 | $PropertyType = "DWORD" 444 | $Result = New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force 445 | Write-TSxLog "$ScriptName - $Path\$Name is now: $($Result.$Name)" 446 | 447 | $Path = "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" 448 | $Name = "Overwrite" 449 | $Value = 00000001 450 | $PropertyType = "DWORD" 451 | $Result = New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force 452 | Write-TSxLog "$ScriptName - $Path\$Name is now: $($Result.$Name)" 453 | 454 | $Path = "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" 455 | $Name = "AlwaysKeepMemoryDump" 456 | $Value = 00000000 457 | $PropertyType = "DWORD" 458 | $Result = New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force 459 | Write-TSxLog "$ScriptName - $Path\$Name is now: $($Result.$Name)" 460 | 461 | $Path = "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" 462 | $Name = "FilterPages" 463 | $Value = 00000001 464 | $PropertyType = "DWORD" 465 | $Result = New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force 466 | Write-TSxLog "$ScriptName - $Path\$Name is now: $($Result.$Name)" 467 | } 468 | catch{ 469 | Write-TSxLog "$ScriptName - $Action - Fail" 470 | } 471 | } 472 | if($ConfigureFirewallRules -eq $true){ 473 | # Configure firewall rules 474 | $Action = "Configure firewall rules" 475 | Write-TSxLog "$ScriptName - $Action" 476 | try{ 477 | $RuleSet = Get-NetFirewallRule -Group "@FirewallAPI.dll,-28752" 478 | $RuleSet | Enable-NetFirewallRule -Verbose 479 | 480 | foreach ($Rule in $RuleSet){ 481 | Write-TSxLog "$ScriptName - $Action - $($Rule.Description) is now Enabled:$($Rule.Enabled)" 482 | } 483 | }catch{ 484 | Write-TSxLog "$ScriptName - $Action - Fail" 485 | } 486 | } 487 | if($ConfigureEventlogs -eq $True){ 488 | # Configure Eventlogs 489 | $Action = "Configure Eventlogs" 490 | Write-TSxLog "$ScriptName - $Action" 491 | $EventLogs = "Application","Security","System" 492 | $MaxSize = 2GB 493 | foreach($EventLog in $EventLogs){ 494 | try{ 495 | Limit-EventLog -LogName $EventLog -MaximumSize $MaxSize 496 | } 497 | catch{ 498 | Write-TSxLog "$ScriptName - $Action Could not set $EventLog to $MaxSize, sorry" 499 | } 500 | $EventLogData = Get-EventLog -List | Where-Object Log -EQ $EventLog 501 | Write-TSxLog "$ScriptName - $Action $($EventLogData.Log) log is now set to now $($EventLogData.MaximumKilobytes)" 502 | } 503 | } 504 | if($SetPowerSchemaSettingsHighPerformance -eq $True){ 505 | # Set PowerSchemaSettings to High Performance 506 | $Action = "Set PowerSchemaSettings to High Performance" 507 | Write-TSxLog "$ScriptName - $Action" 508 | try{ 509 | Invoke-TSxExe -Executable powercfg.exe -Arguments "/SETACTIVE 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c" -Verbose 510 | } 511 | catch{ 512 | Write-TSxLog "$ScriptName - $Action - Fail" 513 | } 514 | $PowerCfgConfig = powercfg.exe /GETACTIVESCHEME 515 | Write-TSxLog "$ScriptName - $PowerCfgConfig" 516 | } 517 | if($SetConfirmDeleteQuestion -eq $true -and $IsServerCoreOS -eq $false){ 518 | # Set ConfirmDeleteQuestion to ask before deletion 519 | $Action = "Set ConfirmDeleteQuestion to ask before deletion" 520 | 521 | Write-TSxLog "$ScriptName - $Action" 522 | $RegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" 523 | $Result = New-ItemProperty -Path $RegistryPath -Name "ScreenSaverIsSecure" -PropertyType DWORD -Value "0000001" -Force 524 | Write-TSxLog "$ScriptName - TaskbarSmallIcons is now: $($result.ScreenSaverIsSecure)" 525 | } 526 | if($AddingShortCutForNotepadToSendTofolder -eq $true -and $IsServerCoreOS -eq $false){ 527 | try{ 528 | $Action = "Adding ShortCut for Notepad in the SendTo folder" 529 | Write-TSxLog "$ScriptName - $Action" 530 | 531 | $Folder = "C:\Users\Default\AppData\Roaming\Microsoft\Windows\SendTo\" 532 | $linkPath = "$Folder\Notepad.lnk" 533 | $wshShell = New-Object -comObject WScript.Shell 534 | $shortcut = $WshShell.CreateShortcut($linkPath) 535 | $shortcut.Description = "Notepad" 536 | $shortcut.HotKey = "" 537 | $shortcut.IconLocation = "C:\Windows\System32\Notepad.exe,0" 538 | $shortcut.TargetPath = "C:\Windows\System32\Notepad.exe" 539 | $shortcut.WindowStyle = 3 540 | $shortcut.WorkingDirectory = "C:\Windows\System32" 541 | $shortcut.Save() 542 | 543 | } 544 | catch{ 545 | Write-TSxLog "$ScriptName - $Action - Fail" 546 | } 547 | } 548 | if($ConfigureScreenSaver -eq $true){ 549 | $Action = "Configure Screen Saver" 550 | Write-TSxLog "$ScriptName - $Action" 551 | 552 | $Path = "HKCU:\Control Panel\Desktop" 553 | $Name = "ScreenSaverIsSecure" 554 | $Result = New-ItemProperty -Path $Path -Name $Name -Value 1 -PropertyType String -Force 555 | Write-TSxLog "$ScriptName - $Path\$Name is now: $($result.$Name)" 556 | 557 | $Path = "HKCU:\Control Panel\Desktop" 558 | $Name = "ScreenSaveActive" 559 | $Result = New-ItemProperty -Path $Path -Name $Name -Value 1 -PropertyType String -Force 560 | Write-TSxLog "$ScriptName - TaskbarSmallIcons is now: $($result.$Name)" 561 | 562 | $Path = "HKCU:\Control Panel\Desktop" 563 | $Name = "ScreenSaveTimeOut" 564 | $Result = New-ItemProperty -Path $Path -Name ScreenSaveTimeOut -Value 900 -PropertyType String -Force 565 | Write-TSxLog "$ScriptName - TaskbarSmallIcons is now: $($result.$Name)" 566 | 567 | $Path = "HKCU:\defuser\Control Panel\Desktop" 568 | $Name = "ScreenSaverIsSecure" 569 | $Result = New-ItemProperty -Path $Path -Name $Name -Value 1 -PropertyType String -Force 570 | Write-TSxLog "$ScriptName - $Path\$Name is now: $($result.$Name)" 571 | 572 | $Path = "HKCU:\defuser\Control Panel\Desktop" 573 | $Name = "ScreenSaveActive" 574 | $Result = New-ItemProperty -Path $Path -Name $Name -Value 1 -PropertyType String -Force 575 | Write-TSxLog "$ScriptName - $Path\$Name is now: $($result.$Name)" 576 | 577 | $Path = "HKCU:\defuser\Control Panel\Desktop" 578 | $Name = "ScreenSaveTimeOut" 579 | $Result = New-ItemProperty -Path $Path -Name $Name -Value 900 -PropertyType String -Force 580 | Write-TSxLog "$ScriptName - $Path\$Name is now: $($result.$Name)" 581 | 582 | 583 | } 584 | if($ShowTaskbarSmallIcons -eq $true -and $IsServerCoreOS -eq $false){ 585 | # Show small icons on taskbar 586 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name TaskbarSmallIcons -Value 1 -PropertyType DWORD -Force 587 | Write-TSxLog "$ScriptName - TaskbarSmallIcons is now: $($result.TaskbarSmallIcons)" 588 | 589 | # Show small icons on taskbar 590 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name TaskbarSmallIcons -Value 1 -PropertyType DWORD -Force 591 | Write-TSxLog "$ScriptName - TaskbarSmallIcons is now: $($result.TaskbarSmallIcons)" 592 | } 593 | if($ShowFileExt -eq $true -and $IsServerCoreOS -eq $false){ 594 | # Folderoptions Show file extensions 595 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name HideFileExt -Value 0 -PropertyType DWORD -Force 596 | Write-TSxLog "$ScriptName - HideFileExt is now: $($result.HideFileExt)" 597 | 598 | # Folderoptions Show file extensions 599 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name HideFileExt -Value 0 -PropertyType DWORD -Force 600 | Write-TSxLog "$ScriptName - HideFileExt is now: $($result.HideFileExt)" 601 | } 602 | if($ShowHiddenFiles -eq $true -and $IsServerCoreOS -eq $false){ 603 | # Folderoptions Show hidden files, show hidden systemfiles file 604 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name Hidden -Value 1 -PropertyType DWORD -Force 605 | Write-TSxLog "$ScriptName - Hidden is now: $($result.Hidden)" 606 | 607 | # Folderoptions Show hidden files, show hidden systemfiles file 608 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name Hidden -Value 1 -PropertyType DWORD -Force 609 | Write-TSxLog "$ScriptName - Hidden is now: $($result.Hidden)" 610 | } 611 | if($ShowSuperHiddenFiles -eq $true -and $IsServerCoreOS -eq $false){ 612 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name ShowSuperHidden -Value 1 -PropertyType DWORD -Force 613 | Write-TSxLog "$ScriptName - SuperHidden is now: $($result.ShowSuperHidden)" 614 | 615 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name ShowSuperHidden -Value 1 -PropertyType DWORD -Force 616 | Write-TSxLog "$ScriptName - SuperHidden is now: $($result.ShowSuperHidden)" 617 | } 618 | if($AlwaysShowMenus -eq $true -and $IsServerCoreOS -eq $false){ 619 | # Folderoptions Always shows Menus 620 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name AlwaysShowMenus -Value 1 -PropertyType DWORD -Force 621 | Write-TSxLog "$ScriptName - AlwaysShowMenus is now: $($result.AlwaysShowMenus)" 622 | 623 | # Folderoptions Always shows Menus 624 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name AlwaysShowMenus -Value 1 -PropertyType DWORD -Force 625 | Write-TSxLog "$ScriptName - AlwaysShowMenus is now: $($result.AlwaysShowMenus)" 626 | } 627 | if($AlwaysShowFullPath -eq $true -and $IsServerCoreOS -eq $false){ 628 | # Folderoptions Display the full path in the title bar 629 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name FullPath -Value 1 -PropertyType DWORD -Force 630 | Write-TSxLog "$ScriptName - FullPath is now: $($result.FullPath)" 631 | 632 | # Folderoptions Display the full path in the title bar 633 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name FullPath -Value 1 -PropertyType DWORD -Force 634 | Write-TSxLog "$ScriptName - FullPath is now: $($result.FullPath)" 635 | } 636 | if($HideMergeConflicts -eq $true -and $IsServerCoreOS -eq $false){ 637 | # Folderoptions HideMerge Conflicts 638 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name HideMergeConflicts -Value 0 -PropertyType DWORD -Force 639 | Write-TSxLog "$ScriptName - HideMergeConflicts is now: $($result.HideMergeConflicts)" 640 | 641 | # Folderoptions HideMerge Conflicts 642 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name HideMergeConflicts -Value 0 -PropertyType DWORD -Force 643 | Write-TSxLog "$ScriptName - HideMergeConflicts is now: $($result.HideMergeConflicts)" 644 | } 645 | if($HideDrivesWithNoMedia -eq $true -and $IsServerCoreOS -eq $false){ 646 | # Folderoptions Hide empty drives in the computer folder 647 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name HideDrivesWithNoMedia -Value 0 -PropertyType DWORD -Force 648 | Write-TSxLog "$ScriptName - HideDrivesWithNoMedia is now: $($result.HideDrivesWithNoMedia)" 649 | 650 | # Folderoptions Hide empty drives in the computer folder 651 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name HideDrivesWithNoMedia -Value 0 -PropertyType DWORD -Force 652 | Write-TSxLog "$ScriptName - HideDrivesWithNoMedia is now: $($result.HideDrivesWithNoMedia)" 653 | } 654 | if($LaunchSeparateProcess -eq $true -and $IsServerCoreOS -eq $false){ 655 | # Folderoptions launch folder windows in separate process 656 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name SeparateProcess -Value 1 -PropertyType DWORD -Force 657 | Write-TSxLog "$ScriptName - SeparateProcess is now: $($result.SeparateProcess)" 658 | 659 | # Folderoptions launch folder windows in separate process 660 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name SeparateProcess -Value 1 -PropertyType DWORD -Force 661 | Write-TSxLog "$ScriptName - SeparateProcess is now: $($result.SeparateProcess)" 662 | } 663 | if($ShowIconsOnlyNoThumbnails -eq $true -and $IsServerCoreOS -eq $false){ 664 | # Folderoptions Always show icons never thumbnails 665 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name IconsOnly -Value 1 -PropertyType DWORD -Force 666 | Write-TSxLog "$ScriptName - IconsOnly is now: $($result.IconsOnly)" 667 | 668 | # Folderoptions Always show icons never thumbnails 669 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name IconsOnly -Value 1 -PropertyType DWORD -Force 670 | Write-TSxLog "$ScriptName - IconsOnly is now: $($result.IconsOnly)" 671 | } 672 | if($DontShowInfoTip -eq $true -and $IsServerCoreOS -eq $false){ 673 | # Dont show tooltip 674 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name ShowInfoTip -Value 0 -PropertyType DWORD -Force 675 | Write-TSxLog "$ScriptName - ShowInfoTip is now: $($result.ShowInfoTip)" 676 | 677 | # Dont show tooltip 678 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name ShowInfoTip -Value 0 -PropertyType DWORD -Force 679 | Write-TSxLog "$ScriptName - ShowInfoTip is now: $($result.ShowInfoTip)" 680 | } 681 | if($ShowComputerOnDesktop -eq $true -and $IsServerCoreOS -eq $false){ 682 | # Show computer on desktop 683 | $null = New-Item -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons' -Force 684 | $null = New-Item -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel' -Force 685 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel' -Name '{20D04FE0-3AEA-1069-A2D8-08002B30309D}' -Value 0 -PropertyType DWORD -Force 686 | Write-TSxLog "$ScriptName - TaskbarSmallIcons is now: $($result.'{20D04FE0-3AEA-1069-A2D8-08002B30309D}')" 687 | 688 | # Show computer on desktop 689 | $null = New-Item -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons' -Force 690 | $null = New-Item -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel' -Force 691 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel' -Name '{20D04FE0-3AEA-1069-A2D8-08002B30309D}' -Value 0 -PropertyType DWORD -Force 692 | Write-TSxLog "$ScriptName - TaskbarSmallIcons is now: $($result.'{20D04FE0-3AEA-1069-A2D8-08002B30309D}')" 693 | } 694 | if($ShowAllTaskbarIconsAndNotifcations -eq $true -and $IsServerCoreOS -eq $false){ 695 | # Always show all taskbar icons and notifcations 696 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer' -Name EnableAutoTray -Value 0 -PropertyType DWORD -Force 697 | Write-TSxLog "$ScriptName - EnableAutoTray is now: $($result.EnableAutoTray)" 698 | 699 | # Always show all taskbar icons and notifcations 700 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer' -Name EnableAutoTray -Value 0 -PropertyType DWORD -Force 701 | Write-TSxLog "$ScriptName - EnableAutoTray is now: $($result.EnableAutoTray)" 702 | } 703 | if($SetControlPanelToSmallIconsView -eq $true -and $IsServerCoreOS -eq $false){ 704 | # Set control panel to small icons view 705 | $null = New-Item -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel' -Force 706 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel' -Name AllItemsIconView -Value 1 -PropertyType DWORD -Force 707 | Write-TSxLog "$ScriptName - AllItemsIconView is now: $($result.AllItemsIconView)" 708 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel' -Name StartupPage -Value 1 -PropertyType DWORD -Force 709 | Write-TSxLog "$ScriptName - StartupPage is now: $($result.StartupPage)" 710 | 711 | # Set control panel to small icons view 712 | $null = New-Item -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel' -Force 713 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel' -Name AllItemsIconView -Value 1 -PropertyType DWORD -Force 714 | Write-TSxLog "$ScriptName - AllItemsIconView is now: $($result.AllItemsIconView)" 715 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel' -Name StartupPage -Value 1 -PropertyType DWORD -Force 716 | Write-TSxLog "$ScriptName - StartupPage is now: $($result.StartupPage)" 717 | } 718 | if($DisableVolumeIcon -eq $true -and $IsServerCoreOS -eq $false){ 719 | # Disable the Volume Icon in system icons 720 | $null = New-Item -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies' -Force 721 | $null = New-Item -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer' -Force 722 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer' -Name HideSCAVolume -Value 1 -PropertyType DWORD -Force 723 | Write-TSxLog "$ScriptName - HideSCAVolume is now: $($result.HideSCAVolume)" 724 | 725 | # Disable the Volume Icon in system icons 726 | $null = New-Item -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies' -Force 727 | $null = New-Item -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer' -Force 728 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer' -Name HideSCAVolume -Value 1 -PropertyType DWORD -Force 729 | Write-TSxLog "$ScriptName - HideSCAVolume is now: $($result.HideSCAVolume)" 730 | } 731 | if($DisableAutosearch -eq $true -and $IsServerCoreOS -eq $false){ 732 | # Disable Search in the address bar and the search box on the new tab page 733 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Internet Explorer\Main' -Name Autosearch -Value 0 -PropertyType DWORD -Force 734 | Write-TSxLog "$ScriptName - Autosearch is now: $($result.Autosearch)" 735 | 736 | # Disable Search in the address bar and the search box on the new tab page 737 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Internet Explorer\Main' -Name Autosearch -Value 0 -PropertyType DWORD -Force 738 | Write-TSxLog "$ScriptName - Autosearch is now: $($result.Autosearch)" 739 | } 740 | if($SetAutoDetectProxySettingsEmpty -eq $true -and $IsServerCoreOS -eq $false){ 741 | # Set AutoDetectProxySettings Empty 742 | $result = New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings' -Name AutoDetect -Value 0 -PropertyType DWORD -Force 743 | Write-TSxLog "$ScriptName - AutoDetect is now: $($result.AutoDetect)" 744 | 745 | # Set AutoDetectProxySettings Empty 746 | $result = New-ItemProperty -Path 'HKLM:\defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings' -Name AutoDetect -Value 0 -PropertyType DWORD -Force 747 | Write-TSxLog "$ScriptName - AutoDetect is now: $($result.AutoDetect)" 748 | } 749 | 750 | [gc]::collect() 751 | Write-TSxLog "$ScriptName - $Action - UnLoading C:\Users\Default\NTUSER.DAT" 752 | REG UNLOAD HKEY_LOCAL_MACHINE\defuser 753 | 754 | Write-TSxLog "$ScriptName - Done" 755 | #Custom Code Ends-------------------------------------- 756 | -------------------------------------------------------------------------------- /MDTApps/Install - C++ Runtime v14 framework package for Desktop Bridge/Install-C++Runtimev14.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Short description. 4 | .DESCRIPTION 5 | Long description 6 | .EXAMPLE 7 | 8 | #> 9 | 10 | [CmdletBinding(SupportsShouldProcess=$true)] 11 | Param() 12 | 13 | Function Invoke-Exe{ 14 | [CmdletBinding(SupportsShouldProcess=$true)] 15 | 16 | param( 17 | [parameter(mandatory=$true,position=0)] 18 | [ValidateNotNullOrEmpty()] 19 | [string] 20 | $Executable, 21 | 22 | [parameter(mandatory=$false,position=1)] 23 | [string] 24 | $Arguments 25 | ) 26 | 27 | if($Arguments -eq "") 28 | { 29 | Write-Verbose "Running $ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru" 30 | $ReturnFromEXE = Start-Process -FilePath $Executable -NoNewWindow -Wait -Passthru 31 | }else{ 32 | Write-Verbose "Running $ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru" 33 | $ReturnFromEXE = Start-Process -FilePath $Executable -ArgumentList $Arguments -NoNewWindow -Wait -Passthru 34 | } 35 | Write-Verbose "Returncode is $($ReturnFromEXE.ExitCode)" 36 | Return $ReturnFromEXE.ExitCode 37 | } 38 | Function Get-OSVersion{ 39 | $OS = Get-WmiObject -Class Win32_OperatingSystem 40 | Switch -Regex ($OS.Version) 41 | { 42 | "6.1" 43 | { 44 | If($OS.ProductType -eq 1) 45 | {$OSv = "Windows 7 SP1"} 46 | Else 47 | {$OSv = "Windows Server 2008 R2"} 48 | } 49 | "6.2" 50 | {If($OS.ProductType -eq 1) 51 | {$OSv = "Windows 8"} 52 | Else 53 | {$OSv = "Windows Server 2012"} 54 | } 55 | "6.3" 56 | {If($OS.ProductType -eq 1) 57 | {$OSv = "Windows 8.1"} 58 | Else 59 | {$OSv = "Windows Server 2012 R2"} 60 | } 61 | "10." 62 | {If($OS.ProductType -eq 1) 63 | {$OSv = "Windows 10"} 64 | Else 65 | {$OSv = "Windows Server 2016"} 66 | } 67 | DEFAULT {$OSv = "Unknown"} 68 | } 69 | Return $OSV 70 | } 71 | Function Import-SMSTSENV{ 72 | try 73 | { 74 | $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment 75 | Write-Output "$ScriptName - tsenv is $tsenv " 76 | $MDTIntegration = "YES" 77 | 78 | #$tsenv.GetVariables() | % { Write-Output "$ScriptName - $_ = $($tsenv.Value($_))" } 79 | } 80 | catch 81 | { 82 | Write-Output "$ScriptName - Unable to load Microsoft.SMS.TSEnvironment" 83 | Write-Output "$ScriptName - Running in standalonemode" 84 | $MDTIntegration = "NO" 85 | } 86 | Finally 87 | { 88 | if ($MDTIntegration -eq "YES"){ 89 | $Logpath = $tsenv.Value("LogPath") 90 | $LogFile = $Logpath + "\" + "$ScriptName.txt" 91 | 92 | } 93 | Else{ 94 | $Logpath = $env:TEMP 95 | $LogFile = $Logpath + "\" + "$ScriptName.txt" 96 | } 97 | } 98 | } 99 | Function Start-Logging{ 100 | start-transcript -path $LogFile -Force 101 | } 102 | Function Stop-Logging{ 103 | Stop-Transcript 104 | } 105 | 106 | # Set Vars 107 | $SCRIPTDIR = split-path -parent $MyInvocation.MyCommand.Path 108 | $SCRIPTNAME = split-path -leaf $MyInvocation.MyCommand.Path 109 | $SOURCEROOT = "$SCRIPTDIR\Source" 110 | $LANG = (Get-Culture).Name 111 | $ARCHITECTURE = $env:PROCESSOR_ARCHITECTURE 112 | 113 | #Try to Import SMSTSEnv 114 | . Import-SMSTSENV 115 | 116 | #Start Transcript Logging 117 | . Start-Logging 118 | 119 | #Detect current OS Version 120 | $OSVersion = Get-OSVersion 121 | 122 | #Output base info 123 | Write-Output "" 124 | Write-Output "$ScriptName - ScriptDir: $ScriptDir" 125 | Write-Output "$ScriptName - SourceRoot: $SOURCEROOT" 126 | Write-Output "$ScriptName - ScriptName: $ScriptName" 127 | Write-Output "$ScriptName - OS Name: $OSVersion" 128 | Write-Output "$ScriptName - OS Architecture: $ARCHITECTURE" 129 | Write-Output "$ScriptName - Current Culture: $LANG" 130 | Write-Output "$ScriptName - Integration with MDT(LTI/ZTI): $MDTIntegration" 131 | Write-Output "$ScriptName - Log: $LogFile" 132 | 133 | $InstallerFile = Get-ChildItem -Path $SOURCEROOT -Filter *.exe 134 | 135 | $Arguments = "/QUIET /NORESTART " 136 | $Exe = $InstallerFile.FullName 137 | 138 | Write-Output "$ScriptName - Invoke-Exe -Executable $Exe -Arguments $Arguments" 139 | Invoke-Exe -Executable $Exe -Arguments $Arguments 140 | #Stop Logging 141 | . Stop-Logging -------------------------------------------------------------------------------- /MDTApps/Install - Microsoft BGInfo - x86-x64/Install-MicrosoftBGInfox86x64.wsf: -------------------------------------------------------------------------------- 1 | 2 | 85 | -------------------------------------------------------------------------------- /MDTApps/Install - Microsoft BGInfo - x86-x64/Source/Bginfo.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeploymentBunny/IMF4/445174060bf86f1efe55ae9b592d907da2607dde/MDTApps/Install - Microsoft BGInfo - x86-x64/Source/Bginfo.lnk -------------------------------------------------------------------------------- /MDTApps/Install - Microsoft BGInfo - x86-x64/Source/Custom.bgi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeploymentBunny/IMF4/445174060bf86f1efe55ae9b592d907da2607dde/MDTApps/Install - Microsoft BGInfo - x86-x64/Source/Custom.bgi -------------------------------------------------------------------------------- /MDTApps/Install - Microsoft Visual C++/Install-MicrosoftVisualC++x86x64.wsf: -------------------------------------------------------------------------------- 1 | 2 | 257 | -------------------------------------------------------------------------------- /MDTApps/Install - Roles and Features/InstallRolesAndFeatures.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | ImageFactory 3.3 4 | .DESCRIPTION 5 | ImageFactory 3.3 6 | .EXAMPLE 7 | ImageFactoryV3-Verify-ShowContent.ps1 8 | .NOTES 9 | Created: 2016-11-24 10 | Version: 3.1 11 | 12 | Updated: 2017-02-23 13 | Version: 3.2 14 | 15 | Updated: 2017-09-27 16 | Version: 3.3 17 | 18 | Author - Mikael Nystrom 19 | Twitter: @mikael_nystrom 20 | Blog : http://deploymentbunny.com 21 | 22 | Disclaimer: 23 | This script is provided 'AS IS' with no warranties, confers no rights and 24 | is not supported by the author. 25 | 26 | This script uses the PsIni module: 27 | Blog : http://oliver.lipkau.net/blog/ 28 | Source : https://github.com/lipkau/PsIni 29 | http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 30 | 31 | .LINK 32 | http://www.deploymentbunny.com 33 | #> 34 | 35 | Function Import-SMSTSENV{ 36 | try 37 | { 38 | $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment 39 | Write-Output "$ScriptName - tsenv is $tsenv " 40 | $MDTIntegration = "YES" 41 | 42 | #$tsenv.GetVariables() | % { Write-Output "$ScriptName - $_ = $($tsenv.Value($_))" } 43 | } 44 | catch 45 | { 46 | Write-Output "$ScriptName - Unable to load Microsoft.SMS.TSEnvironment" 47 | Write-Output "$ScriptName - Running in standalonemode" 48 | $MDTIntegration = "NO" 49 | } 50 | Finally 51 | { 52 | if ($MDTIntegration -eq "YES"){ 53 | $Logpath = $tsenv.Value("LogPath") 54 | $LogFile = $Logpath + "\" + "$ScriptName.log" 55 | 56 | } 57 | Else{ 58 | $Logpath = $env:TEMP 59 | $LogFile = $Logpath + "\" + "$ScriptName.log" 60 | } 61 | } 62 | } 63 | Function Start-Logging{ 64 | start-transcript -path $LogFile -Force 65 | } 66 | Function Stop-Logging{ 67 | Stop-Transcript 68 | } 69 | 70 | # Set vars 71 | $SCRIPTDIR = split-path -parent $MyInvocation.MyCommand.Path 72 | $SCRIPTNAME = split-path -leaf $MyInvocation.MyCommand.Path 73 | $SOURCEROOT = "$SCRIPTDIR\Source" 74 | $SettingsFile = $SCRIPTDIR + "\" + $SettingsName 75 | $LANG = (Get-Culture).Name 76 | $OSV = $Null 77 | $ARCHITECTURE = $env:PROCESSOR_ARCHITECTURE 78 | 79 | #Try to Import SMSTSEnv 80 | . Import-SMSTSENV 81 | 82 | # Set more vars 83 | $Make = $tsenv.Value("Make") 84 | $Model = $tsenv.Value("Model") 85 | $ModelAlias = $tsenv.Value("ModelAlias") 86 | $MakeAlias = $tsenv.Value("MakeAlias") 87 | $OSDComputername = $tsenv.Value("OSDComputername") 88 | 89 | #Start Transcript Logging 90 | . Start-Logging 91 | 92 | #Output base info 93 | Write-Output "" 94 | Write-Output "$ScriptName - ScriptDir: $ScriptDir" 95 | Write-Output "$ScriptName - SourceRoot: $SOURCEROOT" 96 | Write-Output "$ScriptName - ScriptName: $ScriptName" 97 | Write-Output "$ScriptName - Current Culture: $LANG" 98 | Write-Output "$ScriptName - Integration with MDT(LTI/ZTI): $MDTIntegration" 99 | Write-Output "$ScriptName - Log: $LogFile" 100 | Write-Output "$ScriptName - Model (win32_computersystem): $((Get-WmiObject Win32_ComputerSystem).model)" 101 | Write-Output "$ScriptName - Name (Win32_ComputerSystemProduct): $((Get-WmiObject Win32_ComputerSystemProduct).Name)" 102 | Write-Output "$ScriptName - Version (Win32_ComputerSystemProduct): $((Get-WmiObject Win32_ComputerSystemProduct).Version)" 103 | Write-Output "$ScriptName - Model (from TSENV): $Model" 104 | Write-Output "$ScriptName - ModelAlias (from TSENV): $ModelAlias" 105 | Write-Output "$ScriptName - OSDComputername (from TSENV): $OSDComputername" 106 | Write-Output "$ScriptName - ModelAlias (from TSENV): $ModelAlias" 107 | Write-Output "$ScriptName - OSDComputername (from TSENV): $OSDComputername" 108 | 109 | $ImageBuild = $tsenv.Value("IMAGEBUILD") 110 | switch ($ImageBuild.Substring(0,3)) 111 | { 112 | '10.' { 113 | $tsenv.Value("OSRoleIndex") = "10" 114 | } 115 | Default { 116 | $tsenv.Value("OSRoleIndex") = $ImageBuild.Substring(0,3) 117 | } 118 | } 119 | Write-Output "$ScriptName - OSRoleIndex is now $($tsenv.Value("OSRoleIndex"))" 120 | 121 | #Stop Transcript Logging 122 | . Stop-Logging 123 | -------------------------------------------------------------------------------- /ReadME.md: -------------------------------------------------------------------------------- 1 | Image Factory 4.0 2 | - UI Based 3 | - Script has been polished 4 | - Logging is updated to CMtrace format 5 | -------------------------------------------------------------------------------- /RunMe.ps1: -------------------------------------------------------------------------------- 1 | Set-Location -Path E:\IMF4 2 | 3 | #Update Bootimage 4 | .\Scripts\IMF-UpdateBootImage.ps1 5 | 6 | #Make sure we are clean 7 | .\Scripts\IMF-VerifyCleanupVMs.ps1 8 | 9 | #Start the Image Factory 10 | .\Scripts\IMF-Build.ps1 -EnableWSUS True 11 | 12 | # Publish 13 | # .\Scripts\IMF-Publish.ps1 -VHDUEFI -VHDBIOS 14 | 15 | #Move to Archive 16 | .\Scripts\IMF-Archive.ps1 -------------------------------------------------------------------------------- /SampleScript.ps1: -------------------------------------------------------------------------------- 1 | #Configure Imagefactory 2 | .\Scripts\IMF-Configure.ps1 -DeploymentShare E:\MDTBuildLab -StartUpRAM 4 -VLANID 0 -Computername HYPERVHOST01 -SwitchName "SwitchName" -VMLocation E:\VMs -ISOLocation E:\ISO -ConcurrentRunningVMs 2 -BuildaccountName MDT_BA -BuildaccountPassword Passw0rd!# 3 | 4 | #Install Imagefactory 5 | .\Scripts\IMF-Install.ps1 6 | 7 | #Uninstall Imagefactory 8 | .\Scripts\IMF-Uninstall.ps1 9 | 10 | #Import ISO 11 | .\Scripts\IMF-ImportISO.ps1 -ISOImage D:\ISO\SW_DVD5_Win_Pro_Ent_Edu_N_10_1709_64BIT_English_MLF_X21-50143.ISO -OSFolder W10x6417091 -OrgName ViaMonstra 12 | #.\Scripts\Import-ISO.ps1 -ISOImage D:\ISO\SW_DVD5_Win_Pro_Ent_Edu_N_10_1709_64BIT_English_MLF_X21-50143.ISO -OSFolder W10x6417092 -OrgName ViaMonstra 13 | 14 | #Update Bootimage 15 | .\Scripts\IMF-UpdateBootImage.ps1 16 | 17 | #Make sure we are clean 18 | .\Scripts\IMF-VerifyCleanupVMs.ps1 19 | 20 | #Start the Image Factory 21 | .\Scripts\IMF-Build.ps1 -EnableWSUS True 22 | 23 | #Start the Image Factory 24 | .\Scripts\IMF-Build.ps1 -EnableWSUS False 25 | 26 | #Verify the build 27 | .\Scripts\IMF-VerifyBuild.ps1 -KeepVMs False 28 | 29 | #Make sure we are clean 30 | .\Scripts\IMF-VerifyCleanupVMs.ps1 31 | 32 | #Generate Report 33 | .\Scripts\IMF-GenerateReport.ps1 34 | 35 | #Generate VHDx 36 | $DateTime = (Get-Date).ToString('yyyyMMdd') 37 | $CaptureFolder = "E:\MDTBuildLab\Captures" 38 | $VHDxFolder = "E:\VHD\$DateTime" 39 | #.\Scripts\\ImageFactoryV3-ConvertToVHD.ps1 -CaptureFolder $CaptureFolder -VHDxFolder $VHDxFolder -UEFI $True -BIOS $false 40 | 41 | # Publish 42 | .\Scripts\IMF-Publish.ps1 -VHDUEFI -VHDBIOS 43 | 44 | #Move to Archive 45 | .\Scripts\IMF-Archive.ps1 -------------------------------------------------------------------------------- /Scripts/Convert-VIAWIM2VHD.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeploymentBunny/IMF4/445174060bf86f1efe55ae9b592d907da2607dde/Scripts/Convert-VIAWIM2VHD.ps1 -------------------------------------------------------------------------------- /Scripts/IMF-Archive.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | ImageFactory 3.2 4 | .DESCRIPTION 5 | ImageFactory 3.2 6 | .EXAMPLE 7 | ImageFactoryV3-Build.ps1 8 | .NOTES 9 | Created: 2016-11-24 10 | Version: 3.1 11 | 12 | Updated: 2017-02-23 13 | Version: 3.2 14 | 15 | 16 | Author - Mikael Nystrom 17 | Twitter: @mikael_nystrom 18 | Blog : http://deploymentbunny.com 19 | 20 | Disclaimer: 21 | This script is provided 'AS IS' with no warranties, confers no rights and 22 | is not supported by the author. 23 | 24 | This script uses the PsIni module: 25 | Blog : http://oliver.lipkau.net/blog/ 26 | Source : https://github.com/lipkau/PsIni 27 | http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 28 | 29 | .LINK 30 | http://www.deploymentbunny.com 31 | #> 32 | [cmdletbinding(SupportsShouldProcess=$True)] 33 | Param( 34 | ) 35 | 36 | #Inititial Settings 37 | $CurrentPath = split-path -parent $MyInvocation.MyCommand.Path 38 | $RootPath = split-path -parent $CurrentPath 39 | $Global:ScriptLogFilePath = "$RootPath\IMF.log" 40 | $XMLFile = "$RootPath\IMF.xml" 41 | $Global:writetoscreen = $true 42 | 43 | #Read Settings from XML 44 | Write-Log -Message "Reading from $XMLFile" 45 | [xml]$Settings = Get-Content $XMLFile -ErrorAction Stop -WarningAction Stop 46 | 47 | #Verify Connection to DeploymentRoot 48 | Write-Log -Message "Verify Connection to DeploymentRoot" 49 | $Result = Test-Path -Path $Settings.Settings.MDT.DeploymentShare 50 | If($Result -ne $true){ 51 | Write-Log -Message "Cannot access $($Settings.Settings.MDT.DeploymentShare) , will break" 52 | break 53 | } 54 | 55 | #Creating folder 56 | Write-Log -Message "Creating $($Settings.Settings.MDT.DeploymentShare)\Capture\Archive if needed" 57 | New-Item -ItemType Directory -Path "$($Settings.Settings.MDT.DeploymentShare)\Captures\Archive" -Force 58 | 59 | #Moving files 60 | Write-Log -Message "Moving files from $($Settings.Settings.MDT.DeploymentShare)\Captures to $($Settings.Settings.MDT.DeploymentShare)\Captures\Archive" 61 | $WIMs = Get-ChildItem -Path "$($Settings.Settings.MDT.DeploymentShare)\Captures" -Filter *.wim 62 | foreach($wim in $WIMs){ 63 | Write-Log -Message "Moving $($wim.FullName) to $($Settings.Settings.MDT.DeploymentShare)\Captures\Archive" 64 | Move-Item -Path $wim.FullName -Destination "$($Settings.Settings.MDT.DeploymentShare)\Captures\Archive" -Force 65 | } 66 | 67 | 68 | Write-Log -Message "Done" 69 | Return "OK" -------------------------------------------------------------------------------- /Scripts/IMF-Build.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeploymentBunny/IMF4/445174060bf86f1efe55ae9b592d907da2607dde/Scripts/IMF-Build.ps1 -------------------------------------------------------------------------------- /Scripts/IMF-Configure.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | ImageFactory 3.2 4 | .DESCRIPTION 5 | ImageFactory 3.2 6 | .EXAMPLE 7 | ImageFactoryV3-Build.ps1 8 | .NOTES 9 | Created: 2016-11-24 10 | Version: 3.1 11 | 12 | Updated: 2017-02-23 13 | Version: 3.2 14 | 15 | 16 | Author - Mikael Nystrom 17 | Twitter: @mikael_nystrom 18 | Blog : http://deploymentbunny.com 19 | 20 | Disclaimer: 21 | This script is provided 'AS IS' with no warranties, confers no rights and 22 | is not supported by the author. 23 | 24 | This script uses the PsIni module: 25 | Blog : http://oliver.lipkau.net/blog/ 26 | Source : https://github.com/lipkau/PsIni 27 | http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 28 | 29 | .LINK 30 | http://www.deploymentbunny.com 31 | #> 32 | 33 | [cmdletbinding(SupportsShouldProcess=$True)] 34 | Param( 35 | [parameter(mandatory=$false)] 36 | [string] 37 | $DeploymentShare = "NA", 38 | 39 | [parameter(mandatory=$false)] 40 | [string] 41 | $Computername = "NA", 42 | 43 | [parameter(mandatory=$false)] 44 | [string] 45 | $SwitchName = "NA", 46 | 47 | [parameter(mandatory=$false)] 48 | [string] 49 | $VLANID = "0", 50 | 51 | [parameter(mandatory=$false)] 52 | [string] 53 | $VMLocation = "NA", 54 | 55 | [parameter(mandatory=$false)] 56 | [string] 57 | $ISOLocation = "", 58 | 59 | [parameter(mandatory=$false)] 60 | [string] 61 | $BuildaccountName = "MDT_BA", 62 | 63 | [parameter(mandatory=$false)] 64 | [string] 65 | $BuildaccountPassword = "P@ssw0rd", 66 | 67 | [parameter(mandatory=$false)] 68 | [string] 69 | $CustomerName = "ViaMonstra", 70 | 71 | [parameter(mandatory=$false)] 72 | [string] 73 | $ConcurrentRunningVMs = "2", 74 | 75 | [parameter(mandatory=$false)] 76 | [string] 77 | $StartUpRAM = "3" 78 | ) 79 | 80 | #Requires -RunAsAdministrator 81 | 82 | #Inititial Settings 83 | $CurrentPath = split-path -parent $MyInvocation.MyCommand.Path 84 | $RootPath = split-path -parent $CurrentPath 85 | #$RootPath = "D:\IMFv3" 86 | $Global:ScriptLogFilePath = "$RootPath\IMF.log" 87 | $XMLFile = "$RootPath\IMF.xml" 88 | $Global:writetoscreen = $true 89 | 90 | #Install IMFFuctions 91 | Copy-item -Path "$RootPath\Functions\IMFFunctions" -Destination 'C:\Program Files\WindowsPowerShell\Modules' -ErrorAction Stop -Recurse -Force 92 | Import-Module IMFFunctions -ErrorAction Stop -WarningAction Stop -Force 93 | Write-Log -Message "Module IMFFunctions imported" 94 | 95 | #Install PSINI 96 | if((Get-Module PSINI).name -ne "PSINI"){ 97 | Install-Module PSINI -Force -SkipPublisherCheck -ErrorAction Stop 98 | }else{Update-Module PSINI -Force} 99 | Import-Module PsIni -ErrorAction Stop -WarningAction Stop -MinimumVersion 2.0.5 100 | Write-Log -Message "Module PsIni imported" 101 | 102 | #Importing ModuleMicrosoftDeploymentToolkit 103 | Import-Module 'C:\Program Files\Microsoft Deployment Toolkit\Bin\MicrosoftDeploymentToolkit.psd1' -ErrorAction Stop -WarningAction Stop 104 | Write-Log -Message "ModuleMicrosoftDeploymentToolkit imported" 105 | 106 | #Inititial Settings 107 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 108 | Write-Log -Message "Logfile is $ScriptLogFilePath" 109 | Write-Log -Message "XMLfile is $XMLfile" 110 | 111 | #Read Settings from XML 112 | Write-Log -Message "Reading from $XMLFile" 113 | [xml]$Settings = Get-Content $XMLFile -ErrorAction Stop -WarningAction Stop 114 | 115 | #Update XMLfile 116 | Write-Log -Message "Update XML file" 117 | $Settings.Settings.HyperV.Computername = $Computername 118 | $Settings.Settings.HyperV.VMLocation = $VMLocation 119 | $Settings.Settings.HyperV.ISOLocation = $ISOLocation 120 | $Settings.Settings.HyperV.VLANID = $VLANID 121 | $Settings.Settings.HyperV.StartUpRAM = $StartUpRAM 122 | $Settings.Settings.HyperV.SwitchName = $SwitchName 123 | $settings.Settings.MDT.DeploymentShare = $DeploymentShare 124 | $settings.Settings.ConcurrentRunningVMs = $ConcurrentRunningVMs 125 | $settings.Settings.Security.BuildAccount.Name = $BuildaccountName 126 | $settings.Settings.Security.BuildAccount.Password = $BuildaccountPassword 127 | $settings.Settings.CustomerName = $CustomerName 128 | 129 | #Save cnfig fie 130 | Write-Log -Message "Save to XML file" 131 | $settings.Save("$XMLFile") 132 | Write-Log -Message "Done" -------------------------------------------------------------------------------- /Scripts/IMF-ConvertToVHD.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | ImageFactory 3.3 4 | .DESCRIPTION 5 | ImageFactory 3.3 6 | .EXAMPLE 7 | ImageFactoryV3-ConvertToVHD.ps1 8 | .NOTES 9 | Created: 2016-11-24 10 | Version: 3.1 11 | 12 | Updated: 2017-02-23 13 | Version: 3.2 14 | 15 | Updated: 2017-09-27 16 | Version: 3.3 17 | 18 | 19 | Author - Mikael Nystrom 20 | Twitter: @mikael_nystrom 21 | Blog : http://deploymentbunny.com 22 | 23 | Disclaimer: 24 | This script is provided 'AS IS' with no warranties, confers no rights and 25 | is not supported by the author. 26 | 27 | This script uses the PsIni module: 28 | Blog : http://oliver.lipkau.net/blog/ 29 | Source : https://github.com/lipkau/PsIni 30 | http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 31 | 32 | .LINK 33 | http://www.deploymentbunny.com 34 | #> 35 | Param( 36 | $CaptureFolder = "D:\MDTBuildLab\Captures", 37 | $VHDxFolder = "C:\Setup\VHD\$DateTime", 38 | $UEFI = $true, 39 | $BIOS = $false 40 | ) 41 | 42 | New-Item -Path $VHDxFolder -ItemType Directory -Force 43 | 44 | $wims = Get-ChildItem -Path $CaptureFolder -Filter *.wim 45 | foreach($wim in $wims){ 46 | $WindowsImage = Get-WindowsImage -ImagePath $wim.FullName -Index 1 -Verbose 47 | if ($WindowsImage.ImageDescription -ne ""){ 48 | $ImageName = $WindowsImage.ImageDescription 49 | }else{ 50 | $ImageName = $wim.BaseName 51 | } 52 | Write-Host "$($wim.FullName) is $ImageName" 53 | } 54 | 55 | 56 | $wims = Get-ChildItem -Path $CaptureFolder -Filter *.wim 57 | foreach($wim in $wims){ 58 | $WindowsImage = Get-WindowsImage -ImagePath $wim.FullName -Index 1 -Verbose 59 | if ($WindowsImage.ImageDescription -ne ""){ 60 | $ImageName = $WindowsImage.ImageDescription 61 | }else{ 62 | $ImageName = $wim.BaseName 63 | } 64 | 65 | Write-Host "Working on $ImageName" 66 | if($UEFI -eq $True){ 67 | #Create UEFI VHDX files 68 | $DestinationFile = $VHDxFolder + "\" + $ImageName + "_UEFI.vhdx" 69 | if((Test-Path -Path $DestinationFile) -ne $true){ 70 | Write-Host "About to create $DestinationFile" 71 | C:\Setup\ImageFactoryV3ForHyper-V\Convert-VIAWIM2VHD.ps1 -SourceFile $wim.FullName -DestinationFile $DestinationFile -Disklayout UEFI -SizeInMB 80000 -Index 1 72 | }else{ 73 | Write-Host "$DestinationFile already exists" 74 | } 75 | } 76 | 77 | if($BIOS -eq $True){ 78 | #Create BIOS VHDX files 79 | $DestinationFile = $VHDxFolder + "\" + $ImageName + "_BIOS.vhdx" 80 | if((Test-Path -Path $DestinationFile) -ne $true){ 81 | Write-Host "About to create $DestinationFile" 82 | C:\Setup\ImageFactoryV3ForHyper-V\Convert-VIAWIM2VHD.ps1 -SourceFile $wim.FullName -DestinationFile $DestinationFile -Disklayout BIOS -SizeInMB 80000 -Index 1 83 | }else{ 84 | Write-Host "$DestinationFile already exists" 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Scripts/IMF-Display.ps1: -------------------------------------------------------------------------------- 1 | #Inititial Settings 2 | $CurrentPath = Split-Path -parent $MyInvocation.MyCommand.Path 3 | $RootPath = Split-Path -parent $CurrentPath 4 | $Global:ScriptLogFilePath = "$RootPath\IMF.log" 5 | $XMLFile = "$RootPath\IMF.xml" 6 | $Global:writetoscreen = $true 7 | 8 | #Install IMFFuctions 9 | Import-Module IMFFunctions -ErrorAction Stop -WarningAction Stop -Force 10 | Write-Log -Message "Module IMFFunctions imported" 11 | 12 | #Install PSINI 13 | Import-Module PsIni -ErrorAction Stop -WarningAction Stop -RequiredVersion 2.0.5 14 | Write-Log -Message "Module PsIni imported" 15 | 16 | #Importing ModuleMicrosoftDeploymentToolkit 17 | Import-Module 'C:\Program Files\Microsoft Deployment Toolkit\Bin\MicrosoftDeploymentToolkit.psd1' -ErrorAction Stop -WarningAction Stop 18 | Write-Log -Message "Module Microsoft Deployment Toolkit imported" 19 | 20 | Write-Log -Message "writetoscreen is $writetoscreen" 21 | Write-Log -Message "writetolistbox is $writetolistbox" 22 | 23 | #Inititial Settings 24 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 25 | Write-Log -Message "Logfile is $ScriptLogFilePath" 26 | Write-Log -Message "XMLfile is $XMLfile" 27 | 28 | Start-Sleep -Seconds 5 29 | 30 | #Inititial Settings 31 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 32 | Write-Log -Message "Logfile is $ScriptLogFilePath" 33 | Write-Log -Message "XMLfile is $XMLfile" 34 | 35 | Start-Sleep -Seconds 5 36 | 37 | #Inititial Settings 38 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 39 | Write-Log -Message "Logfile is $ScriptLogFilePath" 40 | Write-Log -Message "XMLfile is $XMLfile" 41 | 42 | Start-Sleep -Seconds 5 43 | 44 | #Inititial Settings 45 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 46 | Write-Log -Message "Logfile is $ScriptLogFilePath" 47 | Write-Log -Message "XMLfile is $XMLfile" 48 | 49 | Start-Sleep -Seconds 5 50 | 51 | #Inititial Settings 52 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 53 | Write-Log -Message "Logfile is $ScriptLogFilePath" 54 | Write-Log -Message "XMLfile is $XMLfile" 55 | 56 | Start-Sleep -Seconds 5 57 | 58 | #Inititial Settings 59 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 60 | Write-Log -Message "Logfile is $ScriptLogFilePath" 61 | Write-Log -Message "XMLfile is $XMLfile" 62 | 63 | Start-Sleep -Seconds 5 64 | Write-Log -Message "Done" 65 | -------------------------------------------------------------------------------- /Scripts/IMF-Display.txt: -------------------------------------------------------------------------------- 1 | #Inititial Settings 2 | $CurrentPath = Split-Path -parent $MyInvocation.MyCommand.Path 3 | $RootPath = Split-Path -parent $CurrentPath 4 | $Global:ScriptLogFilePath = "$RootPath\IMF.log" 5 | $XMLFile = "$RootPath\IMF.xml" 6 | $Global:writetoscreen = $true 7 | 8 | #Install IMFFuctions 9 | Import-Module IMFFunctions -ErrorAction Stop -WarningAction Stop -Force 10 | Write-Log -Message "Module IMFFunctions imported" 11 | 12 | #Install PSINI 13 | Import-Module PsIni -ErrorAction Stop -WarningAction Stop -RequiredVersion 2.0.5 14 | Write-Log -Message "Module PsIni imported" 15 | 16 | #Importing ModuleMicrosoftDeploymentToolkit 17 | Import-Module 'C:\Program Files\Microsoft Deployment Toolkit\Bin\MicrosoftDeploymentToolkit.psd1' -ErrorAction Stop -WarningAction Stop 18 | Write-Log -Message "Module Microsoft Deployment Toolkit imported" 19 | 20 | Write-Log -Message "writetoscreen is $writetoscreen" 21 | Write-Log -Message "writetolistbox is $writetolistbox" 22 | 23 | #Inititial Settings 24 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 25 | Write-Log -Message "Logfile is $ScriptLogFilePath" 26 | Write-Log -Message "XMLfile is $XMLfile" 27 | 28 | Start-Sleep -Seconds 5 29 | 30 | #Inititial Settings 31 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 32 | Write-Log -Message "Logfile is $ScriptLogFilePath" 33 | Write-Log -Message "XMLfile is $XMLfile" 34 | 35 | Start-Sleep -Seconds 5 36 | 37 | #Inititial Settings 38 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 39 | Write-Log -Message "Logfile is $ScriptLogFilePath" 40 | Write-Log -Message "XMLfile is $XMLfile" 41 | 42 | Start-Sleep -Seconds 5 43 | 44 | #Inititial Settings 45 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 46 | Write-Log -Message "Logfile is $ScriptLogFilePath" 47 | Write-Log -Message "XMLfile is $XMLfile" 48 | 49 | Start-Sleep -Seconds 5 50 | 51 | #Inititial Settings 52 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 53 | Write-Log -Message "Logfile is $ScriptLogFilePath" 54 | Write-Log -Message "XMLfile is $XMLfile" 55 | 56 | Start-Sleep -Seconds 5 57 | 58 | #Inititial Settings 59 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 60 | Write-Log -Message "Logfile is $ScriptLogFilePath" 61 | Write-Log -Message "XMLfile is $XMLfile" 62 | 63 | -------------------------------------------------------------------------------- /Scripts/IMF-GenerateReport.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | ImageFactory 3.3 4 | .DESCRIPTION 5 | ImageFactory 3.3 6 | .EXAMPLE 7 | ImageFactoryV3-Verify-ShowContent.ps1 8 | .NOTES 9 | Created: 2016-11-24 10 | Version: 3.1 11 | 12 | Updated: 2017-02-23 13 | Version: 3.2 14 | 15 | Updated: 2017-09-27 16 | Version: 3.3 17 | 18 | Author - Mikael Nystrom 19 | Twitter: @mikael_nystrom 20 | Blog : http://deploymentbunny.com 21 | 22 | Disclaimer: 23 | This script is provided 'AS IS' with no warranties, confers no rights and 24 | is not supported by the author. 25 | 26 | This script uses the PsIni module: 27 | Blog : http://oliver.lipkau.net/blog/ 28 | Source : https://github.com/lipkau/PsIni 29 | http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 30 | 31 | .LINK 32 | http://www.deploymentbunny.com 33 | #> 34 | 35 | [cmdletbinding(SupportsShouldProcess=$True)] 36 | Param( 37 | ) 38 | 39 | #Inititial Settings 40 | $CurrentPath = Split-Path -parent $MyInvocation.MyCommand.Path 41 | $RootPath = Split-Path -parent $CurrentPath 42 | $Global:ScriptLogFilePath = "$RootPath\IMF.log" 43 | $XMLFile = "$RootPath\IMF.xml" 44 | $Global:writetoscreen = $true 45 | 46 | #Inititial Settings 47 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 48 | Write-Log -Message "Logfile is $ScriptLogFilePath" 49 | Write-Log -Message "XMLfile is $XMLfile" 50 | 51 | #Importing modules 52 | Import-Module IMFFunctions -ErrorAction Stop -WarningAction Stop -Force 53 | Write-Log -Message "Module IMFFunctions imported" 54 | 55 | #Read Settings from XML 56 | Write-Log -Message "Reading from $XMLFile" 57 | [xml]$Settings = Get-Content $XMLFile -ErrorAction Stop -WarningAction Stop 58 | 59 | #Verify Connection to DeploymentRoot 60 | Write-Log -Message "Verify Connection to DeploymentRoot" 61 | $Result = Test-Path -Path $Settings.Settings.MDT.DeploymentShare 62 | If($Result -ne $true){ 63 | Write-Log -Message "Cannot access $($Settings.Settings.MDT.DeploymentShare) , will break" -LogLevel 3 64 | Return "Cannot access $($Settings.Settings.MDT.DeploymentShare) , will break" 65 | Exit 66 | } 67 | 68 | $reportfolders = Get-ChildItem -Path "$($Settings.Settings.MDT.DeploymentShare)\Reports" -Filter *. 69 | foreach($reportfolder in $reportfolders){ 70 | # Set the basic's 71 | $htmlreport = @() 72 | $htmlbody = @() 73 | $spacer = "
" 74 | 75 | 76 | #OS Info 77 | Write-Log -Message "Begin generating OS Info" 78 | Try { 79 | $subhead = "

Operating System Information

" 80 | $htmlbody += $subhead 81 | 82 | $Comment = "

Data from the Win32_OperatingSystem WMI class

" 83 | $htmlbody += $Comment 84 | 85 | $Win32_OperatingSystem = Import-Csv -Path "$($reportfolder.FullName)\Win32_OperatingSystem.csv" | 86 | Select-Object Caption,BuildNumber,CountryCode,OSLanguage,Locale, 87 | @{Name='CurrentTimeZone';Expression={Convert-TSxMinutesToHours -minutes $($_.CurrentTimeZone)}}, 88 | @{Name='InstallDate';Expression={Convert-TSxWMITimeToStandardDate -WMITime $($_.InstallDate)}} 89 | 90 | $htmlbody += $Win32_OperatingSystem | ConvertTo-Html -Fragment 91 | $htmlbody += $spacer 92 | } 93 | Catch { 94 | Write-Log -Message $_.Exception.Message -LogLevel 2 95 | $htmlbody += "

An error was encountered. $($_.Exception.Message)

" 96 | $htmlbody += $spacer 97 | } 98 | Write-Log -Message "Done generating OS Info" 99 | 100 | #TaskSequence 101 | Write-Log -Message "Begin generating TaskSequence Info" 102 | Try { 103 | $subhead = "

Task Sequence information

" 104 | $htmlbody += $subhead 105 | 106 | $Comment = "

Data from the Microsoft_BDD_Info WMI Class

" 107 | $htmlbody += $Comment 108 | 109 | $Microsoft_BDD_Info = Import-Csv -Path "$($reportfolder.FullName)\Microsoft_BDD_Info.csv" | 110 | Select-Object CaptureTaskSequenceID,CaptureTaskSequenceName,CaptureTaskSequenceVersion, 111 | @{Name='CaptureTimestamp';Expression={Convert-TSxWMITimeToStandardDate -WMITime $($_.CaptureTimestamp)}}, 112 | @{Name='DeploymentTimestamp';Expression={Convert-TSxWMITimeToStandardDate -WMITime $($_.DeploymentTimestamp)}} 113 | 114 | $htmlbody += $Microsoft_BDD_Info | ConvertTo-Html -Fragment 115 | $htmlbody += $spacer 116 | } 117 | Catch { 118 | Write-Log -Message $_.Exception.Message -LogLevel 2 119 | $htmlbody += "

An error was encountered. $($_.Exception.Message)

" 120 | $htmlbody += $spacer 121 | } 122 | Write-Log -Message "Done generating TaskSequence Info" 123 | 124 | #Roles and Features 125 | Write-Log -Message "Begin generating Roles and Features Info" 126 | Try { 127 | $subhead = "

Windows Roles and Festures

" 128 | $htmlbody += $subhead 129 | 130 | $Comment = "

Data from the WindowsOptionalFeature cmdlet

" 131 | $htmlbody += $Comment 132 | 133 | $WindowsOptionalFeature = Import-Csv -Path "$($reportfolder.FullName)\WindowsOptionalFeature.csv" | Where-Object State -EQ Enabled | Select-Object FeatureName,State | Sort-Object FeatureName 134 | 135 | $htmlbody += $WindowsOptionalFeature | ConvertTo-Html -Fragment 136 | $htmlbody += $spacer 137 | } 138 | Catch { 139 | Write-Log -Message $_.Exception.Message -LogLevel 2 140 | $htmlbody += "

An error was encountered. $($_.Exception.Message)

" 141 | $htmlbody += $spacer 142 | } 143 | Write-Log -Message "Done generating Roles and Features Info" 144 | 145 | #Hotfixes 146 | Write-Log -Message "Begin generating Hotfixes Info" 147 | Try { 148 | $subhead = "

Patches and Hotfix infrmation

" 149 | $htmlbody += $subhead 150 | 151 | $Comment = "

Data from Win32_QuickFixEngineering cmdlet

" 152 | $htmlbody += $Comment 153 | 154 | $Win32_QuickFixEngineering = Import-Csv -Path "$($reportfolder.FullName)\Win32_QuickFixEngineering.csv" 155 | 156 | if((Test-NetConnection -WarningAction SilentlyContinue).PingSucceeded -eq $true){ 157 | $InternetAccess = $True 158 | }else{ 159 | $InternetAccess = $false 160 | } 161 | 162 | $KBs = foreach($Item in $Win32_QuickFixEngineering){ 163 | $Hash = [ordered]@{ 164 | HotfixID = $($Item.HotFixID); 165 | Description = $($Item.Description); 166 | URL = $($Item.Caption); 167 | 168 | } 169 | New-Object PSObject -Property $Hash 170 | } 171 | 172 | $htmlbody += $KBs | ConvertTo-Html -Fragment 173 | $htmlbody += $spacer 174 | } 175 | Catch { 176 | Write-Log -Message $($_.Exception.Message) 177 | $htmlbody += "

An error was encountered. $($_.Exception.Message)

" 178 | $htmlbody += $spacer 179 | } 180 | Write-Log -Message "Done generating Hotfixes Info" 181 | 182 | #Legacy Apps 183 | Write-Log -Message "Begin generating Legacy Apps Info" 184 | Try { 185 | $subhead = "

Installed legacy applications

" 186 | $htmlbody += $subhead 187 | 188 | $Comment = "

Data from UnInstallKey and UninstallKeyWow6432Node

" 189 | $htmlbody += $Comment 190 | 191 | $UnInstallKey = Import-Csv -Path "$($reportfolder.FullName)\UninstallKey.csv" -ErrorAction SilentlyContinue 192 | $UninstallKeyWow6432Node = Import-Csv -Path "$($reportfolder.FullName)\UninstallKeyWow6432Node.csv" -ErrorAction SilentlyContinue 193 | if($UnInstallKeys -eq $null){ 194 | }else{ 195 | $UnInstallKeys = $UnInstallKey + $UninstallKeyWow6432Node 196 | $Apps = foreach($Item in $UnInstallKeys){ 197 | $Hash = [ordered]@{ 198 | DisplayName = $($Item.DisplayName); 199 | Publisher = $($Item.Publisher); 200 | DisplayVersion = $($Item.DisplayVersion); 201 | UninstallKey = $($Item.PSChildName); 202 | Architechture = $( 203 | If($Item.PSPath -like "*Wow*"){"x86"}else{"x64"} 204 | ) 205 | } 206 | 207 | New-Object PSObject -Property $Hash 208 | } 209 | } 210 | 211 | $htmlbody += $Apps | Sort-Object DisplayName | ConvertTo-Html -Fragment 212 | $htmlbody += $spacer 213 | } 214 | Catch { 215 | Write-Log -Message $_.Exception.Message -LogLevel 2 216 | $htmlbody += "

An error was encountered. $($_.Exception.Message)

" 217 | $htmlbody += $spacer 218 | } 219 | Write-Log -Message "Done generating Legacy Apps Info" 220 | 221 | #Modern Applications 222 | Write-Log -Message "Begin generating Modern Applications Info" 223 | Try { 224 | $subhead = "

Modern Applications

" 225 | $htmlbody += $subhead 226 | 227 | $Comment = "

Data from the AppxPackage cmdlet

" 228 | $htmlbody += $Comment 229 | 230 | $AppxPackage = Import-Csv -Path "$($reportfolder.FullName)\AppxPackage.csv" | Select-Object Name,Version | Sort-Object Name 231 | 232 | $htmlbody += $AppxPackage | ConvertTo-Html -Fragment 233 | $htmlbody += $spacer 234 | } 235 | Catch { 236 | Write-Log -Message $_.Exception.Message -LogLevel 2 237 | $htmlbody += "

An error was encountered. $($_.Exception.Message)

" 238 | $htmlbody += $spacer 239 | } 240 | Write-Log -Message "Done generating Modern Applications Info" 241 | 242 | #------------------------------------------------------------------------------ 243 | # Generate the HTML report and output to file 244 | Write-Log -Message "Begin generating Report" 245 | 246 | $reportime = Get-Date 247 | 248 | #Common HTML head and styles 249 | $htmlhead=" 250 | 264 | 265 |

Report - $($reportfolder.Name)

266 |

Generated: $reportime

" 267 | $htmltail = " 268 | " 269 | 270 | $htmlreport = $htmlhead + $htmlbody + $htmltail 271 | 272 | $htmlfile = "$ReportPath" + "\Report_ActiveDirectory.html" 273 | $HTMLReport | Out-File -FilePath "$($reportfolder.FullName).html" -Encoding utf8 -Force 274 | Write-Log -Message "Done generating Report" 275 | 276 | } 277 | Write-Log -Message "Done" -------------------------------------------------------------------------------- /Scripts/IMF-ImportISO.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | ImageFactory 3.2 4 | .DESCRIPTION 5 | ImageFactory 3.2 6 | .EXAMPLE 7 | ImageFactoryV3-Build.ps1 8 | .NOTES 9 | Created: 2016-11-24 10 | Version: 3.1 11 | 12 | Updated: 2017-02-23 13 | Version: 3.2 14 | 15 | 16 | Author - Mikael Nystrom 17 | Twitter: @mikael_nystrom 18 | Blog : http://deploymentbunny.com 19 | 20 | Disclaimer: 21 | This script is provided 'AS IS' with no warranties, confers no rights and 22 | is not supported by the author. 23 | 24 | This script uses the PsIni module: 25 | Blog : http://oliver.lipkau.net/blog/ 26 | Source : https://github.com/lipkau/PsIni 27 | http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 28 | 29 | .LINK 30 | http://www.deploymentbunny.com 31 | #> 32 | 33 | 34 | [cmdletbinding(SupportsShouldProcess=$True)] 35 | Param( 36 | $ISOImage, 37 | $OSFolder, 38 | $OrgName 39 | ) 40 | 41 | #Inititial Settings 42 | $CurrentPath = split-path -parent $MyInvocation.MyCommand.Path 43 | $RootPath = split-path -parent $CurrentPath 44 | #$RootPath = "D:\IMFv3" 45 | $Global:ScriptLogFilePath = "$RootPath\IMF.log" 46 | $XMLFile = "$RootPath\IMF.xml" 47 | $Global:writetoscreen = $true 48 | 49 | #Importing modules 50 | Import-Module IMFFunctions -ErrorAction Stop -WarningAction Stop -Force 51 | Write-Log -Message "Module IMFFunctions imported" 52 | Import-Module 'C:\Program Files\Microsoft Deployment Toolkit\Bin\MicrosoftDeploymentToolkit.psd1' -ErrorAction Stop -WarningAction Stop 53 | Write-Log -Message "ModuleMicrosoftDeploymentToolkit imported" 54 | 55 | #Read Settings from XML 56 | Write-Log -Message "Reading from $XMLFile" 57 | [xml]$Settings = Get-Content $XMLFile -ErrorAction Stop -WarningAction Stop 58 | 59 | #Verify path to ISO 60 | Write-Log -Message "Verify path to $ISOImage" 61 | $Result = Test-Path -Path $ISOImage 62 | If($Result -ne $true){ 63 | Write-Log -Message "Cannot access $ISOImage , will break" -LogLevel 3 64 | Return "Fail" 65 | break 66 | } 67 | 68 | #Verify Connection to DeploymentRoot 69 | Write-Log -Message "Verify Connection to DeploymentRoot" 70 | $Result = Test-Path -Path $Settings.Settings.MDT.DeploymentShare 71 | If($Result -ne $true){ 72 | Write-Log -Message "Cannot access $($Settings.Settings.MDT.DeploymentShare) , will break" -LogLevel 3 73 | Return "Fail" 74 | Exit 75 | } 76 | 77 | #Connect to MDT 78 | Write-Log -Message "Connect to MDT" 79 | $Root = $Settings.Settings.MDT.DeploymentShare 80 | if((Test-Path -Path MDT:) -eq $false){ 81 | $MDTPSDrive = New-PSDrive -Name MDT -PSProvider MDTProvider -Root $Root -ErrorAction Stop 82 | Write-Log -Message "Connected to $($MDTPSDrive.Root)" 83 | } 84 | 85 | #Check if folder already exists 86 | Write-Log -Message "Checking if $OSFolder already exists" 87 | $Result = Test-Path -Path "$($MDTPSDrive.Root)\Operating Systems\$OSFolder" 88 | If($Result -eq $true){ 89 | Write-Log -Message "$OSFolder already exists , will break" -LogLevel 3 90 | Return "Fail" 91 | Exit 92 | } 93 | 94 | #Import ISO 95 | Write-Log -Message "Working on $ISOImage" 96 | 97 | $DiskImage = Mount-DiskImage -ImagePath $ISOImage -PassThru -ErrorAction Stop 98 | Write-Log -Message "Succesfully mounted $($DiskImage.imagepath)" 99 | 100 | $Result = Import-MDTOperatingSystem -Path "MDT:\Operating Systems\Msft" -SourcePath "$(($DiskImage | Get-Volume).DriveLetter):\" -DestinationFolder $OSFolder 101 | Write-Log -Message "Succesfully imported $($item.name) in $($item.source)" 102 | 103 | $Return = Dismount-DiskImage -ImagePath $DiskImage.ImagePath 104 | Write-Log -Message "Succesfully dismounted $($Return.Imagepath)" 105 | 106 | $Return = New-Item -Path "MDT:\Packages" -enable "True" -Name $OSFolder -Comments "" -ItemType "folder" 107 | Write-Log -Message "Succesfully created $($Return.name) in $($Return.NodeType)" 108 | 109 | $Return = New-Item -path "MDT:\Selection Profiles" -enable "True" -Name $OSFolder -Comments "" -Definition "" -ReadOnly "False" 110 | Write-Log -Message "Succesfully created $($Return.name) in $($Return.NodeType)" 111 | 112 | 113 | foreach($item in $Result){ 114 | if($item.Description -like "*Windows Server*"){ 115 | $Template = "Server.xml" 116 | } 117 | else{ 118 | $Template = "Client.xml" 119 | } 120 | 121 | $item | select * 122 | $Name = "Ref $($item.ImageName) for $($OSFolder)" 123 | $ID = "$OSFolder-$($item.ImageIndex)" 124 | $OperatingSystemPath = "MDT:\Operating Systems\Msft\$($item.name)" 125 | Import-MDTTaskSequence -path "MDT:\Task Sequences\Reference" -Name $Name -Template $Template -Comments "" -ID $ID -Version "1.0" -OperatingSystemPath $OperatingSystemPath -FullName $item.OrgName -OrgName $item.OrgName -HomePage "about:blank" 126 | Import-MDTApplication -path "MDT:\Applications\Bundles" -enable "True" -Name "Install - Bundle used by $Name" -ShortName "Install - Bundle used by $Name" -Version "" -Publisher "" -Language "" -Bundle 127 | } 128 | 129 | 130 | $TSFolders = Get-ChildItem "$($Settings.Settings.MDT.DeploymentShare)\Control" -Filter *. 131 | foreach($TSFolder in $TSFolders){ 132 | $TSXML = [xml](Get-Content -Path "$($TSFolder.FullName)\ts.xml") 133 | $StateRestore = $TSXML.sequence.group | Where-Object Name -EQ 'State Restore' 134 | ($StateRestore.step | Where-Object Name -EQ 'Windows Update (Post-Application Installation)').disable = 'false' 135 | ($StateRestore.step | Where-Object Name -EQ 'Windows Update (Pre-Application Installation)').disable = 'false' 136 | $TSXML.Save("$($TSFolder.FullName)\ts.xml") 137 | } 138 | 139 | $TSFolders = Get-ChildItem "$($Settings.Settings.MDT.DeploymentShare)\Control" -Filter *. 140 | foreach($TSFolder in $TSFolders){ 141 | $TSXML = [xml](Get-Content -Path "$($TSFolder.FullName)\ts.xml") 142 | $BaseName = $($TSFolder.Name).Split("-")[0] 143 | $SelectionProfileName = Get-ChildItem -Path "mdt:\Selection Profiles" | Where-Object name -Like $BaseName* 144 | $PreInstall = $TSXML.sequence.group | Where-Object Name -EQ 'PreInstall' 145 | (($PreInstall.step| Where-Object Name -EQ 'Apply Patches').defaultVarList.variable | Where-Object name -EQ PackageSelectionProfile | Where-Object Property -EQ PackageSelectionProfile).'#text' = $SelectionProfileName.Name 146 | $TSXML.Save("$($TSFolder.FullName)\ts.xml") 147 | } 148 | Return "OK" 149 | -------------------------------------------------------------------------------- /Scripts/IMF-Install.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | ImageFactory 3.2 4 | .DESCRIPTION 5 | ImageFactory 3.2 6 | .EXAMPLE 7 | ImageFactoryV3-Build.ps1 8 | .NOTES 9 | Created: 2016-11-24 10 | Version: 3.1 11 | 12 | Updated: 2017-02-23 13 | Version: 3.2 14 | 15 | 16 | Author - Mikael Nystrom 17 | Twitter: @mikael_nystrom 18 | Blog : http://deploymentbunny.com 19 | 20 | Disclaimer: 21 | This script is provided 'AS IS' with no warranties, confers no rights and 22 | is not supported by the author. 23 | 24 | This script uses the PsIni module: 25 | Blog : http://oliver.lipkau.net/blog/ 26 | Source : https://github.com/lipkau/PsIni 27 | http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 28 | 29 | .LINK 30 | http://www.deploymentbunny.com 31 | #> 32 | 33 | [cmdletbinding(SupportsShouldProcess=$True)] 34 | Param( 35 | ) 36 | 37 | #Requires -RunAsAdministrator 38 | 39 | #Inititial Settings 40 | $CurrentPath = split-path -parent $MyInvocation.MyCommand.Path 41 | $RootPath = split-path -parent $CurrentPath 42 | #$RootPath = "D:\IMFv3" 43 | $Global:ScriptLogFilePath = "$RootPath\IMF.log" 44 | $XMLFile = "$RootPath\IMF.xml" 45 | $Global:writetoscreen = $true 46 | 47 | #Install IMFFuctions 48 | Import-Module IMFFunctions -ErrorAction Stop -WarningAction Stop -Force 49 | Write-Log -Message "Module IMFFunctions imported" 50 | 51 | #Install PSINI 52 | Import-Module PsIni -ErrorAction Stop -WarningAction Stop -MinimumVersion 2.0.5 53 | Write-Log -Message "Module PsIni imported" 54 | 55 | #Importing ModuleMicrosoftDeploymentToolkit 56 | Import-Module 'C:\Program Files\Microsoft Deployment Toolkit\Bin\MicrosoftDeploymentToolkit.psd1' -ErrorAction Stop -WarningAction Stop 57 | Write-Log -Message "Module Microsoft Deployment Toolkit imported" 58 | 59 | #Inititial Settings 60 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 61 | Write-Log -Message "Logfile is $ScriptLogFilePath" 62 | Write-Log -Message "XMLfile is $XMLfile" 63 | 64 | #Read Settings from XML 65 | Write-Log -Message "Reading from $XMLFile" 66 | [xml]$Settings = Get-Content $XMLFile -ErrorAction Stop -WarningAction Stop 67 | 68 | #Check for deployshare 69 | if((Test-Path -Path $Settings.Settings.MDT.DeploymentShare) -eq $True){ 70 | Write-Log -Message "$($Settings.Settings.MDT.DeploymentShare) already exists, will abort" -LogLevel 2 71 | Return "Fail" 72 | Break 73 | } 74 | 75 | #Test 76 | Write-Log -Message "Verifying access to objects" 77 | if((Test-VIAHypervConnection -Computername $Settings.Settings.HyperV.Computername -ISOFolder $Settings.Settings.HyperV.ISOLocation -VMFolder $Settings.Settings.HyperV.VMLocation -VMSwitchName $Settings.Settings.HyperV.SwitchName) -ne $true){ 78 | Write-Log -Message "could not access hyper-v host, hyper-v iso folder, hyper-v vm folder or hyper-v switch" -LogLevel 3 79 | Return "Fail" 80 | Break 81 | } 82 | 83 | $path = ($settings.Settings.MDT.DeploymentShare | Split-Path) 84 | if((Test-Path $path) -ne $true){ 85 | Write-Log -Message "could not access rootfolder for deploymentshare, make sure you have access to $path" -LogLevel 2 86 | Return "Fail" 87 | Break 88 | } 89 | 90 | $DeploymentShare = $($Settings.Settings.MDT.DeploymentShare) 91 | $DeploymentShareName = $($DeploymentShare | Split-Path -Leaf) + "$" 92 | 93 | $Return = New-Item -Path $DeploymentShare -ItemType Directory 94 | Write-Log "Folder $($Return.FullName) was created" 95 | 96 | $Return = New-SmbShare -Name $DeploymentShareName -Path $DeploymentShare -FullAccess Everyone 97 | Write-Log "$($Return.Path) was shared as $($Return.Name)" 98 | 99 | $Return = New-PSDrive -Name MDT -PSProvider "MDTProvider" -Root $DeploymentShare -Description "MDT Build LAB" -NetworkPath "\\$env:COMPUTERNAME\$DeploymentShareName" | Add-MDTPersistentDrive 100 | Write-Log "Successfully created a $($Return.Provider.Name) named $($Return.Name) in $($Return.Root)" 101 | 102 | $Return = New-Item -Path "MDT:\Operating Systems" -enable "True" -Name "Msft" -ItemType "folder" 103 | Write-Log "Created folder $($Return.name) in $($Return.NodeType)" 104 | 105 | $Return = New-Item -Path "MDT:\Operating Systems" -enable "True" -Name $($Settings.Settings.MDT.ValidateOSImageFolderName) -ItemType "folder" 106 | Write-Log "Created folder $($Return.name) in $($Return.NodeType)" 107 | 108 | $Return = New-Item -Path "MDT:\Operating Systems" -enable "True" -Name "Retired" -ItemType "folder" 109 | Write-Log "Created folder $($Return.name) in $($Return.NodeType)" 110 | 111 | $Return = New-Item -Path "MDT:\Applications" -enable "True" -Name "Active" -ItemType "folder" 112 | Write-Log "Created folder $($Return.name) in $($Return.NodeType)" 113 | 114 | $Return = New-Item -Path "MDT:\Applications" -enable "True" -Name "Bundles" -ItemType "folder" 115 | Write-Log "Created folder $($Return.name) in $($Return.NodeType)" 116 | 117 | $Return = New-Item -Path "MDT:\Task Sequences" -enable "True" -Name $($Settings.Settings.MDT.RefTaskSequenceFolderName) -ItemType "folder" 118 | Write-Log "Created folder $($Return.name) in $($Return.NodeType)" 119 | 120 | $Return = New-Item -Path "MDT:\Task Sequences" -enable "True" -Name $($Settings.Settings.MDT.ValidateTaskSequenceFolderName) -ItemType "folder" 121 | Write-Log "Created folder $($Return.name) in $($Return.NodeType)" 122 | 123 | $Return = New-Item -Path "MDT:\Task Sequences" -enable "True" -Name "Retired" -ItemType "folder" 124 | Write-Log "Created folder $($Return.name) in $($Return.NodeType)" 125 | 126 | #Configure customsettings.ini 127 | $IniFile = "$($Settings.settings.MDT.DeploymentShare)\Control\CustomSettings.ini" 128 | Write-Log "Infile is $IniFile" 129 | 130 | Write-Log "Reading $IniFile" 131 | $CustomSettings = Get-IniContent -FilePath $IniFile -CommentChar ";" 132 | 133 | Write-Log "Update customsettings.ini" 134 | Write-Log "Adding SerialNumber,Default to Priority" 135 | $CustomSettings.Settings.Priority = 'SerialNumber,Default' 136 | 137 | Write-Log "Adding WSUS,ReportFolder,Suspendas custom properties" 138 | $CustomSettings.Settings.Properties = 'WSUS,ReportFolder,Suspend' 139 | 140 | Write-Log "updating $IniFile" 141 | Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CustomSettings 142 | 143 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"_SMSTSORGNAME"="%TaskSequenceName%"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 144 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"UserDataLocation"="NONE"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 145 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"OSInstall"="Y"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 146 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"AdminPassword"="P@ssw0rd"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 147 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"TimeZoneName"="Pacific Standard Time"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 148 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"JoinWorkgroup"="WORKGROUP"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 149 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"ApplyGPOPack"="NO"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 150 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"SLShare"="%DeployRoot%\Logs"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 151 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"ReportFolder"="%DeployRoot%\Reports"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 152 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"HideShell"="YES"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 153 | 154 | Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 155 | Write-Log "$IniFile is updated" 156 | 157 | If((Get-LocalUser | Where-Object Name -EQ $Settings.settings.Security.BuildAccount.Name).count -eq "1"){ 158 | Write-Log -Message "MDTBA Account already exists" -LogLevel 2 159 | }else{ 160 | New-LocalUser -AccountNeverExpires -Description $Settings.settings.Security.BuildAccount.Name -Name $Settings.settings.Security.BuildAccount.Name -UserMayNotChangePassword -PasswordNeverExpires -Password ($Settings.settings.Security.BuildAccount.Password | ConvertTo-SecureString -AsPlainText -Force) 161 | } 162 | 163 | Write-Log -Message "Creating folders" 164 | $FolderNames = "Logs","Reports" 165 | foreach($Item in $FolderNames){ 166 | 167 | $FolderName = "$($Settings.settings.MDT.DeploymentShare)\$Item" 168 | $return = New-Item -Path $FolderName -ItemType Directory -Force 169 | Write-Log -Message "$($return.FullName) was created" 170 | 171 | Write-Log -Message "Setting permissions on $($return.FullName)" 172 | $Acl = Get-Acl $FolderName 173 | $Ar = New-Object system.security.accesscontrol.filesystemaccessrule("$($Settings.settings.Security.BuildAccount.Name)","Modify","Allow") 174 | $Acl.SetAccessRule($Ar) 175 | Set-Acl $FolderName $Acl 176 | 177 | $Acl = Get-Acl $FolderName 178 | $acl.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule("$($Settings.settings.Security.BuildAccount.Name)","Modify", "ContainerInherit, ObjectInherit", "InheritOnly", "Allow"))) 179 | Set-Acl $FolderName $Acl 180 | } 181 | 182 | #Configure bootstrap.ini 183 | $IniFile = "$($Settings.settings.MDT.DeploymentShare)\Control\Bootstrap.ini" 184 | $Bootstrap = Get-IniContent -FilePath $IniFile -CommentChar ";" 185 | Write-Log -Message "Modifying $IniFile" 186 | 187 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"UserDomain"="$env:COMPUTERNAME"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 188 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"UserID"="$($Settings.settings.Security.BuildAccount.Name)"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 189 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"UserPassword"="$($Settings.settings.Security.BuildAccount.Password)"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 190 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"SkipBDDWelcome"="YES"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 191 | 192 | if((Get-IniContent -FilePath $IniFile)["Default"]["DeployRoot"] -ne "\\$env:COMPUTERNAME\$DeploymentShareName"){ 193 | Write-Log -Message "Adding deployroot path, since it was missing..." 194 | $CSIniUpdate = Set-IniContent -FilePath $IniFile -Sections "Default" -NameValuePairs @{"Deployroot"="\\$env:COMPUTERNAME\$DeploymentShareName"};Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 195 | } 196 | 197 | Out-IniFile -FilePath $IniFile -Force -Encoding ASCII -InputObject $CSIniUpdate 198 | Write-Log -Message "Saved $IniFile" 199 | 200 | $AppName = "Configure - Enable Remote Desktop (Windows Server)" 201 | $Return = Import-MDTApplication -Path "MDT:\Applications\Active" -enable "True" -Name $Appname -ShortName $Appname -Version "" -Publisher "" -Language "" -CommandLine 'cscript.exe c:\windows\system32\scregedit.wsf /AR 0' -WorkingDirectory "" -NoSource 202 | Write-Log -Message "Added $($Return.Name)" 203 | 204 | $AppName = "Configure - Enable Previous Client Connection to Remote Desktop (Windows Server)" 205 | $Return = Import-MDTApplication -Path "MDT:\Applications\Active" -enable "True" -Name $Appname -ShortName $Appname -Version "" -Publisher "" -Language "" -CommandLine 'cscript.exe c:\windows\system32\scregedit.wsf /CS 0' -WorkingDirectory "" -NoSource 206 | Write-Log -Message "Added $($Return.Name)" 207 | 208 | $AppName = "Configure - Enable Firewall for Remote Desktop (Windows Server)" 209 | $Return = Import-MDTApplication -Path "MDT:\Applications\Active" -enable "True" -Name $Appname -ShortName $appname -Version "" -Publisher "" -Language "" -CommandLine 'PowerShell.exe -Command """Get-NetFirewallRule -Group "@FirewallAPI.dll,-28752" | Enable-NetFirewallRule"""' -WorkingDirectory "" -NoSource 210 | Write-Log -Message "Added $($Return.Name)" 211 | 212 | $AppName = "Install - Microsoft Visual C++" 213 | $Return = Import-MDTApplication -Path "MDT:\Applications\Active" -enable "True" -Name $Appname -ShortName $appname -Version "" -Publisher "" -Language "" -CommandLine "cscript.exe Install-MicrosoftVisualC++x86x64.wsf" -WorkingDirectory ".\Applications\Install - Microsoft Visual C++" -ApplicationSourcePath "$RootPath\MDTApps\Install - Microsoft Visual C++" -DestinationFolder "Install - Microsoft Visual C++" 214 | Write-Log -Message "Added $($Return.Name)" 215 | 216 | $AppName = "Configure - Disable Services in Windows Server 2016 Desktop Edition" 217 | $Return = Import-MDTApplication -Path "MDT:\Applications\Active" -enable "True" -Name $Appname -ShortName $Appname -Version "" -Publisher "" -Language "" -CommandLine "PowerShell.exe -ExecutionPolicy Bypass -File Configure-DisableServicesforWindowsServer.ps1" -WorkingDirectory ".\Applications\Configure - Disable Services in Windows Server 2016 Desktop Edition" -ApplicationSourcePath "$RootPath\MDTApps\Configure - Disable Services in Windows Server 2016 Desktop Edition" -DestinationFolder "Configure - Disable Services in Windows Server 2016 Desktop Edition" 218 | Write-Log -Message "Added $($Return.Name)" 219 | 220 | $AppName = $($Settings.Settings.MDT.ReportApplicationName) 221 | $Return = Import-MDTApplication -Path "MDT:\Applications\Active" -enable "True" -Name $AppName -ShortName $AppName -CommandLine "PowerShell.exe -ExecutionPolicy Bypass -File Generate-OSReport.ps1" -WorkingDirectory ".\Applications\$($Settings.Settings.MDT.ReportApplicationName)" -ApplicationSourcePath "$RootPath\MDTApps\Action - Generate OSReport" -DestinationFolder $($Settings.Settings.MDT.ReportApplicationName) 222 | Write-Log -Message "Added $($Return.Name)" 223 | 224 | $AppName = "Install - Microsoft BGInfo - x86-x64" 225 | $Return = Import-MDTApplication -Path "MDT:\Applications\Active" -enable "True" -Name $AppName -ShortName $AppName -CommandLine "cscript.exe Install-MicrosoftBGInfox86x64.wsf" -WorkingDirectory ".\Applications\Install - Microsoft BGInfo - x86-x64" -ApplicationSourcePath "$RootPath\MDTApps\Install - Microsoft BGInfo - x86-x64" -DestinationFolder "Install - Microsoft BGInfo - x86-x64" 226 | Write-Log -Message "Added $($Return.Name)" 227 | 228 | $AppName = "Install - Roles and Features" 229 | $Return = Import-MDTApplication -Path "MDT:\Applications\Active" -enable "True" -Name $AppName -ShortName $AppName -Version "" -Publisher "" -Language "" -CommandLine "PowerShell.exe -ExecutionPolicy ByPass -File InstallRolesAndFeatures.ps1" -WorkingDirectory ".\Applications\Install - Roles and Features" -ApplicationSourcePath "$RootPath\MDTApps\Install - Roles and Features" -DestinationFolder "Install - Roles and Features" 230 | Write-Log -Message "Added $($Return.Name)" 231 | 232 | Return "OK" -------------------------------------------------------------------------------- /Scripts/IMF-Publish.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | ImageFactory 3.2 4 | .DESCRIPTION 5 | ImageFactory 3.2 6 | .EXAMPLE 7 | ImageFactoryV3-Build.ps1 8 | .NOTES 9 | Created: 2016-11-24 10 | Version: 3.1 11 | 12 | Updated: 2017-02-23 13 | Version: 3.2 14 | 15 | 16 | Author - Mikael Nystrom 17 | Twitter: @mikael_nystrom 18 | Blog : http://deploymentbunny.com 19 | 20 | Disclaimer: 21 | This script is provided 'AS IS' with no warranties, confers no rights and 22 | is not supported by the author. 23 | 24 | This script uses the PsIni module: 25 | Blog : http://oliver.lipkau.net/blog/ 26 | Source : https://github.com/lipkau/PsIni 27 | http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 28 | 29 | .LINK 30 | http://www.deploymentbunny.com 31 | #> 32 | [cmdletbinding(SupportsShouldProcess=$True)] 33 | Param( 34 | [switch]$VHDBIOS, 35 | [switch]$VHDUEFI 36 | ) 37 | 38 | #Inititial Settings 39 | $CurrentPath = split-path -parent $MyInvocation.MyCommand.Path 40 | $RootPath = split-path -parent $CurrentPath 41 | $Global:ScriptLogFilePath = "$RootPath\IMF.log" 42 | $XMLFile = "$RootPath\IMF.xml" 43 | $Global:writetoscreen = $true 44 | 45 | #Read Settings from XML 46 | Write-Log -Message "Reading from $XMLFile" 47 | [xml]$Settings = Get-Content $XMLFile -ErrorAction Stop -WarningAction Stop 48 | 49 | Write-Log -Message "Import Module" 50 | Import-Module 'C:\Program Files\Microsoft Deployment Toolkit\Bin\MicrosoftDeploymentToolkit.psd1' -ErrorAction Stop -WarningAction Stop 51 | 52 | $Root = $Settings.Settings.MDT.DeploymentShare 53 | if((Test-Path -Path MDT:) -eq $false){ 54 | $MDTPSDrive = New-PSDrive -Name MDT -PSProvider MDTProvider -Root $Root -ErrorAction Stop 55 | Write-Log -Message "Connected to $($MDTPSDrive.Root)" 56 | } 57 | 58 | #Verify Connection to DeploymentRoot 59 | Write-Log -Message "Verify Connection to DeploymentRoot" 60 | $Result = Test-Path -Path $Settings.Settings.MDT.DeploymentShare 61 | If($Result -ne $true){ 62 | Write-Log -Message "Cannot access $($Settings.Settings.MDT.DeploymentShare) , will break" 63 | break 64 | } 65 | 66 | # Make Sure destination exists 67 | Write-Log -Message "Creating $($Settings.Settings.PublishingFolder)" 68 | New-Item -Path "$($Settings.Settings.PublishingFolder)" -Force -ItemType Directory 69 | 70 | # Get all capture images 71 | Write-Log -Message "Enumarating .WIM files in $($Settings.Settings.MDT.DeploymentShare)\Captures" 72 | $Items = Get-ChildItem -Path "$($Settings.Settings.MDT.DeploymentShare)\Captures" -Filter *.wim 73 | 74 | # Match wim with ts 75 | foreach($item in $items){ 76 | Write-Log -Message "Working on $($Item.BaseName)" 77 | $TSInfo = Get-ChildItem -Path "MDT:\Task Sequences\Reference" -Recurse | Where-Object ID -EQ $Item.BaseName 78 | $WIMInfo = Get-WindowsImage -ImagePath $item.FullName -Index 1 79 | 80 | # Copy the WIM file 81 | Write-Log -Message "Copy $($item.FullName) to $($Settings.Settings.PublishingFolder)" 82 | Copy-Item -Path $item.FullName -Destination "$($Settings.Settings.PublishingFolder)\$($item.Name)" -Force 83 | 84 | $VHDBIOSFileName = "NA" 85 | $VHDUEFIFileName = "NA" 86 | 87 | if($VHDBIOS){ 88 | Write-Log -Message "Creating $($item.Basename + "_BIOS.vhdx")" 89 | if(Test-Path -Path "$($Settings.Settings.PublishingFolder)\$($item.Basename + "_BIOS.vhdx")"){ 90 | Remove-Item -Path "$($Settings.Settings.PublishingFolder)\$($item.Basename + "_BIOS.vhdx")" -Force 91 | } 92 | 93 | .\Scripts\Convert-VIAWIM2VHD.ps1 -Sourcefile $item.FullName -DestinationFile "$($Settings.Settings.PublishingFolder)\$($item.Basename + "_BIOS.vhdx")" -SizeInMB 100000 -Disklayout BIOS -Index 1 94 | $VHDBIOSFileName = $($item.Basename + "_BIOS.vhdx") 95 | } 96 | 97 | if($VHDUEFI){ 98 | Write-Log -Message "Creating $($item.Basename + "_UEFI.vhdx")" 99 | if(Test-Path -Path "$($Settings.Settings.PublishingFolder)\$($item.Basename + "_UEFI.vhdx")"){ 100 | Remove-Item -Path "$($Settings.Settings.PublishingFolder)\$($item.Basename + "_UEFI.vhdx")" -Force 101 | } 102 | 103 | .\Scripts\Convert-VIAWIM2VHD.ps1 -Sourcefile $item.FullName -DestinationFile "$($Settings.Settings.PublishingFolder)\$($item.Basename + "_UEFI.vhdx")" -SizeInMB 100000 -Disklayout UEFI -Index 1 104 | $VHDUEFIFileName = $($item.Basename + "_UEFI.vhdx") 105 | } 106 | 107 | $CustomData = [pscustomobject]@{ 108 | Name = $item.Name 109 | Location = "/" 110 | FileName = $item.Name 111 | FileCreationTime = $item.Name 112 | FileLength = $item.Length 113 | TSID = $TSInfo.ID 114 | TSName = $TSInfo.Name 115 | TSVersion = $TSInfo.Version 116 | WIMVersion = $WIMInfo.Version 117 | WIMCreatedTime = $WIMInfo.CreatedTime 118 | WIMImageName = $WIMInfo.ImageName 119 | WIMImageSize = $WIMInfo.ImageSize 120 | WIMArchitecture = $WIMInfo.Architecture 121 | WIMEditionID = $WIMInfo.EditionId 122 | WIMProductType = $WIMInfo.ProductType 123 | WIMInstallationType = $WIMInfo.InstallationType 124 | WIMMajorVersion = $WIMInfo.MajorVersion 125 | WIMMinorVersion = $WIMInfo.MinorVersion 126 | WIMBuild = $WIMInfo.Build 127 | WIMSPBuild = $WIMInfo.SPBuild 128 | WIMLanguages = $WIMInfo.Languages 129 | } 130 | 131 | 132 | $FilePath = "$($Settings.Settings.PublishingJsonFolder)" + "\$($item.Name)" + ".json" 133 | Write-Log -Message "Creating $FilePath" 134 | $CustomData | ConvertTo-Json | Out-File -FilePath $FilePath -Force 135 | 136 | if($VHDBIOSFileName -ne "NA"){ 137 | $CustomData = [pscustomobject]@{ 138 | Name = $VHDBIOSFileName 139 | Location = "/" 140 | FileName = $VHDBIOSFileName 141 | FileCreationTime = $item.Name 142 | FileLength = $item.Length 143 | TSID = $TSInfo.ID 144 | TSName = $TSInfo.Name 145 | TSVersion = $TSInfo.Version 146 | WIMVersion = $WIMInfo.Version 147 | WIMCreatedTime = $WIMInfo.CreatedTime 148 | WIMImageName = $WIMInfo.ImageName 149 | WIMImageSize = $WIMInfo.ImageSize 150 | WIMArchitecture = $WIMInfo.Architecture 151 | WIMEditionID = $WIMInfo.EditionId 152 | WIMProductType = $WIMInfo.ProductType 153 | WIMInstallationType = $WIMInfo.InstallationType 154 | WIMMajorVersion = $WIMInfo.MajorVersion 155 | WIMMinorVersion = $WIMInfo.MinorVersion 156 | WIMBuild = $WIMInfo.Build 157 | WIMSPBuild = $WIMInfo.SPBuild 158 | WIMLanguages = $WIMInfo.Languages 159 | } 160 | 161 | $FilePath = "$($Settings.Settings.PublishingJsonFolder)" + "\$($VHDBIOSFileName)" + ".json" 162 | Write-Log -Message "Creating $FilePath" 163 | $CustomData | ConvertTo-Json | Out-File -FilePath $FilePath -Force 164 | } 165 | 166 | if($VHDUEFIFileName -ne "NA"){ 167 | $CustomData = [pscustomobject]@{ 168 | Name = $VHDUEFIFileName 169 | Location = "/" 170 | FileName = $VHDUEFIFileName 171 | FileCreationTime = $item.Name 172 | FileLength = $item.Length 173 | TSID = $TSInfo.ID 174 | TSName = $TSInfo.Name 175 | TSVersion = $TSInfo.Version 176 | WIMVersion = $WIMInfo.Version 177 | WIMCreatedTime = $WIMInfo.CreatedTime 178 | WIMImageName = $WIMInfo.ImageName 179 | WIMImageSize = $WIMInfo.ImageSize 180 | WIMArchitecture = $WIMInfo.Architecture 181 | WIMEditionID = $WIMInfo.EditionId 182 | WIMProductType = $WIMInfo.ProductType 183 | WIMInstallationType = $WIMInfo.InstallationType 184 | WIMMajorVersion = $WIMInfo.MajorVersion 185 | WIMMinorVersion = $WIMInfo.MinorVersion 186 | WIMBuild = $WIMInfo.Build 187 | WIMSPBuild = $WIMInfo.SPBuild 188 | WIMLanguages = $WIMInfo.Languages 189 | } 190 | $FilePath = "$($Settings.Settings.PublishingJsonFolder)" + "\$($VHDUEFIFileName)" + ".json" 191 | Write-Log -Message "Creating $FilePath" 192 | $CustomData | ConvertTo-Json | Out-File -FilePath $FilePath -Force 193 | } 194 | 195 | } 196 | 197 | # Create CatalogFile 198 | 199 | $JItems = Get-ChildItem -Path "$($Settings.Settings.PublishingJsonFolder)" -Filter *.json | Where-Object Name -NE catalog.json 200 | $Catalog = foreach($JItem in $JItems){ 201 | Get-Content -Path $JItem.FullName | ConvertFrom-Json 202 | } 203 | $CatalogFilePath = "$($Settings.Settings.PublishingJsonFolder)" + "\catalog.json" 204 | if(Test-Path -Path $CatalogFilePath){Remove-Item -Path $CatalogFilePath -Force} 205 | Write-Log -Message "Creating $CatalogFilePath" 206 | $Catalog | ConvertTo-Json > $CatalogFilePath 207 | 208 | Write-Log -Message "Done" 209 | Return "OK" -------------------------------------------------------------------------------- /Scripts/IMF-SCVMMImport.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | ImageFactory 3.2 4 | .DESCRIPTION 5 | ImageFactory 3.2 6 | .EXAMPLE 7 | ImageFactoryV3-Build.ps1 8 | .NOTES 9 | Created: 2016-11-24 10 | Version: 3.1 11 | 12 | Updated: 2017-02-23 13 | Version: 3.2 14 | 15 | 16 | Author - Mikael Nystrom 17 | Twitter: @mikael_nystrom 18 | Blog : http://deploymentbunny.com 19 | 20 | Disclaimer: 21 | This script is provided 'AS IS' with no warranties, confers no rights and 22 | is not supported by the author. 23 | 24 | This script uses the PsIni module: 25 | Blog : http://oliver.lipkau.net/blog/ 26 | Source : https://github.com/lipkau/PsIni 27 | http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 28 | 29 | .LINK 30 | http://www.deploymentbunny.com 31 | #> 32 | [cmdletbinding(SupportsShouldProcess=$True)] 33 | Param( 34 | [parameter(mandatory=$false)] 35 | [ValidateSet($True,$False)] 36 | $UpdateBootImage = $False, 37 | 38 | [parameter(mandatory=$false)] 39 | [ValidateSet($True,$False)] 40 | $EnableMDTMonitoring = $True, 41 | 42 | [parameter(mandatory=$false)] 43 | [ValidateSet($True,$False)] 44 | $EnableWSUS = $True, 45 | 46 | [parameter(mandatory=$false)] 47 | [ValidateSet($True,$False)] 48 | $TestMode = $False 49 | ) 50 | 51 | #Set start time 52 | $StartTime = Get-Date 53 | 54 | Function Get-VIARefTaskSequence 55 | { 56 | Param( 57 | $RefTaskSequenceFolder 58 | ) 59 | $RefTaskSequences = Get-ChildItem $RefTaskSequenceFolder 60 | Foreach($RefTaskSequence in $RefTaskSequences){ 61 | New-Object PSObject -Property @{ 62 | TaskSequenceID = $RefTaskSequence.ID 63 | Name = $RefTaskSequence.Name 64 | Comments = $RefTaskSequence.Comments 65 | Version = $RefTaskSequence.Version 66 | Enabled = $RefTaskSequence.enable 67 | LastModified = $RefTaskSequence.LastModifiedTime 68 | } 69 | } 70 | } 71 | Function Update-Log 72 | { 73 | Param( 74 | [Parameter( 75 | Mandatory=$true, 76 | ValueFromPipeline=$true, 77 | ValueFromPipelineByPropertyName=$true, 78 | Position=0 79 | )] 80 | [string]$Data, 81 | 82 | [Parameter( 83 | Mandatory=$false, 84 | ValueFromPipeline=$true, 85 | ValueFromPipelineByPropertyName=$true, 86 | Position=0 87 | )] 88 | [string]$Solution = $Solution, 89 | 90 | [Parameter( 91 | Mandatory=$false, 92 | ValueFromPipeline=$true, 93 | ValueFromPipelineByPropertyName=$true, 94 | Position=1 95 | )] 96 | [validateset('Information','Warning','Error')] 97 | [string]$Class = "Information" 98 | 99 | ) 100 | $LogString = "$Solution, $Data, $Class, $(Get-Date)" 101 | $HostString = "$Solution, $Data, $(Get-Date)" 102 | 103 | Add-Content -Path $Log -Value $LogString 104 | switch ($Class) 105 | { 106 | 'Information'{ 107 | Write-Host $HostString -ForegroundColor Gray 108 | } 109 | 'Warning'{ 110 | Write-Host $HostString -ForegroundColor Yellow 111 | } 112 | 'Error'{ 113 | Write-Host $HostString -ForegroundColor Red 114 | } 115 | Default {} 116 | } 117 | } 118 | 119 | #Inititial Settings 120 | Clear-Host 121 | $Log = "C:\Setup\ImageFactoryV3ForHyper-V\log.txt" 122 | $XMLFile = "C:\setup\ImageFactoryV3ForHyper-V\ImageFactoryV3.xml" 123 | $Solution = "IMF32" 124 | Update-Log -Data "Imagefactory 3.2 (Hyper-V)" 125 | Update-Log -Data "Logfile is $Log" 126 | Update-Log -Data "XMLfile is $XMLfile" 127 | 128 | if($TestMode -eq $True){ 129 | Update-Log -Data "Testmode is now $TestMode" 130 | } 131 | 132 | #Importing modules 133 | Update-Log -Data "Importing modules" 134 | Import-Module 'C:\Program Files\Microsoft Deployment Toolkit\Bin\MicrosoftDeploymentToolkit.psd1' -ErrorAction Stop -WarningAction Stop 135 | 136 | #Read Settings from XML 137 | Update-Log -Data "Reading from $XMLFile" 138 | [xml]$Settings = Get-Content $XMLFile -ErrorAction Stop -WarningAction Stop 139 | 140 | #Verify Connection to DeploymentRoot 141 | Update-Log -Data "Verify Connection to DeploymentRoot" 142 | $Result = Test-Path -Path $Settings.Settings.MDT.DeploymentShare 143 | If($Result -ne $true){Update-Log -Data "Cannot access $($Settings.Settings.MDT.DeploymentShare) , will break";break} 144 | 145 | #Connect to MDT 146 | Update-Log -Data "Connect to MDT" 147 | $Root = $Settings.Settings.MDT.DeploymentShare 148 | if((Test-Path -Path MDT:) -eq $false){ 149 | $MDTPSDrive = New-PSDrive -Name MDT -PSProvider MDTProvider -Root $Root -ErrorAction Stop 150 | Update-Log -Data "Connected to $($MDTPSDrive.Root)" 151 | } 152 | 153 | #Get MDT Settings 154 | Update-Log -Data "Get MDT Settings" 155 | $MDTSettings = Get-ItemProperty MDT: 156 | 157 | 158 | #Get TaskSequences 159 | Update-Log -Data "Get TaskSequences" 160 | $RefTaskSequenceIDs = (Get-VIARefTaskSequence -RefTaskSequenceFolder "MDT:\Task Sequences\$($Settings.Settings.MDT.RefTaskSequenceFolderName)").TasksequenceID 161 | if($RefTaskSequenceIDs.count -eq 0){ 162 | Update-Log -Data "Sorry, could not find any TaskSequences to work with" 163 | BREAK 164 | } 165 | Update-Log -Data "Found $($RefTaskSequenceIDs.count) TaskSequences to work on" 166 | 167 | #Get detailed info 168 | Update-Log -Data "Get detailed info about the task sequences" 169 | $Result = Get-VIARefTaskSequence -RefTaskSequenceFolder "MDT:\Task Sequences\$($Settings.Settings.MDT.RefTaskSequenceFolderName)" 170 | foreach($obj in ($Result | Select-Object TaskSequenceID,Name,Version)){ 171 | $data = "$($obj.TaskSequenceID) $($obj.Name) $($obj.Version)" 172 | Update-Log -Data $data 173 | } 174 | 175 | foreach ($item in $Result){ 176 | $VHDName = $item.TaskSequenceID + "_UEFI.vhdx" 177 | $OSName = $item.Name 178 | $scriptblock = { 179 | $libraryObject = Get-SCVirtualHardDisk -Name "WS2016-01-2_UEFI.vhdx" | Where-Object Directory -Like "\\SFADEPL01.FABRIC.SEAL-SOFTWARE.CLOUD\VHD*" 180 | foreach($Item in $libraryObject){ 181 | $os = Get-SCOperatingSystem | Where-Object Name -Like "* 2012 r2 standard" 182 | Set-SCVirtualHardDisk -VirtualHardDisk $libraryObject -OperatingSystem $os -VirtualizationPlatform "Unknown" -Name "WS2012R2-01-1_UEFI.vhdx" -Description "" -Release "" -FamilyName "" 183 | } 184 | 185 | } 186 | } 187 | 188 | 189 | 190 | } 191 | 192 | 193 | 194 | 195 | -------------------------------------------------------------------------------- /Scripts/IMF-Uninstall.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | ImageFactory 3.2 4 | .DESCRIPTION 5 | ImageFactory 3.2 6 | .EXAMPLE 7 | ImageFactoryV3-Build.ps1 8 | .NOTES 9 | Created: 2016-11-24 10 | Version: 3.1 11 | 12 | Updated: 2017-02-23 13 | Version: 3.2 14 | 15 | 16 | Author - Mikael Nystrom 17 | Twitter: @mikael_nystrom 18 | Blog : http://deploymentbunny.com 19 | 20 | Disclaimer: 21 | This script is provided 'AS IS' with no warranties, confers no rights and 22 | is not supported by the author. 23 | 24 | This script uses the PsIni module: 25 | Blog : http://oliver.lipkau.net/blog/ 26 | Source : https://github.com/lipkau/PsIni 27 | http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 28 | 29 | .LINK 30 | http://www.deploymentbunny.com 31 | #> 32 | [cmdletbinding(SupportsShouldProcess=$True)] 33 | Param( 34 | ) 35 | 36 | #Inititial Settings 37 | $CurrentPath = split-path -parent $MyInvocation.MyCommand.Path 38 | $RootPath = split-path -parent $CurrentPath 39 | $Global:ScriptLogFilePath = "$RootPath\IMF.log" 40 | $XMLFile = "$RootPath\IMF.xml" 41 | $Global:writetoscreen = $true 42 | 43 | #Importing modules 44 | Import-Module IMFFunctions -ErrorAction Stop -WarningAction Stop -Force 45 | Write-Log -Message "Module IMFFunctions imported" 46 | Import-Module 'C:\Program Files\Microsoft Deployment Toolkit\Bin\MicrosoftDeploymentToolkit.psd1' -ErrorAction Stop -WarningAction Stop 47 | Write-Log -Message "Module MicrosoftDeploymentToolkit imported" 48 | 49 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 50 | Write-Log -Message "Logfile is $Log" 51 | Write-Log -Message "XMLfile is $XMLfile" 52 | 53 | #Read Settings from XML 54 | Write-Log -Message "Reading from $XMLFile" 55 | [xml]$Settings = Get-Content $XMLFile -ErrorAction Stop -WarningAction Stop 56 | 57 | #Get deploymentshare folder 58 | Write-Log -Message "Get Deploymentshare settings" 59 | $DeploymentShare = $settings.Settings.MDT.DeploymentShare 60 | 61 | #Verify Connection to DeploymentRoot 62 | Write-Log -Message "Verify Connection to DeploymentRoot" 63 | $Result = Test-Path -Path $Settings.Settings.MDT.DeploymentShare 64 | If($Result -ne $true){ 65 | Write-Log -Message "Cannot access $($Settings.Settings.MDT.DeploymentShare) , will break" -LogLevel 2 66 | Return "Fail" 67 | break 68 | } 69 | 70 | #Connect to MDT 71 | Write-Log -Message "Connect to MDT" 72 | $Root = $Settings.Settings.MDT.DeploymentShare 73 | if((Test-Path -Path MDT:) -eq $false){ 74 | $MDTPSDrive = New-PSDrive -Name MDT -PSProvider MDTProvider -Root $Root -ErrorAction Stop 75 | Write-Log -Message "Connected to $($MDTPSDrive.Root)" 76 | } 77 | 78 | #Get MDT Settings 79 | Write-Log -Message "Get MDT Settings" 80 | $MDTSettings = Get-ItemProperty MDT: 81 | 82 | #Get SMB Share 83 | Write-Log -Message "Get SMB Share" 84 | $result = Get-SmbShare | Where-Object Path -EQ $MDTSettings.PhysicalPath | Remove-SmbShare -Force -PassThru 85 | Write-Log -Message "Removed file share" 86 | 87 | #Get MDT Settings 88 | Write-Log -Message "Get Folder" 89 | $result = Get-Item -Path $MDTSettings.PhysicalPath | Remove-Item -Recurse -Force 90 | Write-Log -Message "Removed Folder" 91 | Return "OK" -------------------------------------------------------------------------------- /Scripts/IMF-UpdateBootImage.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | ImageFactory 3.2 4 | .DESCRIPTION 5 | ImageFactory 3.2 6 | .EXAMPLE 7 | ImageFactoryV3-Build.ps1 8 | .NOTES 9 | Created: 2016-11-24 10 | Version: 3.1 11 | 12 | Updated: 2017-02-23 13 | Version: 3.2 14 | 15 | 16 | Author - Mikael Nystrom 17 | Twitter: @mikael_nystrom 18 | Blog : http://deploymentbunny.com 19 | 20 | Disclaimer: 21 | This script is provided 'AS IS' with no warranties, confers no rights and 22 | is not supported by the author. 23 | 24 | This script uses the PsIni module: 25 | Blog : http://oliver.lipkau.net/blog/ 26 | Source : https://github.com/lipkau/PsIni 27 | http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 28 | 29 | .LINK 30 | http://www.deploymentbunny.com 31 | #> 32 | 33 | [cmdletbinding(SupportsShouldProcess=$True)] 34 | Param( 35 | ) 36 | 37 | #Requires -RunAsAdministrator 38 | 39 | #Inititial Settings 40 | $CurrentPath = Split-Path -parent $MyInvocation.MyCommand.Path 41 | $RootPath = Split-Path -parent $CurrentPath 42 | $Global:ScriptLogFilePath = "$RootPath\IMF.log" 43 | $XMLFile = "$RootPath\IMF.xml" 44 | $Global:writetoscreen = $true 45 | 46 | #Importing ModuleMicrosoftDeploymentToolkit 47 | Import-Module 'C:\Program Files\Microsoft Deployment Toolkit\Bin\MicrosoftDeploymentToolkit.psd1' -ErrorAction Stop -WarningAction Stop 48 | Write-Log -Message "ModuleMicrosoftDeploymentToolkit imported" 49 | 50 | #Inititial Settings 51 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 52 | Write-Log -Message "Logfile is $ScriptLogFilePath" 53 | Write-Log -Message "XMLfile is $XMLfile" 54 | 55 | #Read Settings from XML 56 | Write-Log -Message "Reading from $XMLFile" 57 | [xml]$Settings = Get-Content $XMLFile -ErrorAction Stop -WarningAction Stop 58 | 59 | #Connect to MDT 60 | Write-Log -Message "Connect to MDT" 61 | $Root = $Settings.Settings.MDT.DeploymentShare 62 | if((Test-Path -Path MDT:) -eq $false){ 63 | $MDTPSDrive = New-PSDrive -Name MDT -PSProvider MDTProvider -Root $Root -ErrorAction Stop 64 | Write-Log -Message "Connected to $($MDTPSDrive.Root)" 65 | } 66 | 67 | #Update bootimage 68 | Write-Log -Message "Updating boot image, please wait" 69 | Update-MDTDeploymentShare -Path MDT: -ErrorAction Stop 70 | Write-Log -Message "Done" 71 | Return "OK" 72 | -------------------------------------------------------------------------------- /Scripts/IMF-VerifyBuild.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeploymentBunny/IMF4/445174060bf86f1efe55ae9b592d907da2607dde/Scripts/IMF-VerifyBuild.ps1 -------------------------------------------------------------------------------- /Scripts/IMF-VerifyCleanupVMs.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | ImageFactory 3.3 4 | .DESCRIPTION 5 | ImageFactory 3.3 6 | .EXAMPLE 7 | ImageFactoryV3-Verify-CleanupVMs.ps1 8 | .NOTES 9 | Created: 2016-11-24 10 | Version: 3.1 11 | 12 | Updated: 2017-02-23 13 | Version: 3.2 14 | 15 | Updated: 2017-09-27 16 | Version: 3.3 17 | 18 | 19 | Author - Mikael Nystrom 20 | Twitter: @mikael_nystrom 21 | Blog : http://deploymentbunny.com 22 | 23 | Disclaimer: 24 | This script is provided 'AS IS' with no warranties, confers no rights and 25 | is not supported by the author. 26 | 27 | This script uses the PsIni module: 28 | Blog : http://oliver.lipkau.net/blog/ 29 | Source : https://github.com/lipkau/PsIni 30 | http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 31 | 32 | .LINK 33 | http://www.deploymentbunny.com 34 | #> 35 | 36 | $CurrentPath = split-path -parent $MyInvocation.MyCommand.Path 37 | $RootPath = split-path -parent $CurrentPath 38 | 39 | #Importing modules 40 | Import-Module IMFFunctions -ErrorAction Stop -WarningAction Stop -Force 41 | Write-Log -Message "Module IMFFunctions imported" 42 | Import-Module 'C:\Program Files\Microsoft Deployment Toolkit\Bin\MicrosoftDeploymentToolkit.psd1' -ErrorAction Stop -WarningAction Stop 43 | Write-Log -Message "ModuleMicrosoftDeploymentToolkit imported" 44 | 45 | #Inititial Settings 46 | $Log = "$RootPath\log.txt" 47 | $XMLFile = "$RootPath\IMF.xml" 48 | $Solution = "IMF32" 49 | Write-Log -Message "Imagefactory 3.2 (Hyper-V)" 50 | Write-Log -Message "Logfile is $Log" 51 | Write-Log -Message "XMLfile is $XMLfile" 52 | 53 | #Read Settings from XML 54 | Write-Log -Message "Reading from $XMLFile" 55 | [xml]$Settings = Get-Content $XMLFile -ErrorAction Stop -WarningAction Stop 56 | 57 | #Verify Connection to Hyper-V host 58 | Write-Log -Message "Verify Connection to Hyper-V host" 59 | $Result = Test-VIAHypervConnection -Computername $Settings.Settings.HyperV.Computername -ISOFolder $Settings.Settings.HyperV.ISOLocation -VMFolder $Settings.Settings.HyperV.VMLocation -VMSwitchName $Settings.Settings.HyperV.SwitchName 60 | If($Result -ne $true){Write-Log -Message "$($Settings.Settings.HyperV.Computername) is not ready, will break";break} 61 | 62 | #Cleanup Validate VMs 63 | Write-Log -Message "Cleanup Validate VMs" 64 | Invoke-Command -ComputerName $($Settings.Settings.HyperV.Computername) -ScriptBlock { 65 | $ValVMs = Get-VM | Where-Object -Property Notes -Like -Value "VALIDATE*" 66 | Foreach($ValVM in $ValVMs){ 67 | $VM = Get-VM -VMName $ValVM.Name 68 | Write-Verbose "Stopping $($VM.Name) on $($VM.Computername) at $($VM.ConfigurationLocation)" 69 | Stop-VM -VM $VM -Force -TurnOff 70 | Write-Verbose "Deleting $($VM.Name) on $($VM.Computername) at $($VM.ConfigurationLocation)" 71 | Remove-VM -VM $VM -Force 72 | Remove-Item -Path $VM.ConfigurationLocation -Recurse -Force 73 | } 74 | } 75 | 76 | #Cleanup Reference VMs 77 | Write-Log -Message "Cleanup Reference VMs" 78 | Invoke-Command -ComputerName $($Settings.Settings.HyperV.Computername) -ScriptBlock { 79 | $ValVMs = Get-VM | Where-Object -Property Notes -Like -Value "REFIMAGE*" 80 | Foreach($ValVM in $ValVMs){ 81 | $VM = Get-VM -VMName $ValVM.Name 82 | Write-Verbose "Stopping $($VM.Name) on $($VM.Computername) at $($VM.ConfigurationLocation)" 83 | Stop-VM -VM $VM -Force -TurnOff 84 | Write-Verbose "Deleting $($VM.Name) on $($VM.Computername) at $($VM.ConfigurationLocation)" 85 | Remove-VM -VM $VM -Force 86 | Remove-Item -Path $VM.ConfigurationLocation -Recurse -Force 87 | } 88 | } 89 | 90 | 91 | #Cleanup in SCVMM 92 | if($Settings.Settings.SCVMM.InUse -eq $true){ 93 | 94 | $SCVMMServerName = $Settings.Settings.SCVMM.SCVMMServerName 95 | 96 | $ScriptBlock = { 97 | $result = Get-SCVirtualMachine -All | Where-Object Description -EQ REFIMAGE | Where-Object StatusString -EQ Missing | Remove-SCVirtualMachine -Force -RunAsynchronously 98 | $result | Select Name 99 | 100 | $result = Get-SCVirtualMachine -All | Where-Object Description -EQ Validate | Where-Object StatusString -EQ Missing | Remove-SCVirtualMachine -Force -RunAsynchronously 101 | $result | Select Name 102 | } 103 | 104 | Invoke-Command -ComputerName $SCVMMServerName -ScriptBlock $ScriptBlock 105 | } 106 | Return "OK" -------------------------------------------------------------------------------- /Scripts/SampleScripts.ps1: -------------------------------------------------------------------------------- 1 | #Configure Imagefactory 2 | D:\IMFv3\Scripts\ConfigureIMF.ps1 -DeploymentShare D:\MDTBuildLabdev -StartUpRAM 4 -VLANID 0 -Computername $env:COMPUTERNAME -SwitchName "UplinkSwitchNAT" -VMLocation D:\VMsDEV -ISOLocation D:\ISODEV -ConcurrentRunningVMs 2 3 | 4 | #Configure Imagefactory 5 | D:\IMFv3\Scripts\RemoveIMF.ps1 6 | 7 | #Import ISO 8 | D:\IMFv3\Scripts\Import-ISO.ps1 -ISOImage D:\ISO\SW_DVD5_Win_Pro_Ent_Edu_N_10_1709_64BIT_English_MLF_X21-50143.ISO -OSFolder W10x6417091 -OrgName ViaMonstra 9 | #D:\IMFv3\Scripts\Import-ISO.ps1 -ISOImage D:\ISO\SW_DVD5_Win_Pro_Ent_Edu_N_10_1709_64BIT_English_MLF_X21-50143.ISO -OSFolder W10x6417092 -OrgName ViaMonstra 10 | 11 | #Update Bootimage 12 | D:\IMFv3\Scripts\ImageFactoryV3-UpdateBootImage.ps1 13 | 14 | #Make sure we are clean 15 | D:\IMFv3\Scripts\ImageFactoryV3-Verify-CleanupVMs.ps1 16 | 17 | #Start the Image Factory 18 | D:\IMFv3\Scripts\ImageFactoryV3-Build.ps1 -EnableWSUS False 19 | 20 | #Verify the build 21 | D:\IMFv3\Scripts\ImageFactoryV3-Verify-Build.ps1 -KeepVMs False 22 | 23 | #Make sure we are clean 24 | D:\IMFv3\Scripts\ImageFactoryV3-Verify-CleanupVMs.ps1 25 | 26 | #Generate Report 27 | D:\IMFv3\Scripts\ImageFactoryV3-Generate-Report.ps1 28 | 29 | #Generate VHDx 30 | $DateTime = (Get-Date).ToString('yyyyMMdd') 31 | $CaptureFolder = "E:\MDTBuildLab\Captures" 32 | $VHDxFolder = "E:\VHD\$DateTime" 33 | #D:\IMFv3\Scripts\\ImageFactoryV3-ConvertToVHD.ps1 -CaptureFolder $CaptureFolder -VHDxFolder $VHDxFolder -UEFI $True -BIOS $false 34 | 35 | #Move to Archive 36 | New-Item -ItemType Directory -Path $CaptureFolder\Archive -Force 37 | Move-Item -Path (Get-ChildItem -Path $CaptureFolder -Filter *.wim).FullName -Destination $CaptureFolder\Archive -Force 38 | 39 | explorer.exe "D:\MDTBuildLabDev\Reports" 40 | 41 | #Update Image Class in SCVMM 42 | #Import to SCVMM and build validation Templates 43 | 44 | #Update Image Class in SCVMM 45 | #Import to ConfigMgr and build validation TaskSequences 46 | 47 | -------------------------------------------------------------------------------- /Scripts/ZTIBackup.wsf: -------------------------------------------------------------------------------- 1 | 2 | 474 | 475 | -------------------------------------------------------------------------------- /Template/Bootstrap.ini: -------------------------------------------------------------------------------- 1 | [Settings] 2 | Priority=Default 3 | 4 | [Default] 5 | DeployRoot=\\SERVER\SHARE 6 | UserDomain=DOMAIN 7 | UserID=USER 8 | UserPassword=PASSWORD 9 | SkipBDDWelcome=YES 10 | -------------------------------------------------------------------------------- /Template/CustomSettings.ini: -------------------------------------------------------------------------------- 1 | [Settings] 2 | Priority=Serialnumber,Default 3 | 4 | [Default] 5 | _SMSTSORGNAME=%TaskSequenceName% 6 | UserDataLocation=NONE 7 | OSInstall=Y 8 | AdminPassword=PASSWORD 9 | TimeZoneName=Pacific Standard Time 10 | JoinWorkgroup=WORKGROUP 11 | HideShell=NO 12 | FinishAction=SHUTDOWN 13 | WSUSServer=http://server.network.com:8530 14 | ApplyGPOPack=NO 15 | SLShare=\\SERVER\Logs$ 16 | SLShareDynamicLogging=\\SERVER\Logs$ 17 | EventShare=\\SERVER\EventShare$ 18 | ComputerBackupLocation=NETWORK 19 | BackupShare=\\SERVER\MDTBuildLab$ 20 | BackupDir=Captures 21 | 22 | SkipAdminPassword=YES 23 | SkipProductKey=YES 24 | SkipComputerName=YES 25 | SkipDomainMembership=YES 26 | SkipUserData=YES 27 | SkipLocaleSelection=YES 28 | SkipTaskSequence=NO 29 | SkipTimeZone=YES 30 | SkipBitLocker=YES 31 | SkipSummary=YES 32 | SkipRoles=YES 33 | SkipCapture=NO 34 | SkipFinalSummary=YES 35 | 36 | -------------------------------------------------------------------------------- /deploymentbunny-w175.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeploymentBunny/IMF4/445174060bf86f1efe55ae9b592d907da2607dde/deploymentbunny-w175.ico --------------------------------------------------------------------------------