Skip to content

Commit

Permalink
removed trailing space chars
Browse files Browse the repository at this point in the history
  • Loading branch information
JaromirK authored and JaromirK committed Jan 12, 2024
1 parent bb6120a commit ab1c69f
Showing 1 changed file with 53 additions and 53 deletions.
106 changes: 53 additions & 53 deletions Scripts/2_CreateParentDisks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ If (-not $isAdmin) {
Write-Host "-- Restarting as Administrator" -ForegroundColor Cyan ; Start-Sleep -Seconds 1

if($PSVersionTable.PSEdition -eq "Core") {
Start-Process pwsh.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
Start-Process pwsh.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
} else {
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
}

exit
Expand All @@ -15,7 +15,7 @@ If (-not $isAdmin) {
#region Functions
. $PSScriptRoot\0_Shared.ps1 # [!build-include-inline]

#Create Unattend for VHD
#Create Unattend for VHD
Function CreateUnattendFileVHD{
param (
[parameter(Mandatory=$true)]
Expand Down Expand Up @@ -72,8 +72,8 @@ If (-not $isAdmin) {
</UserAccounts>
<OOBE>
<HideEULAPage>true</HideEULAPage>
<SkipMachineOOBE>true</SkipMachineOOBE>
<SkipUserOOBE>true</SkipUserOOBE>
<SkipMachineOOBE>true</SkipMachineOOBE>
<SkipUserOOBE>true</SkipUserOOBE>
</OOBE>
<TimeZone>$TimeZone</TimeZone>
</component>
Expand All @@ -85,7 +85,7 @@ If (-not $isAdmin) {
Set-Content -path $unattendFile -value $fileContent

#return the file object
Return $unattendFile
Return $unattendFile
}

#endregion
Expand Down Expand Up @@ -158,7 +158,7 @@ If (-not $isAdmin) {
#DCHP scope
$DHCPscope = $LabConfig.DHCPscope
$ReverseDNSrecord = $DHCPscope -replace '^(\d+)\.(\d+)\.\d+\.(\d+)$','$3.$2.$1.in-addr.arpa'
$DHCPscope = $DHCPscope.Substring(0,$DHCPscope.Length-1)
$DHCPscope = $DHCPscope.Substring(0,$DHCPscope.Length-1)

#endregion

Expand Down Expand Up @@ -245,7 +245,7 @@ If (-not $isAdmin) {
WriteInfoHighlighted "Checking if volume filesystem is NTFS or ReFS"
$driveletter=$PSScriptRoot -split ":" | Select-Object -First 1
if ($PSScriptRoot -like "c:\ClusterStorage*"){
WriteSuccess "`t Volume Cluster Shared Volume. Mountdir will be $env:Temp\MSLabMountdir"
WriteSuccess "`t Volume Cluster Shared Volume. Mountdir will be $env:Temp\MSLabMountdir"
$mountdir="$env:Temp\MSLabMountdir"
$VolumeFileSystem="CSVFS"
}else{
Expand Down Expand Up @@ -279,7 +279,7 @@ If (-not $isAdmin) {
$openFile = New-Object System.Windows.Forms.OpenFileDialog -Property @{
Title="Please select ISO image with Windows Server 2016, 2019, 2022 or Server Insider"
}
$openFile.Filter = "iso files (*.iso)|*.iso|All files (*.*)|*.*"
$openFile.Filter = "iso files (*.iso)|*.iso|All files (*.*)|*.*"
If($openFile.ShowDialog() -eq "OK"){
WriteInfo "File $($openfile.FileName) selected"
}
Expand Down Expand Up @@ -332,7 +332,7 @@ If (-not $isAdmin) {
Multiselect = $true;
Title = "Please select Windows Server Updates (*.msu). Click Cancel if you don't want any."
}
$msupackages.Filter = "msu files (*.msu)|*.msu|All files (*.*)|*.*"
$msupackages.Filter = "msu files (*.msu)|*.msu|All files (*.*)|*.*"
If($msupackages.ShowDialog() -eq "OK"){
WriteInfoHighlighted "Following patches selected:"
WriteInfo "`t $($msupackages.filenames)"
Expand All @@ -352,13 +352,13 @@ If (-not $isAdmin) {
#Windows Server 2016
$ServerVHDs += @{
Kind = "Full"
Edition="4"
Edition="4"
VHDName="Win2016_G2.vhdx"
Size=127GB
}
$ServerVHDs += @{
Kind = "Core"
Edition="3"
Edition="3"
VHDName="Win2016Core_G2.vhdx"
Size=127GB
}
Expand All @@ -374,34 +374,34 @@ If (-not $isAdmin) {
#Windows Server 2019
$ServerVHDs += @{
Kind = "Full"
Edition="4"
Edition="4"
VHDName="Win2019_G2.vhdx"
Size=127GB
}
$ServerVHDs += @{
Kind = "Core"
Edition="3"
Edition="3"
VHDName="Win2019Core_G2.vhdx"
Size=127GB
}
}elseif ($BuildNumber -eq 20348){
#Windows Server 2022
$ServerVHDs += @{
Kind = "Full"
Edition="4"
Edition="4"
VHDName="Win2022_G2.vhdx"
Size=127GB
}
$ServerVHDs += @{
Kind = "Core"
Edition="3"
Edition="3"
VHDName="Win2022Core_G2.vhdx"
Size=127GB
}
}elseif ($BuildNumber -gt 20348 -and $SAC){
$ServerVHDs += @{
Kind = "Core"
Edition="2"
Edition="2"
VHDName="WinSrvInsiderCore_$BuildNumber.vhdx"
Size=127GB
}
Expand All @@ -413,13 +413,13 @@ If (-not $isAdmin) {
#Windows Sever Insider
$ServerVHDs += @{
Kind = "Full"
Edition="4"
Edition="4"
VHDName="WinSrvInsider_$BuildNumber.vhdx"
Size=127GB
}
$ServerVHDs += @{
Kind = "Core"
Edition="3"
Edition="3"
VHDName="WinSrvInsiderCore_$BuildNumber.vhdx"
Size=127GB
}
Expand Down Expand Up @@ -450,7 +450,7 @@ If (-not $isAdmin) {
'ParentDisks','Temp','Temp\mountdir' | ForEach-Object {
if (!( Test-Path "$PSScriptRoot\$_" )) {
WriteInfoHighlighted "Creating Directory $_"
New-Item -Type Directory -Path "$PSScriptRoot\$_"
New-Item -Type Directory -Path "$PSScriptRoot\$_"
}
}

Expand Down Expand Up @@ -528,8 +528,8 @@ If (-not $isAdmin) {
$toolsVHD=New-VHD -Path "$PSScriptRoot\ParentDisks\tools.vhdx" -SizeBytes 300GB -Dynamic
#mount and format VHD
$VHDMount = Mount-VHD $toolsVHD.Path -Passthru
$vhddisk = $VHDMount| get-disk
$vhddiskpart = $vhddisk | Initialize-Disk -PartitionStyle GPT -PassThru | New-Partition -UseMaximumSize -AssignDriveLetter |Format-Volume -FileSystem NTFS -AllocationUnitSize 8kb -NewFileSystemLabel ToolsDisk
$vhddisk = $VHDMount| get-disk
$vhddiskpart = $vhddisk | Initialize-Disk -PartitionStyle GPT -PassThru | New-Partition -UseMaximumSize -AssignDriveLetter |Format-Volume -FileSystem NTFS -AllocationUnitSize 8kb -NewFileSystemLabel ToolsDisk

$VHDPathTest=Test-Path -Path "$PSScriptRoot\Temp\ToolsVHD\"
if (!$VHDPathTest){
Expand Down Expand Up @@ -632,7 +632,7 @@ If (-not $isAdmin) {
New-item -type directory -Path $mountdir -force
[System.Version]$VMVersion=(Get-WindowsImage -ImagePath $VHDPath -Index 1).Version
Mount-WindowsImage -Path $mountdir -ImagePath $VHDPath -Index 1
Use-WindowsUnattend -Path $mountdir -UnattendPath $unattendFile
Use-WindowsUnattend -Path $mountdir -UnattendPath $unattendFile
#&"$PSScriptRoot\Temp\dism\dism" /mount-image /imagefile:$vhdpath /index:1 /MountDir:$mountdir
#&"$PSScriptRoot\Temp\dism\dism" /image:$mountdir /Apply-Unattend:$unattendfile
New-item -type directory -Path "$mountdir\Windows\Panther" -force
Expand All @@ -650,12 +650,12 @@ If (-not $isAdmin) {
#Create DSC configuration
configuration DCHydration
{
param
param
(
[Parameter(Mandatory)]
[pscredential]$safemodeAdministratorCred,
[Parameter(Mandatory)]
[pscredential]$safemodeAdministratorCred,

[Parameter(Mandatory)]
[Parameter(Mandatory)]
[pscredential]$domainCred,

[Parameter(Mandatory)]
Expand All @@ -671,12 +671,12 @@ If (-not $isAdmin) {
Import-DscResource -ModuleName PSDesiredStateConfiguration


Node $AllNodes.Where{$_.Role -eq "Parent DC"}.Nodename
Node $AllNodes.Where{$_.Role -eq "Parent DC"}.Nodename

{
WindowsFeature ADDSInstall
WindowsFeature ADDSInstall
{
Ensure = "Present"
Ensure = "Present"
Name = "AD-Domain-Services"
}

Expand Down Expand Up @@ -717,18 +717,18 @@ If (-not $isAdmin) {

ADDomain FirstDS
{
DomainName = $Node.DomainName
Credential = $domainCred
DomainName = $Node.DomainName
Credential = $domainCred
SafemodeAdministratorPassword = $safemodeAdministratorCred
DomainNetbiosName = $node.DomainNetbiosName
DependsOn = "[WindowsFeature]ADDSInstall"
}

WaitForADDomain DscForestWait
WaitForADDomain DscForestWait
{
DomainName = $Node.DomainName
Credential = $domainCred
DependsOn = "[ADDomain]FirstDS"
DomainName = $Node.DomainName
Credential = $domainCred
DependsOn = "[ADDomain]FirstDS"
}

ADOrganizationalUnit DefaultOU
Expand All @@ -738,7 +738,7 @@ If (-not $isAdmin) {
ProtectedFromAccidentalDeletion = $true
Description = 'Default OU for all user and computer accounts'
Ensure = 'Present'
DependsOn = "[ADDomain]FirstDS"
DependsOn = "[ADDomain]FirstDS"
}

ADUser SQL_SA
Expand Down Expand Up @@ -954,32 +954,32 @@ If (-not $isAdmin) {

AllNodes = @(
@{
Nodename = $DCName
Role = "Parent DC"
Nodename = $DCName
Role = "Parent DC"
DomainAdminName=$LabConfig.DomainAdminName
DomainName = $LabConfig.DomainName
DomainNetbiosName = $LabConfig.DomainNetbiosName
DomainDN = $LabConfig.DN
DefaultOUName=$LabConfig.DefaultOUName
RegistrationKey='14fc8e72-5036-4e79-9f89-5382160053aa'
PSDscAllowPlainTextPassword = $true
PsDscAllowDomainUser= $true
RetryCount = 50
RetryIntervalSec = 30
PsDscAllowDomainUser= $true
RetryCount = 50
RetryIntervalSec = 30
}
)
}

#create LCM config
[DSCLocalConfigurationManager()]
[DSCLocalConfigurationManager()]
configuration LCMConfig
{
Node DC
{
Settings
{
RebootNodeIfNeeded = $true
ActionAfterReboot = 'ContinueConfiguration'
ActionAfterReboot = 'ContinueConfiguration'
}
}
}
Expand All @@ -1004,7 +1004,7 @@ If (-not $isAdmin) {
WriteInfoHighlighted "`t Starting DC"
$DC | Start-VM

$VMStartupTime = 250
$VMStartupTime = 250
WriteInfoHighlighted "`t Configuring DC using DSC takes a while."
WriteInfo "`t `t Initial configuration in progress. Sleeping $VMStartupTime seconds"
Start-Sleep $VMStartupTime
Expand All @@ -1016,7 +1016,7 @@ If (-not $isAdmin) {
Start-Sleep 10
}elseif ($test.status -ne "Success" -and $i -eq 1) {
WriteInfo "`t `t Current DSC state: $($test.status), ResourncesNotInDesiredState: $($test.resourcesNotInDesiredState.count), ResourncesInDesiredState: $($test.resourcesInDesiredState.count)."
WriteInfoHighlighted "`t `t Invoking DSC Configuration again"
WriteInfoHighlighted "`t `t Invoking DSC Configuration again"
Invoke-Command -VMGuid $DC.id -ScriptBlock {Start-DscConfiguration -UseExisting} -Credential $cred
$i++
}elseif ($test.status -ne "Success" -and $i -gt 1) {
Expand All @@ -1025,7 +1025,7 @@ If (-not $isAdmin) {
Invoke-Command -VMGuid $DC.id -ScriptBlock {Restart-Computer} -Credential $cred
}elseif ($test.status -eq "Success" ) {
WriteInfo "`t `t Current DSC state: $($test.status), ResourncesNotInDesiredState: $($test.resourcesNotInDesiredState.count), ResourncesInDesiredState: $($test.resourcesInDesiredState.count)."
WriteInfoHighlighted "`t `t DSC Configured DC Successfully"
WriteInfoHighlighted "`t `t DSC Configured DC Successfully"
}
}until ($test.Status -eq 'Success' -and $test.rebootrequested -eq $false)
$test
Expand All @@ -1035,7 +1035,7 @@ If (-not $isAdmin) {
Param($LabConfig);
redircmp "OU=$($LabConfig.DefaultOUName),$($LabConfig.DN)"
Add-DnsServerPrimaryZone -NetworkID ($DHCPscope+"/24") -ReplicationScope "Forest"
}
}
#install SCVMM or its prereqs if specified so
if (($LabConfig.InstallSCVMM -eq "Yes") -or ($LabConfig.InstallSCVMM -eq "SQL") -or ($LabConfig.InstallSCVMM -eq "ADK") -or ($LabConfig.InstallSCVMM -eq "Prereqs")){
$DC | Add-VMHardDiskDrive -Path $toolsVHD.Path
Expand Down Expand Up @@ -1068,15 +1068,15 @@ If (-not $isAdmin) {
Start-Sleep 30 #Wait as sometimes VMM failed to install without this.
Invoke-Command -VMGuid $DC.id -Credential $cred -ScriptBlock {
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force
d:\scvmm\3_SCVMM_Install.ps1
d:\scvmm\3_SCVMM_Install.ps1
}
}

if ($LabConfig.InstallSCVMM -eq "SQL"){
WriteInfoHighlighted "Installing SQL"
Invoke-Command -VMGuid $DC.id -Credential $cred -ScriptBlock {
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force
d:\scvmm\1_SQL_Install.ps1
d:\scvmm\1_SQL_Install.ps1
}
}

Expand Down Expand Up @@ -1159,7 +1159,7 @@ If (-not $isAdmin) {
}else{
$renamed = $true
WriteInfo "`t `t Cleaning unnecessary items"
Remove-Item -Path "$PSScriptRoot\temp" -Force -Recurse
Remove-Item -Path "$PSScriptRoot\temp" -Force -Recurse
"$PSScriptRoot\Temp","$PSScriptRoot\1_Prereq.ps1","$PSScriptRoot\2_CreateParentDisks.ps1" | ForEach-Object {
WriteInfo "`t `t `t Removing $_"
Remove-Item -Path $_ -Force -Recurse -ErrorAction SilentlyContinue
Expand Down Expand Up @@ -1223,11 +1223,11 @@ If (-not $isAdmin) {
$vhdProperties['vhd.os.language'] = $OSLanguage
}
}
$events += New-TelemetryEvent -Event "CreateParentDisks.Vhd" -Metrics $vhdMetrics -Properties $vhdProperties -NickName $LabConfig.TelemetryNickName
$events += New-TelemetryEvent -Event "CreateParentDisks.Vhd" -Metrics $vhdMetrics -Properties $vhdProperties -NickName $LabConfig.TelemetryNickName
}

# and one overall
$events += New-TelemetryEvent -Event "CreateParentDisks.End" -Metrics $metrics -Properties $properties -NickName $LabConfig.TelemetryNickName
$events += New-TelemetryEvent -Event "CreateParentDisks.End" -Metrics $metrics -Properties $properties -NickName $LabConfig.TelemetryNickName

Send-TelemetryEvents -Events $events | Out-Null
}
Expand Down

0 comments on commit ab1c69f

Please sign in to comment.