Hi Spicies,<\/p>\n
Been a while since i’ve posted but I have a little annoying issue with a script I had been using for years now that started failing few months back, I haven’t spent much time looking into it and I’m by no means a Powershell Guru and was wondering if anyone could point to the right direction.
\nThe script is to automatically proceed with a Windows 10 Feature upgrade. We were using it everytime we onboarded new clients who would have workstations with w10 versions older than 1903 as Feature upgrades weren’t part of WUS before then.
\nThe script seems to fail at the download portion and it skips quickly to the install portion, which ultimately fail because the file does not exist.
\nAnyone can see why this script wouldn’t work anymore?
\nThanks! <\/p>\n
#================================================================================\n# Configuration\n#================================================================================\n \n# Application name (this will be used to check if application already installed)\n$name = \"Windows 10\"\n \n# Download URL (redirects will be followed)\n$dlurl = 'https://go.microsoft.com/fwlink/?LinkID=799445'\n \n# Installer filename (can be blank if download isn't a zip, wildcards allowed)\n$installer = \"Windows10Upgrade*.exe\"\n \n# Arguments to use for installer (can be blank)\n$arg = \"/QuietInstall /SkipEULA /SkipSelfUpdate\"\n \n# Disk space required in MB (leave blank for no requirement)\n$diskspacerequired = '11000'\n \n# Temporary storage location (no trailing \\)\n$homepath = \"c:\\Windows\\Temp\"\n \n#================================================================================\n# Shouldn't need to edit anything below this line\n#================================================================================\n \nWrite-Output \"$name installation starting...\"\n \nWrite-Output \"Checking disk space...\"\n$disk = Get-WmiObject Win32_LogicalDisk -Filter \"DeviceID='$env:SystemDrive'\" | Select-Object FreeSpace\n$disk = ([Math]::Round($Disk.Freespace / 1MB))\nif ($disk -lt $diskspacerequired) {\n write-output \"$name requires $diskspacerequired MB to install but there's only $disk MB free.\"\n exit\n}\n \n# Test for home directory and create if it doesn't exist\nif (-not (Test-Path $homepath)) { mkdir $homepath | Out-Null }\nSet-Location $homepath\n \n# Retrieve headers to make sure we have the final destination redirected file URL\n$dlurl = (Invoke-WebRequest -UseBasicParsing -Uri $dlurl -MaximumRedirection 0 -ErrorAction Ignore).headers.location\nWrite-Output \"Downloading: $dlurl\"\n$dlfilename = [io.path]::GetFileName(\"$dlurl\")\n(New-Object Net.WebClient).DownloadFile(\"$dlurl\", \"$homepath\\$dlfilename\")\n \n# Use GCI to determine filename in case wildcards are used\n$installer = (Get-ChildItem $installer).Name\nWrite-Output \"Installing: $homepath\\$installer $arg\"\nStart-Process \"$installer\" -ArgumentList \"$arg\"\n \nWrite-Output \"Cleaning up...\"\nStart-Sleep -s 60\nRemove-Item $installer -Force\n<\/code><\/pre>","upvoteCount":7,"answerCount":3,"datePublished":"2023-09-14T23:10:13.000Z","author":{"@type":"Person","name":"mathieucohen","url":"https://community.spiceworks.com/u/mathieucohen"},"suggestedAnswer":[{"@type":"Answer","text":"
Advertisement
Hi Spicies,<\/p>\n
Been a while since i’ve posted but I have a little annoying issue with a script I had been using for years now that started failing few months back, I haven’t spent much time looking into it and I’m by no means a Powershell Guru and was wondering if anyone could point to the right direction.
\nThe script is to automatically proceed with a Windows 10 Feature upgrade. We were using it everytime we onboarded new clients who would have workstations with w10 versions older than 1903 as Feature upgrades weren’t part of WUS before then.
\nThe script seems to fail at the download portion and it skips quickly to the install portion, which ultimately fail because the file does not exist.
\nAnyone can see why this script wouldn’t work anymore?
\nThanks!
<\/p>\n
#================================================================================\n# Configuration\n#================================================================================\n \n# Application name (this will be used to check if application already installed)\n$name = \"Windows 10\"\n \n# Download URL (redirects will be followed)\n$dlurl = 'https://go.microsoft.com/fwlink/?LinkID=799445'\n \n# Installer filename (can be blank if download isn't a zip, wildcards allowed)\n$installer = \"Windows10Upgrade*.exe\"\n \n# Arguments to use for installer (can be blank)\n$arg = \"/QuietInstall /SkipEULA /SkipSelfUpdate\"\n \n# Disk space required in MB (leave blank for no requirement)\n$diskspacerequired = '11000'\n \n# Temporary storage location (no trailing \\)\n$homepath = \"c:\\Windows\\Temp\"\n \n#================================================================================\n# Shouldn't need to edit anything below this line\n#================================================================================\n \nWrite-Output \"$name installation starting...\"\n \nWrite-Output \"Checking disk space...\"\n$disk = Get-WmiObject Win32_LogicalDisk -Filter \"DeviceID='$env:SystemDrive'\" | Select-Object FreeSpace\n$disk = ([Math]::Round($Disk.Freespace / 1MB))\nif ($disk -lt $diskspacerequired) {\n write-output \"$name requires $diskspacerequired MB to install but there's only $disk MB free.\"\n exit\n}\n \n# Test for home directory and create if it doesn't exist\nif (-not (Test-Path $homepath)) { mkdir $homepath | Out-Null }\nSet-Location $homepath\n \n# Retrieve headers to make sure we have the final destination redirected file URL\n$dlurl = (Invoke-WebRequest -UseBasicParsing -Uri $dlurl -MaximumRedirection 0 -ErrorAction Ignore).headers.location\nWrite-Output \"Downloading: $dlurl\"\n$dlfilename = [io.path]::GetFileName(\"$dlurl\")\n(New-Object Net.WebClient).DownloadFile(\"$dlurl\", \"$homepath\\$dlfilename\")\n \n# Use GCI to determine filename in case wildcards are used\n$installer = (Get-ChildItem $installer).Name\nWrite-Output \"Installing: $homepath\\$installer $arg\"\nStart-Process \"$installer\" -ArgumentList \"$arg\"\n \nWrite-Output \"Cleaning up...\"\nStart-Sleep -s 60\nRemove-Item $installer -Force\n<\/code><\/pre>","upvoteCount":7,"datePublished":"2023-09-14T23:10:14.000Z","url":"https://community.spiceworks.com/t/windows-10-feature-upgrade-powershell-not-working-anymore/959120/1","author":{"@type":"Person","name":"mathieucohen","url":"https://community.spiceworks.com/u/mathieucohen"}},{"@type":"Answer","text":"It downloads for me just fine.<\/p>\n
What is the error message? You can add transcript logging to see what the error says<\/p>\n
Start-Transcript -Path \"c:\\windows\\temp\\logfile.txt\n# your code\nStop-Transcript\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2023-09-14T23:15:12.000Z","url":"https://community.spiceworks.com/t/windows-10-feature-upgrade-powershell-not-working-anymore/959120/2","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},{"@type":"Answer","text":"How are you running the script ? via GPO at user per profile or GPO at per machine profile ?<\/p>","upvoteCount":0,"datePublished":"2023-09-15T05:00:41.000Z","url":"https://community.spiceworks.com/t/windows-10-feature-upgrade-powershell-not-working-anymore/959120/3","author":{"@type":"Person","name":"adrian_ych","url":"https://community.spiceworks.com/u/adrian_ych"}}]}}