Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- If (!(Test-Path $profile)) { New-item –type file –force $profile }
- Import-Module "$env:WinDir\system32\WindowsPowerShell\v1.0\Modules\NetSecurity\NetSecurity.psd1"
- Import-Module "$env:WinDir\system32\WindowsPowerShell\v1.0\Modules\SmbShare\SmbShare.psd1"
- Import-Module "$env:WinDir\system32\WindowsPowerShell\v1.0\Modules\NetTCPIP\NetTCPIP.psd1"
- Import-Module "$env:WinDir\system32\WindowsPowerShell\v1.0\Modules\ServerManager\ServerManager.psd1"
- function AddFolder {
- Param ([string]$xmlPath,[string]$nodeName)
- if (!(Test-Path($xmlPath))) {
- [xml]$xml = "<groups><group /></groups>"
- }elseif (!(([xml](type $xmlPath)).groups.HasChildNodes)) {
- [xml]$xml = "<groups><group /></groups>"
- }else{
- [xml]$xml = (type $xmlPath)
- }
- $newGUID = ([guid]::NewGuid())
- [xml]$newNode = @"
- <group guid="{$newGUID}" enable="True">
- <Name>$nodeName</Name>
- </group>
- "@
- $xml.groups.AppendChild($xml.ImportNode($newNode.group, $true))
- $xml.save($xmlPath)
- }
- #Get-NetIPAddress -InterfaceAlias "Ethernet" -AddressFamily IPv4 | fl -Property "IPAddress"
- #Test-Connection -ComputerName "google.com"
- #Start-Sleep -Seconds 180 -Verbose
- If (!(Invoke-WebRequest -Uri "https://chocolatey.org/install.ps1" -UseBasicParsing | Invoke-Expression)) {Exit}
- Start-Process -FilePath "$env:SystemDrive\ProgramData\chocolatey\bin\choco.exe" -ArgumentList "feature enable -n=allowGlobalConfirmation" -NoNewWindow -Wait
- Start-Process -FilePath "$env:SystemDrive\ProgramData\chocolatey\bin\choco.exe" -ArgumentList "feature enable -n=allowEmptyChecksums" -NoNewWindow -Wait
- Start-Process -FilePath "$env:SystemDrive\ProgramData\chocolatey\bin\choco.exe" -ArgumentList "source add --name=""local"" --source=""$env:SystemDrive\vagrant_data\packages"" --priority=""1""" -NoNewWindow -Wait
- Start-Process -FilePath "$env:SystemDrive\ProgramData\chocolatey\bin\choco.exe" -ArgumentList "config set --cache-location=""$env:SystemDrive\vagrant_data\cache""" -NoNewWindow -Wait
- Start-Process -FilePath "$env:SystemDrive\ProgramData\chocolatey\bin\choco.exe" -ArgumentList "install windows-adk-winpe mdt hackfont notepadplusplus 7zip.install sccmtoolkit imagemagick pscx --limitoutput --allowunofficial" -NoNewWindow -Wait
- Remove-Item -Path "$env:UserProfile\Desktop\ImageMagick Display.lnk" -Force
- Import-Module "$env:ProgramFiles\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"
- <# #Install Active Directory
- $SafeModeAdministratorPasswordText = "P@ssw0rd"
- $SafeModeAdministratorPassword = ConvertTo-SecureString -AsPlainText $SafeModeAdministratorPasswordText -Force
- Install-WindowsFeature AD-Domain-Services
- Import-Module "$env:WinDir\system32\WindowsPowerShell\v1.0\Modules\ADDSDeployment\ADDSDeployment.psd1"
- Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath "$env:SystemDrive\Windows\NTDS" -DomainMode "Win2012R2" -DomainName "pdeploy.com" `
- -DomainNetbiosName "pdeploy" -ForestMode "Win2012R2" -InstallDns:$true -LogPath "$env:SystemDrive\Windows\NTDS" -NoRebootOnCompletion:$true `
- -SysvolPath "$env:SystemDrive\Windows\SYSVOL" -Force:$true -SafeModeAdministratorPassword $SafeModeAdministratorPassword
- #Install DHCP and configure
- Install-WindowsFeature -Name 'DHCP' -IncludeManagementTools
- Import-Module "$env:WinDir\system32\WindowsPowerShell\v1.0\Modules\DhcpServer\DhcpServer.psd1"
- Add-DhcpServerv4Scope -Name "Bridged" -StartRange 192.168.50.100 -EndRange 192.168.50.250 -SubnetMask 255.255.255.0 -Description "Bridged Network"
- # Install WDS Role and Configure Server
- Install-WindowsFeature WDS
- #cinst "Microsoft-Windows-Deployment-Services" "Microsoft-Windows-Deployment-Services-Deployment-Server" "Microsoft-Windows-Deployment-Services-Transport-Server" --source windowsfeatures
- Start-Process -FilePath "cmd.exe" -ArgumentList "/c wdsutil /initialize-server /server:$env:computername /reminst:$env:SystemDrive\RemoteInstall" -ErrorAction "SilentlyContinue" -NoNewWindow -Wait
- Start-Process -FilePath "cmd.exe" -ArgumentList "/c wdsutil /set-server /answerclients:all" -ErrorAction "SilentlyContinue" -NoNewWindow -Wait #>
- New-Item -Path "C:\DeploymentShare" -ItemType directory -Verbose
- New-SmbShare -Name "DS" -Path "C:\DeploymentShare" -FullAccess Administrators -Verbose
- # Start-Process -FilePath "cmd.exe" -ArgumentList "/c net share DS=C:\DeploymentShare /GRANT:Everyone,FULL" -ErrorAction "SilentlyContinue" -NoNewWindow -Wait
- Start-Process -FilePath "cmd.exe" -ArgumentList "/c net user MDT P@ssw0rd /add" -ErrorAction "SilentlyContinue" -NoNewWindow -Verbose -Wait
- Start-Process -FilePath "cmd.exe" -ArgumentList "/c net localgroup Administrators MDT /add" -ErrorAction "SilentlyContinue" -NoNewWindow -Verbose -Wait
- Start-Process -FilePath "cmd.exe" -ArgumentList '/c wmic UserAccount where Name="MDT" set PasswordExpires=False' -ErrorAction "SilentlyContinue" -NoNewWindow -Verbose -Wait
- $path = "${env:ProgramFiles(x86)}\Notepad++\stylers.model.xml"
- $xml = [xml](Get-Content $path)
- $node = $xml.NotepadPlus.GlobalStyles.WidgetStyle | ? { $_.name -eq "Global override" }
- $node.fontName = "Hack"
- $node.fontSize = "11"
- $xml.Save($path)
- Start-Process -FilePath "setx.exe" -ArgumentList "PATH ""$env:Path;${env:ProgramFiles(x86)}\Notepad++"" /M" -ErrorAction "SilentlyContinue" -NoNewWindow -Wait
- #[Environment]::SetEnvironmentVariable("Path", $env:Path + ";${env:ProgramFiles(x86)}\Notepad++", [EnvironmentVariableTarget]::Machine)
- new-PSDrive -Name "DS001" -PSProvider "MDTProvider" -Root "$env:SystemDrive\DeploymentShare" -Description "DS" -NetworkPath "\\$env:computername\DS" -Verbose | add-MDTPersistentDrive -Verbose
- $bootstrapPath = "C:\DeploymentShare\Control\Bootstrap.ini"
- if (Test-Path($bootstrapPath)) { Remove-Item $bootstrapPath -Force -Verbose }
- Add-Content -Path $bootstrapPath -Value "[Settings]`r`nPriority=Default`r`n[Default]`r`nDeployRoot=\\$env:computername\DS" -Force -ErrorAction SilentlyContinue -Verbose
- Add-Content -Path $bootstrapPath -Value "`r`nSkipBDDWelcome=YES" -Force -ErrorAction SilentlyContinue -Verbose
- Add-Content -Path $bootstrapPath -Value "`r`nUserDomain=$env:computername`r`nUserID=MDT`r`nUserpassword=P@ssw0rd" -Force -ErrorAction SilentlyContinue -Verbose
- $imagemagick = (dir "C:\Program Files\imagemagick*\magick.exe").FullName
- $datestamp, $architecture = (Get-Date -format "dd-MMM-yyyy HH:mm"), "x64"
- $fontsize, $fontfamily, $fontstyle, $fontcolor = "14", "Tahoma", "Normal", "Blue"
- $convertstring = 'convert "C:\Program Files\Microsoft Deployment Toolkit\Samples\Background.bmp"'+`
- ' -resize "1024x768" -font "'+$fontfamily+'" -style "'+$fontstyle+'" -fill "'+$fontcolor+'" -pointsize "'+$fontsize+`
- '" -draw "text 850,180 '''+$architecture+' @ '+$datestamp+'''" "C:\DeploymentShare\Background.bmp"'
- Start-Process -FilePath $imagemagick -ArgumentList $convertstring -ErrorAction "SilentlyContinue" -NoNewWindow -Wait -Verbose
- $path = "$env:SystemDrive\DeploymentShare\Control\Settings.xml"
- $xml = [xml](Get-Content $path)
- $xml.Settings."SupportX86" = "False"
- $xml.Settings."Boot.x64.ScratchSpace" = "512"
- $xml.Settings."Boot.x64.BackgroundFile" = "$env:SystemDrive\DeploymentShare\Background.bmp"
- $xml.Settings."Boot.x64.SelectionProfile" = "Nothing"
- $xml.Save($path)
- update-MDTDeploymentShare -path "DS001:" -Verbose
- $Folders = ("Win 7x86","Win 7x64","Win 10x64")
- ForEach ($a in $Folders ) { AddFolder -xmlPath "$env:SystemDrive\DeploymentShare\Control\ApplicationGroups.xml" -nodeName $a}
- ForEach ($a in $Folders ) { AddFolder -xmlPath "$env:SystemDrive\DeploymentShare\Control\DriverGroups.xml" -nodeName $a}
- ForEach ($a in $Folders ) { AddFolder -xmlPath "$env:SystemDrive\DeploymentShare\Control\OperatingSystemGroups.xml" -nodeName $a}
- $Folders = ("Win 7x86","Win 7x64","Win 10x64","Win 7x86\Deploy","Win 7x64\Deploy","Win 10x64\Deploy","Win 7x86\Capture","Win 7x64\Capture","Win 10x64\Capture","Development")
- ForEach ($a in $Folders ) { AddFolder -xmlPath "$env:SystemDrive\DeploymentShare\Control\TaskSequenceGroups.xml" -nodeName $a}
- Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False -Verbose
- Copy-Item "$env:SystemDrive\DeploymentShare\Boot\LiteTouchPE_x64.iso" "$env:SystemDrive\vagrant_data\" -Force -Verbose
- $SafeModeAdministratorPasswordText = "P@ssw0rd"
- $SafeModeAdministratorPassword = ConvertTo-SecureString -AsPlainText $SafeModeAdministratorPasswordText -Force
- Install-WindowsFeature AD-Domain-Services -IncludeManagementTools
- Import-Module "$env:WinDir\system32\WindowsPowerShell\v1.0\Modules\ADDSDeployment\ADDSDeployment.psd1"
- Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath "$env:SystemDrive\Windows\NTDS" -DomainMode "Win2012R2" -DomainName "pdeploy.com" `
- -DomainNetbiosName "pdeploy" -ForestMode "Win2012R2" -InstallDns:$true -LogPath "$env:SystemDrive\Windows\NTDS" -NoRebootOnCompletion:$true `
- -SysvolPath "$env:SystemDrive\Windows\SYSVOL" -Force:$true -SafeModeAdministratorPassword $SafeModeAdministratorPassword -ErrorAction "SilentlyContinue"
- Install-WindowsFeature -Name 'DHCP' -IncludeManagementTools -ErrorAction "SilentlyContinue"
- Import-Module "$env:WinDir\system32\WindowsPowerShell\v1.0\Modules\DhcpServer\DhcpServer.psd1" -ErrorAction "SilentlyContinue"
- Add-DhcpServerv4Scope -Name "Bridged" -StartRange "192.168.50.100" -EndRange "192.168.50.250" -SubnetMask "255.255.255.0" -Description "Internal Network" -ErrorAction "SilentlyContinue"
- Install-WindowsFeature WDS -IncludeManagementTools -ErrorAction "SilentlyContinue"
- Start-Process -FilePath "cmd.exe" -ArgumentList '/c wdsutil /initialize-server /reminst:"$env:SystemDrive\RemoteInstall"' -ErrorAction "SilentlyContinue" -NoNewWindow -Wait
- Start-Process -FilePath "cmd.exe" -ArgumentList "/c wdsutil /set-server /answerclients:all" -ErrorAction "SilentlyContinue" -NoNewWindow -Wait
- Restart-Computer -Force
Add Comment
Please, Sign In to add comment