From aeffe413a9824ed241ebca3f778bc34ed9ec70aa Mon Sep 17 00:00:00 2001 From: Brian Kaiser Date: Thu, 17 Jun 2021 16:53:30 -0400 Subject: [PATCH 1/9] Modified OneDrive download --- Public/Save-OSDBuilderDownload.ps1 | 106 ++++++++++++++++++++++------- 1 file changed, 83 insertions(+), 23 deletions(-) diff --git a/Public/Save-OSDBuilderDownload.ps1 b/Public/Save-OSDBuilderDownload.ps1 index 26c92eb..0e077d3 100644 --- a/Public/Save-OSDBuilderDownload.ps1 +++ b/Public/Save-OSDBuilderDownload.ps1 @@ -224,34 +224,94 @@ function Save-OSDBuilderDownload { if ($PSCmdlet.ParameterSetName -eq 'Content') { - #=================================================================================================== - # Database - #=================================================================================================== - if ($ContentDownload -eq 'OneDriveSetup Production') { - $DownloadUrl = 'https://go.microsoft.com/fwlink/p/?LinkId=248256' - $DownloadPath = $GetOSDBuilderPathContentOneDrive - $DownloadFile = 'OneDriveSetup.exe' - } - if ($ContentDownload -eq 'OneDriveSetup Enterprise') { - $DownloadUrl = 'https://go.microsoft.com/fwlink/p/?linkid=860987' - $DownloadPath = $GetOSDBuilderPathContentOneDrive - $DownloadFile = 'OneDriveSetup.exe' + function Save-OneDriveSetup { + [CmdletBinding()] + param ( + # THE NAME OF THE FILE (ONEDRIVESETUP.EXE) + [Parameter(Mandatory = $true)] + [String] + $Name, + + # THE PATH WHERE THE FILE IS SAVED (C:\OSDBuilder\Content\OneDrive) + [Parameter(Mandatory = $true)] + [System.IO.FileInfo] + $Path + ) + + $filePath = "$Path\$Name" + + $iwrParams = @{ + OutFile = "$filePath" + Uri = '' + } + + switch ($ContentDownload) { + 'OneDriveSetup Production' { + # LINK FOR THE PRODUCTION RING, LATEST RELEASE BUILD + $iwrParams.Uri = 'https://go.microsoft.com/fwlink/?linkid=844652' + } + + 'OneDriveSetup Enterprise' { + # LINK FOR THE DEFERRED RING, LATEST RELEASE BUILD + $iwrParams.Uri = 'https://go.microsoft.com/fwlink/?linkid=860987' + } + + Default {} + } + + # CHECK IF THE ONEDRIVESETUP.EXE FILE ALREADY EXISTS + if ((Test-Path -Path "$filePath") -eq $false) { + Write-Verbose -Message "$Name not found at $Path..." -Verbose + $exeExists = $false + } + + # IF ONEDRIVESETUP.EXE ALREADY EXISTS, CHECK IF IT IS UP-TO-DATE + if ($exeExists -eq $true) { + $exeOutdated = $false + + # GET THE VERSION NUMBER OF ONEDRIVESETUP.EXE + $exeVersion = (Get-ItemProperty -Path "$filePath" -Name VersionInfo | Select-Object -ExpandProperty VersionInfo).ProductVersion + + # CHECK THE RELEASE NOTES PAGE FOR ONEDRIVE AND PARSE OUT THE LATEST VERSION NUMBER + $releaseNotes = 'https://go.microsoft.com/fwlink/?linkid=2159953' + $latestVersion = Invoke-WebRequest -Uri $releaseNotes -UseBasicParsing | + Select-Object -ExpandProperty Links | + Where-Object -Property 'href' -like -Value $iwrParams.url | + Select-Object -Last 1 -ExpandProperty 'outerHTML' + $latestVersion = $latestVersion.Split('<>')[2] + + # COMPARE THE VERSION OF ONEDRIVESETUP.EXE WITH WHAT'S LISTED ONLINE + if ($exeVersion -lt $latestVersion) { + Write-Verbose -Message "$Name $exeVersion is out of date. The latest version is $latestVersion..." -Verbose + $exeOutdated = $true + } + } + + # DOWNLOAD ONEDRIVESETUP.EXE IF IT DOESN'T EXIST OR IS OUTDATED + if (($exeExists -eq $false) -or ($exeOutdated -eq $true)) { + Write-Host -Object "Downloading the $UpdateRing ring release of $fileName ($latestVersion)..." + Write-Verbose -Message "DownloadUrl: $($iwrParams.Uri)" -Verbose + Write-Verbose -Message "DownloadPath: $Path" -Verbose + Write-Verbose -Message "DownloadFile: $Name" -Verbose + + try { + Invoke-WebRequest @iwrParams -ErrorAction Stop + } catch { + Write-Warning -Message 'Content could not be downloaded' + } + } else { + Write-Verbose -Message "OneDriveSetup.exe does not need to be updated. Skipping download" + } } #=================================================================================================== # Download #=================================================================================================== + $DownloadPath = $GetOSDBuilderPathContentOneDrive + $DownloadFile = 'OneDriveSetup.exe' + if (!(Test-Path "$DownloadPath")) {New-Item -Path $DownloadPath -ItemType Directory -Force | Out-Null} - Write-Verbose "DownloadUrl: $DownloadUrl" -Verbose - Write-Verbose "DownloadPath: $DownloadPath" -Verbose - Write-Verbose "DownloadFile: $DownloadFile" -Verbose - Invoke-WebRequest -Uri $DownloadUrl -OutFile "$DownloadPath\$DownloadFile" - if (Test-Path "$DownloadPath\$DownloadFile") { - $OneDriveSetupInfo = Get-Item -Path "$DownloadPath\$DownloadFile" | Select-Object -Property * - Write-Verbose "DownloadVersion: $($($OneDriveSetupInfo).VersionInfo.ProductVersion)" -Verbose - Write-Verbose 'Complete' -Verbose - } else { - Write-Warning 'Content could not be downloaded' - } + + Save-OneDriveSetup -Path $DownloadPath -Name $DownloadFile } if (($PSCmdlet.ParameterSetName -eq 'OSDUpdate') -or ($PSCmdlet.ParameterSetName -eq 'OSDUpdateSuperseded')) { From 15c1517cbb9a120c43c539c9d12ec1f47c5ae868 Mon Sep 17 00:00:00 2001 From: Brian Kaiser Date: Fri, 18 Jun 2021 08:16:11 -0400 Subject: [PATCH 2/9] Fixed logic issues and verbose output --- Public/Save-OSDBuilderDownload.ps1 | 31 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/Public/Save-OSDBuilderDownload.ps1 b/Public/Save-OSDBuilderDownload.ps1 index 0e077d3..1fb0a39 100644 --- a/Public/Save-OSDBuilderDownload.ps1 +++ b/Public/Save-OSDBuilderDownload.ps1 @@ -244,7 +244,8 @@ function Save-OSDBuilderDownload { OutFile = "$filePath" Uri = '' } - + + # SET THE DOWNLOAD URL BASED ON ONEDRIVE SETUP TYPE switch ($ContentDownload) { 'OneDriveSetup Production' { # LINK FOR THE PRODUCTION RING, LATEST RELEASE BUILD @@ -258,27 +259,25 @@ function Save-OSDBuilderDownload { Default {} } + + # CHECK THE RELEASE NOTES PAGE FOR ONEDRIVE AND PARSE OUT THE LATEST VERSION NUMBER + $releaseNotes = 'https://go.microsoft.com/fwlink/?linkid=2159953' + $latestVersion = Invoke-WebRequest -Uri $releaseNotes -UseBasicParsing | + Select-Object -ExpandProperty Links | + Where-Object -Property 'href' -like -Value $iwrParams.uri | + Select-Object -Last 1 -ExpandProperty 'outerHTML' + $latestVersion = $latestVersion.Split('<>')[2] # CHECK IF THE ONEDRIVESETUP.EXE FILE ALREADY EXISTS if ((Test-Path -Path "$filePath") -eq $false) { Write-Verbose -Message "$Name not found at $Path..." -Verbose $exeExists = $false - } - - # IF ONEDRIVESETUP.EXE ALREADY EXISTS, CHECK IF IT IS UP-TO-DATE - if ($exeExists -eq $true) { + } else { + $exeExists = $true $exeOutdated = $false # GET THE VERSION NUMBER OF ONEDRIVESETUP.EXE $exeVersion = (Get-ItemProperty -Path "$filePath" -Name VersionInfo | Select-Object -ExpandProperty VersionInfo).ProductVersion - - # CHECK THE RELEASE NOTES PAGE FOR ONEDRIVE AND PARSE OUT THE LATEST VERSION NUMBER - $releaseNotes = 'https://go.microsoft.com/fwlink/?linkid=2159953' - $latestVersion = Invoke-WebRequest -Uri $releaseNotes -UseBasicParsing | - Select-Object -ExpandProperty Links | - Where-Object -Property 'href' -like -Value $iwrParams.url | - Select-Object -Last 1 -ExpandProperty 'outerHTML' - $latestVersion = $latestVersion.Split('<>')[2] # COMPARE THE VERSION OF ONEDRIVESETUP.EXE WITH WHAT'S LISTED ONLINE if ($exeVersion -lt $latestVersion) { @@ -289,18 +288,20 @@ function Save-OSDBuilderDownload { # DOWNLOAD ONEDRIVESETUP.EXE IF IT DOESN'T EXIST OR IS OUTDATED if (($exeExists -eq $false) -or ($exeOutdated -eq $true)) { - Write-Host -Object "Downloading the $UpdateRing ring release of $fileName ($latestVersion)..." Write-Verbose -Message "DownloadUrl: $($iwrParams.Uri)" -Verbose Write-Verbose -Message "DownloadPath: $Path" -Verbose Write-Verbose -Message "DownloadFile: $Name" -Verbose try { + Write-Verbose -Message "Downloading $Name $latestVersion" -Verbose Invoke-WebRequest @iwrParams -ErrorAction Stop } catch { Write-Warning -Message 'Content could not be downloaded' } } else { - Write-Verbose -Message "OneDriveSetup.exe does not need to be updated. Skipping download" + Write-Verbose -Message "OneDriveSetup.exe Version: $exeVersion" -Verbose + Write-Verbose -Message "Latest Version: $latestVersion" -Verbose + Write-Verbose -Message "$Name does not need to be updated. Skipping download" -Verbose } } #=================================================================================================== From 261079b4074252e3985a7529e6188831ac9822ed Mon Sep 17 00:00:00 2001 From: Brian Kaiser Date: Fri, 18 Jun 2021 08:26:36 -0400 Subject: [PATCH 3/9] Minor changes to verbose output --- Public/Save-OSDBuilderDownload.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Public/Save-OSDBuilderDownload.ps1 b/Public/Save-OSDBuilderDownload.ps1 index 1fb0a39..5fb825d 100644 --- a/Public/Save-OSDBuilderDownload.ps1 +++ b/Public/Save-OSDBuilderDownload.ps1 @@ -270,7 +270,7 @@ function Save-OSDBuilderDownload { # CHECK IF THE ONEDRIVESETUP.EXE FILE ALREADY EXISTS if ((Test-Path -Path "$filePath") -eq $false) { - Write-Verbose -Message "$Name not found at $Path..." -Verbose + Write-Verbose -Message "$Name not found at $Path" -Verbose $exeExists = $false } else { $exeExists = $true @@ -299,9 +299,9 @@ function Save-OSDBuilderDownload { Write-Warning -Message 'Content could not be downloaded' } } else { + Write-Verbose -Message "$Name does not need to be updated. Skipping download" -Verbose Write-Verbose -Message "OneDriveSetup.exe Version: $exeVersion" -Verbose Write-Verbose -Message "Latest Version: $latestVersion" -Verbose - Write-Verbose -Message "$Name does not need to be updated. Skipping download" -Verbose } } #=================================================================================================== From a042bebbe95cb356595db09a3ebb7b42907a70e1 Mon Sep 17 00:00:00 2001 From: Brian Kaiser Date: Fri, 18 Jun 2021 10:16:35 -0400 Subject: [PATCH 4/9] Added conditional copy of OneDrive during OSBuild --- Public/New-OSBuild.ps1 | 55 ++++++++++++++---------------- Public/Save-OSDBuilderDownload.ps1 | 4 +-- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/Public/New-OSBuild.ps1 b/Public/New-OSBuild.ps1 index 5951e05..5343fb9 100644 --- a/Public/New-OSBuild.ps1 +++ b/Public/New-OSBuild.ps1 @@ -1031,40 +1031,37 @@ function New-OSBuild { #=================================================================================================== if ($OSMajorVersion -eq 10 -and $OSInstallationType -eq 'Client') { Show-ActionTime - Write-Host -ForegroundColor Green "OS: Update OneDriveSetup.exe" - $OneDriveSetupDownload = $false - $OneDriveSetup = Join-Path $GetOSDBuilderPathContentOneDrive 'OneDriveSetup.exe' - if (!(Test-Path $OneDriveSetup)) {$OneDriveSetupDownload = $true} - - if (Test-Path $OneDriveSetup) { - if (!(([System.Io.fileinfo]$OneDriveSetup).LastWriteTime.Date -ge [datetime]::Today )) { - $OneDriveSetupDownload = $true - } - } -<# if ($OneDriveSetupDownload -eq $true) { - $WebClient = New-Object System.Net.WebClient - Write-Host "Downloading to $OneDriveSetup" -ForegroundColor Gray - $WebClient.DownloadFile('https://go.microsoft.com/fwlink/p/?LinkId=248256',"$OneDriveSetup") - } #> + $OneDriveFileName = 'OneDriveSetup.exe' + Write-Host -ForegroundColor Green -Object "OS: Update $OneDriveFileName" + # SET THE SYSTEM DIRECTORY BASED ON THE ARCHITECTURE OF THE OS if ($OSArchitecture -eq 'x86') { - $OneDriveSetupInfo = Get-Item -Path "$MountDirectory\Windows\System32\OneDriveSetup.exe" | Select-Object -Property * - Write-Host -ForegroundColor Gray " Existing Image Version $($($OneDriveSetupInfo).VersionInfo.ProductVersion)" - if (Test-Path $OneDriveSetup) { - robocopy "$GetOSDBuilderPathContentOneDrive" "$MountDirectory\Windows\System32" OneDriveSetup.exe /ndl /xx /b /np /ts /tee /r:0 /w:0 /Log+:"$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-OneDriveSetup.log" | Out-Null - $OneDriveSetupInfo = Get-Item -Path "$MountDirectory\Windows\System32\OneDriveSetup.exe" | Select-Object -Property * - Write-Host -ForegroundColor Gray " Updating with Version $($($OneDriveSetupInfo).VersionInfo.ProductVersion)" - } + $SystemDirectory = "$MountDirectory\Windows\System32" } else { - $OneDriveSetupInfo = Get-Item -Path "$MountDirectory\Windows\SysWOW64\OneDriveSetup.exe" | Select-Object -Property * - Write-Host -ForegroundColor Gray " Existing Image Version $($($OneDriveSetupInfo).VersionInfo.ProductVersion)" - if (Test-Path $OneDriveSetup) { - robocopy "$GetOSDBuilderPathContentOneDrive" "$MountDirectory\Windows\SysWOW64" OneDriveSetup.exe /ndl /xx /b /np /ts /tee /r:0 /w:0 /Log+:"$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-OneDriveSetup.log" | Out-Null - $OneDriveSetupInfo = Get-Item -Path "$MountDirectory\Windows\SysWOW64\OneDriveSetup.exe" | Select-Object -Property * - Write-Host -ForegroundColor Gray " Updating with Version $($($OneDriveSetupInfo).VersionInfo.ProductVersion)" + $SystemDirectory = "$MountDirectory\Windows\SysWOW64" + } + + # CREATE THE DIRECTORY PATHS FOR THE IMAGE AND OSDBUILDER CONTENT + $OneDriveSetupImagePath = Join-Path -Path $SystemDirectory $OneDriveFileName + $OneDriveSetupPath = Join-Path -Path $GetOSDBuilderPathContentOneDrive $OneDriveFileName + + # GET THE VERSION OF ONEDRIVE FROM THE IMAGE + $OneDriveSetupImageVersion = (Get-ItemProperty -Path $OneDriveSetupImagePath).VersionInfo.ProductVersion + Write-Host -ForegroundColor Gray " Existing Image $OneDriveFileName Version $OneDriveSetupImageVersion" + + # CHECK IF ONEDRIVE IS IN THE CONTENT DIRECTORY + if (Test-Path -Path $OneDriveSetupPath) { + # GET THE VERSION OF ONEDRIVE IN THE CONTENT DIRECTORY + $OneDriveSetupVersion = (Get-ItemProperty -Path $OneDriveSetupPath).VersionInfo.ProductVersion + + # COPY ONEDRIVE FROM THE CONTENT DIRECTORY TO THE IMAGE DIRECTORY ONLY IF THE IMAGE HAS AN OLDER VERSION + if ([Version]$OneDriveSetupImageVersion -lt [Version]$OneDriveSetupVersion) { + Write-Host -ForegroundColor Gray " Updating Image with $OneDriveFileName Version $OneDriveSetupVersion" + $null = robocopy "$GetOSDBuilderPathContentOneDrive" "$SystemDirectory" $OneDriveFileName /ndl /xx /b /np /ts /tee /r:0 /w:0 /Log+:"$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-OneDriveSetup.log" } } - Write-Host -ForegroundColor Cyan " To update OneDriveSetup.exe use one of the following commands:" + + Write-Host -ForegroundColor Cyan " To update $OneDriveFileName use one of the following commands:" Write-Host -ForegroundColor Cyan " Save-OSDBuilderDownload -ContentDownload 'OneDriveSetup Enterprise'" Write-Host -ForegroundColor Cyan " Save-OSDBuilderDownload -ContentDownload 'OneDriveSetup Production'" } diff --git a/Public/Save-OSDBuilderDownload.ps1 b/Public/Save-OSDBuilderDownload.ps1 index 5fb825d..f9f7c23 100644 --- a/Public/Save-OSDBuilderDownload.ps1 +++ b/Public/Save-OSDBuilderDownload.ps1 @@ -277,10 +277,10 @@ function Save-OSDBuilderDownload { $exeOutdated = $false # GET THE VERSION NUMBER OF ONEDRIVESETUP.EXE - $exeVersion = (Get-ItemProperty -Path "$filePath" -Name VersionInfo | Select-Object -ExpandProperty VersionInfo).ProductVersion + $exeVersion = (Get-ItemProperty -Path "$filePath").VersionInfo.ProductVersion # COMPARE THE VERSION OF ONEDRIVESETUP.EXE WITH WHAT'S LISTED ONLINE - if ($exeVersion -lt $latestVersion) { + if ([Version]$exeVersion -lt [Version]$latestVersion) { Write-Verbose -Message "$Name $exeVersion is out of date. The latest version is $latestVersion..." -Verbose $exeOutdated = $true } From 34cec16c112833ebcef192bc15044515737c8bdd Mon Sep 17 00:00:00 2001 From: Brian Kaiser Date: Fri, 18 Jun 2021 10:45:09 -0400 Subject: [PATCH 5/9] Updated output for clarity --- Public/New-OSBuild.ps1 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Public/New-OSBuild.ps1 b/Public/New-OSBuild.ps1 index 5343fb9..2b11654 100644 --- a/Public/New-OSBuild.ps1 +++ b/Public/New-OSBuild.ps1 @@ -1033,6 +1033,7 @@ function New-OSBuild { Show-ActionTime $OneDriveFileName = 'OneDriveSetup.exe' Write-Host -ForegroundColor Green -Object "OS: Update $OneDriveFileName" + $indent = ' ' # 18 spaces # SET THE SYSTEM DIRECTORY BASED ON THE ARCHITECTURE OF THE OS if ($OSArchitecture -eq 'x86') { @@ -1043,27 +1044,30 @@ function New-OSBuild { # CREATE THE DIRECTORY PATHS FOR THE IMAGE AND OSDBUILDER CONTENT $OneDriveSetupImagePath = Join-Path -Path $SystemDirectory $OneDriveFileName - $OneDriveSetupPath = Join-Path -Path $GetOSDBuilderPathContentOneDrive $OneDriveFileName + $OneDriveSetupContentPath = Join-Path -Path $GetOSDBuilderPathContentOneDrive $OneDriveFileName # GET THE VERSION OF ONEDRIVE FROM THE IMAGE $OneDriveSetupImageVersion = (Get-ItemProperty -Path $OneDriveSetupImagePath).VersionInfo.ProductVersion - Write-Host -ForegroundColor Gray " Existing Image $OneDriveFileName Version $OneDriveSetupImageVersion" + Write-Host -ForegroundColor Gray -Object ($indent + "Existing Image $OneDriveFileName Version: $OneDriveSetupImageVersion") # CHECK IF ONEDRIVE IS IN THE CONTENT DIRECTORY - if (Test-Path -Path $OneDriveSetupPath) { + if (Test-Path -Path $OneDriveSetupContentPath) { # GET THE VERSION OF ONEDRIVE IN THE CONTENT DIRECTORY - $OneDriveSetupVersion = (Get-ItemProperty -Path $OneDriveSetupPath).VersionInfo.ProductVersion + $OneDriveSetupVersion = (Get-ItemProperty -Path $OneDriveSetupContentPath).VersionInfo.ProductVersion + Write-Host -ForegroundColor Gray -Object ($indent + "Existing Content $OneDriveFileName Version: $OneDriveSetupVersion") # COPY ONEDRIVE FROM THE CONTENT DIRECTORY TO THE IMAGE DIRECTORY ONLY IF THE IMAGE HAS AN OLDER VERSION if ([Version]$OneDriveSetupImageVersion -lt [Version]$OneDriveSetupVersion) { - Write-Host -ForegroundColor Gray " Updating Image with $OneDriveFileName Version $OneDriveSetupVersion" + Write-Host -ForegroundColor Gray -Object ($indent + "Updating image with $OneDriveFileName version $OneDriveSetupVersion") $null = robocopy "$GetOSDBuilderPathContentOneDrive" "$SystemDirectory" $OneDriveFileName /ndl /xx /b /np /ts /tee /r:0 /w:0 /Log+:"$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-OneDriveSetup.log" + } else { + Write-Host -ForegroundColor Gray -Object ($indent + "Content directory has an older version of $OneDriveFileName than the image. No changes to $OneDriveFileName will be made to the image") } } - Write-Host -ForegroundColor Cyan " To update $OneDriveFileName use one of the following commands:" - Write-Host -ForegroundColor Cyan " Save-OSDBuilderDownload -ContentDownload 'OneDriveSetup Enterprise'" - Write-Host -ForegroundColor Cyan " Save-OSDBuilderDownload -ContentDownload 'OneDriveSetup Production'" + Write-Host -ForegroundColor Cyan -Object ($indent + "To update the OneDrive content directory, use one of the following commands:") + Write-Host -ForegroundColor Cyan -Object ($indent + "Save-OSDBuilderDownload -ContentDownload 'OneDriveSetup Enterprise'") + Write-Host -ForegroundColor Cyan -Object ($indent + "Save-OSDBuilderDownload -ContentDownload 'OneDriveSetup Production'") } #=================================================================================================== # DismCleanupImage From 732399cf536794319c9715029b21ceacdb016a02 Mon Sep 17 00:00:00 2001 From: Brian Kaiser Date: Fri, 18 Jun 2021 11:03:48 -0400 Subject: [PATCH 6/9] Minor change to output --- Public/New-OSBuild.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Public/New-OSBuild.ps1 b/Public/New-OSBuild.ps1 index 2b11654..da9ae5e 100644 --- a/Public/New-OSBuild.ps1 +++ b/Public/New-OSBuild.ps1 @@ -1061,11 +1061,11 @@ function New-OSBuild { Write-Host -ForegroundColor Gray -Object ($indent + "Updating image with $OneDriveFileName version $OneDriveSetupVersion") $null = robocopy "$GetOSDBuilderPathContentOneDrive" "$SystemDirectory" $OneDriveFileName /ndl /xx /b /np /ts /tee /r:0 /w:0 /Log+:"$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-OneDriveSetup.log" } else { - Write-Host -ForegroundColor Gray -Object ($indent + "Content directory has an older version of $OneDriveFileName than the image. No changes to $OneDriveFileName will be made to the image") + Write-Host -ForegroundColor Gray -Object ($indent + "Content directory has an older version or the same version of $OneDriveFileName as the image. No changes to $OneDriveFileName will be made to the image") } } - Write-Host -ForegroundColor Cyan -Object ($indent + "To update the OneDrive content directory, use one of the following commands:") + Write-Host -ForegroundColor Cyan -Object ($indent + 'To update the OneDrive content directory, use one of the following commands:') Write-Host -ForegroundColor Cyan -Object ($indent + "Save-OSDBuilderDownload -ContentDownload 'OneDriveSetup Enterprise'") Write-Host -ForegroundColor Cyan -Object ($indent + "Save-OSDBuilderDownload -ContentDownload 'OneDriveSetup Production'") } From d05eb55bf5decf446794cf4de29dcd558f5ecf8a Mon Sep 17 00:00:00 2001 From: Brian Kaiser Date: Fri, 18 Jun 2021 11:05:41 -0400 Subject: [PATCH 7/9] Updated Join-Path to use Named Parameters --- Public/New-OSBuild.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Public/New-OSBuild.ps1 b/Public/New-OSBuild.ps1 index da9ae5e..450f716 100644 --- a/Public/New-OSBuild.ps1 +++ b/Public/New-OSBuild.ps1 @@ -1043,8 +1043,8 @@ function New-OSBuild { } # CREATE THE DIRECTORY PATHS FOR THE IMAGE AND OSDBUILDER CONTENT - $OneDriveSetupImagePath = Join-Path -Path $SystemDirectory $OneDriveFileName - $OneDriveSetupContentPath = Join-Path -Path $GetOSDBuilderPathContentOneDrive $OneDriveFileName + $OneDriveSetupImagePath = Join-Path -Path $SystemDirectory -ChildPath $OneDriveFileName + $OneDriveSetupContentPath = Join-Path -Path $GetOSDBuilderPathContentOneDrive -ChildPath $OneDriveFileName # GET THE VERSION OF ONEDRIVE FROM THE IMAGE $OneDriveSetupImageVersion = (Get-ItemProperty -Path $OneDriveSetupImagePath).VersionInfo.ProductVersion From b19102e496805fcff0ab2e5ee2f097f2e6ea3ccc Mon Sep 17 00:00:00 2001 From: Brian Kaiser Date: Fri, 18 Jun 2021 11:19:16 -0400 Subject: [PATCH 8/9] Minor changes to output --- Public/New-OSBuild.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Public/New-OSBuild.ps1 b/Public/New-OSBuild.ps1 index 450f716..857d0ab 100644 --- a/Public/New-OSBuild.ps1 +++ b/Public/New-OSBuild.ps1 @@ -1061,7 +1061,8 @@ function New-OSBuild { Write-Host -ForegroundColor Gray -Object ($indent + "Updating image with $OneDriveFileName version $OneDriveSetupVersion") $null = robocopy "$GetOSDBuilderPathContentOneDrive" "$SystemDirectory" $OneDriveFileName /ndl /xx /b /np /ts /tee /r:0 /w:0 /Log+:"$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-OneDriveSetup.log" } else { - Write-Host -ForegroundColor Gray -Object ($indent + "Content directory has an older version or the same version of $OneDriveFileName as the image. No changes to $OneDriveFileName will be made to the image") + Write-Host -ForegroundColor Gray -Object ($indent + "The version of $OneDriveFileName in the image is newer than the version in the OSDBuilder OneDrive content directory") + Write-Host -ForegroundColor Gray -Object ($indent + "No changes to $OneDriveFileName will be made to the image") } } From 96be4135921aa7b39751fe67985c5249a8c566f7 Mon Sep 17 00:00:00 2001 From: Brian Kaiser Date: Fri, 18 Jun 2021 11:25:40 -0400 Subject: [PATCH 9/9] Minor changes to output --- Public/New-OSBuild.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Public/New-OSBuild.ps1 b/Public/New-OSBuild.ps1 index 857d0ab..8558b5f 100644 --- a/Public/New-OSBuild.ps1 +++ b/Public/New-OSBuild.ps1 @@ -1048,20 +1048,20 @@ function New-OSBuild { # GET THE VERSION OF ONEDRIVE FROM THE IMAGE $OneDriveSetupImageVersion = (Get-ItemProperty -Path $OneDriveSetupImagePath).VersionInfo.ProductVersion - Write-Host -ForegroundColor Gray -Object ($indent + "Existing Image $OneDriveFileName Version: $OneDriveSetupImageVersion") + Write-Host -ForegroundColor Gray -Object ($indent + "Image $OneDriveFileName Version: $OneDriveSetupImageVersion") # CHECK IF ONEDRIVE IS IN THE CONTENT DIRECTORY if (Test-Path -Path $OneDriveSetupContentPath) { # GET THE VERSION OF ONEDRIVE IN THE CONTENT DIRECTORY $OneDriveSetupVersion = (Get-ItemProperty -Path $OneDriveSetupContentPath).VersionInfo.ProductVersion - Write-Host -ForegroundColor Gray -Object ($indent + "Existing Content $OneDriveFileName Version: $OneDriveSetupVersion") + Write-Host -ForegroundColor Gray -Object ($indent + "Content $OneDriveFileName Version: $OneDriveSetupVersion") # COPY ONEDRIVE FROM THE CONTENT DIRECTORY TO THE IMAGE DIRECTORY ONLY IF THE IMAGE HAS AN OLDER VERSION if ([Version]$OneDriveSetupImageVersion -lt [Version]$OneDriveSetupVersion) { - Write-Host -ForegroundColor Gray -Object ($indent + "Updating image with $OneDriveFileName version $OneDriveSetupVersion") + Write-Host -ForegroundColor Gray -Object ($indent + "Updating the image with $OneDriveFileName version $OneDriveSetupVersion") $null = robocopy "$GetOSDBuilderPathContentOneDrive" "$SystemDirectory" $OneDriveFileName /ndl /xx /b /np /ts /tee /r:0 /w:0 /Log+:"$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-OneDriveSetup.log" } else { - Write-Host -ForegroundColor Gray -Object ($indent + "The version of $OneDriveFileName in the image is newer than the version in the OSDBuilder OneDrive content directory") + Write-Host -ForegroundColor Gray -Object ($indent + "The version of $OneDriveFileName in the content directory is not newer than the image") Write-Host -ForegroundColor Gray -Object ($indent + "No changes to $OneDriveFileName will be made to the image") } }