OfficeDev / Office-IT-Pro-Deployment-Scripts

A collection of useful PowerShell scripts to make deploying Office 2016 and Office 365 ProPlus easier for IT Pros and administrators. If you have any feature requests or ideas for future scripts please add the idea to the issues list in this repository
http://officedev.github.io/Office-IT-Pro-Deployment-Scripts
MIT License
887 stars 841 forks source link

Get-ChannelXml() causes throw if ofl.cab is not already in place #255

Closed BigSteef closed 7 years ago

BigSteef commented 7 years ago

when you download the scripts, ofl.cab is not already in place and get-channelxml checks to see if its there and attempts to download it.

problem is if it finds its not there: if (Test-Path -Path $XMLFilePath) {

it causes a throw

throw "File missing $FolderPath\ofl.cab"

which stops it getting to the next part of the function which downloads the file:

if ($downloadFile) { $webclient = New-Object System.Net.WebClient $XMLFilePath = "$env:TEMP/ofl.cab" $XMLDownloadURL = "http://officecdn.microsoft.com/pr/wsus/ofl.cab" $webclient.DownloadFile($XMLDownloadURL,$XMLFilePath)

       if ($FolderPath) {
         [System.IO.Directory]::CreateDirectory($FolderPath) | Out-Null
         $targetFile = "$FolderPath\ofl.cab"
         Copy-Item -Path $XMLFilePath -Destination $targetFile -Force
       }
AStigall commented 7 years ago

@BigSteef Which script are using that is causing this error?

AStigall commented 7 years ago

@BigSteef I think I see what you are talking about. This error will be thrown if $OverWrite is set to $false and you specify $Folderpath, and the ofl.cab does not exist in the $FolderPath. This behavior is expected.

If you are not specifying any of the parameters and an error is still being thrown then we would need to see what is going on in that script. Please let us know which script is throwing the error in this scenario.