PowerShell Scripting - Create USB Install Media for Windows 10  

Page 2 of 3 FirstFirst 123 LastLast
  1. Kari's Avatar
    Posts : 15,373
    Windows 10 Pro
    Thread Starter
       25 Oct 2017 #10

    HippsieGypsie said: View Post
    Made my install thumb with your script provided in step 1 and followed the tutorial section to the tee. Before starting I quick formatted it with default settings. Ran the script and all went well, but it doesn't show up in FE and when I open Disk Management it asked to initialize it as seen below. Is that normal? If so, initialize it as GPT, yes?
    No, that is not correct. The USB flash drive should be partitioned, and all well and shown in Explorer and Disk Management with a drive ID letter. MBR or GPT is irrelevant but it should have been partitioned.

    Initialize it, GPT is OK and run the script again to test.

    I have to go out now, have a doc appointment. I'll check what's going on when back home.
    Last edited by Kari; 25 Oct 2017 at 02:56.
      My ComputerSystem Spec


  2. Posts : 7,567
    Dual boot Windows 10 FCU Pro x 64 & current Insider 10 Pro
       25 Oct 2017 #11

    @Kari

    Been attempting to get this to work without success for too long. Time to ask for help.

    Info: Performing this on my Asus tower in FCU with a SanDisk 8GB thumb using PS ISE Admin opening a saved script titled ďCreate Bootable ISO Thumb(.ps1)Ē which is stored on my secondary D: drive. Mounting ISOs made from WTC and UUPtoISO that are also stored on my D: drive mounting on virtual drive. Directing script to the correct virtual drive.

    Each time the script runs for less than a minute, hence my previous joke about java and shot. Iíll assume thatís not normal, for Iíve created ISO thumbs before using Rufus, which takes much longer.

    I actually ran the script more times using different scenarios, but here are the highlights.

    Run 1: I initialized the disk GPT as instructed above and ran the script > No go. The disk is then not seen in FE and not initialized upon opening Disk Management (DM) again.

    Run 2: I initialized as GPT and formatted this time. After running it did not de-initialized the disk, but still empty. I took shots of PS script running. Here are a few. one from early on and one from the end. Something is not correct there > Network path not found.

    Attachment 160188

    Attachment 160189

    Run 3: Reformatted as MBR and ran script. No go.

    Closed everything out and rebooted.

    Run 4: Iíve run some of your prior saved scripts from D: with success, so I donít think itís that, but instead of using my stored ďCreate Bootable ISO ThumbĒ, this time I copied and pasted the script directly into PS ISE. Didnít catch the first part, but this is seen throughout the latter part of the run. It has a little different results, but same error.

    Attachment 160190

    The thumb drive remains empty. Any clue as to why?
      My ComputersSystem Spec

  3. Kari's Avatar
    Posts : 15,373
    Windows 10 Pro
    Thread Starter
       25 Oct 2017 #12

    HippsieGypsie said: View Post
    The thumb drive remains empty. Any clue as to why?
    Logically thinking it can only be a defect USB drive, missing code caused by an error in Copy & Paste or permissions issue. The error messages in your first screenshot are all about path / file not found or existing when saving to USB.

    Do you have another USB drive to test?
      My ComputerSystem Spec


  4. Posts : 7,567
    Dual boot Windows 10 FCU Pro x 64 & current Insider 10 Pro
       25 Oct 2017 #13

    Kari said: View Post
    Logically thinking it can only be a defect USB drive, missing code caused by an error in Copy & Paste or permissions issue. The error messages in your first screenshot are all about path / file not found or existing when saving to USB.

    Do you have another USB drive to test?
    Ok. I see. Yes, I have another. Thanks, Kari.
      My ComputersSystem Spec

  5. Kari's Avatar
    Posts : 15,373
    Windows 10 Pro
    Thread Starter
       25 Oct 2017 #14

    HippsieGypsie said: View Post
    Ok. I see. Yes, I have another. Thanks, Kari.
    Copy & paste mistakes can be excluded, I think, because according to your error messages the errors occur in cmdlet Copy-Item $File.fullname ($USBDrive + $RelativePath) in line 184; I just checked and that cmdlet is line 184 in original code
      My ComputerSystem Spec


  6. Posts : 7,567
    Dual boot Windows 10 FCU Pro x 64 & current Insider 10 Pro
       25 Oct 2017 #15

    Yes, odds are that I could not error in that twice, for I C&Ped it once to save as ps1 file and then C&Ped again right into PS. It isn't the script. It's got to be the drive as you say.

    17025 has been released. My Asus Insider is almost finished updating and I'll get back to this. It's going quite fast. :)
      My ComputersSystem Spec


  7. Posts : 7,567
    Dual boot Windows 10 FCU Pro x 64 & current Insider 10 Pro
       26 Oct 2017 #16

    Finally got to this. Used another thumb and did indeed work with time for java and shot.

    Thing is, this is an older PNY 8GB thumb. I burn ISOs on the SanDisk thumb with Rufus all the time. Don't understand why SanDisk didn't work.

    Edit:

    Just burned my UUPtoISO 17025.1000 to the SanDisk to make sure the thumb is ok and to have it.

    Used PS with same 17025 to make another PNY thumb for my 2nd partition install. All went well.
    Last edited by Tony K; 26 Oct 2017 at 02:50.
      My ComputersSystem Spec

  8. Kari's Avatar
    Posts : 15,373
    Windows 10 Pro
    Thread Starter
       26 Oct 2017 #17

    HippsieGypsie said: View Post
    Finally got to this. Used another thumb and did indeed work with time for java and shot.

    Thing is, this is an older PNY 8GB thumb. I burn ISOs on the SanDisk thumb with Rufus all the time. Don't understand why SanDisk didn't work.
    Can't explain why that SanDisk drive works with Rufus but not from PowerShell script. Anyway, good to know you got it working.
      My ComputerSystem Spec


  9. Posts : 7,567
    Dual boot Windows 10 FCU Pro x 64 & current Insider 10 Pro
       26 Oct 2017 #18

    Kari said: View Post
    Can't explain why that SanDisk drive works with Rufus but not from PowerShell script.
    I swear there's a wormhole somewhere in computer tech that we just can't see. Like quantum physics, the most brilliant in the field don't fully understands it.

    Anyway, good to know you got it working.
    No, my friend. Good to know you got it working with your direction. Thanks. One thing I know is that doing something over and over again getting the same ill results is true insanity.
      My ComputersSystem Spec


  10. Posts : 33
    Windows 10 Pro for Workstations
       14 Aug 2018 #19

    You spent way too much time trying to make every safety-net as possible (will get back to this), and instead are offering a "tutorial" of some fairly dreadful code.

    You should be working with mostly objects for disk structuring and not user input and using the same cmdlet class throughout the processes.

    You have none of this "error-handling" you went on about in case the WIM file was too big for the FAT32 filesystem (4GB), where you could easily add a process to split the WIM to SWM before creating the directory tree on the USB and copying over the ISO content.

    Why do you have 6 lines of "-or" code of this script testing the path for install images when there's the -Include parameter available on the Get-ChildItems cmdlet that is designed specifically for this?

    You have a picture telling people to not click the format button when the GUI screen pops up. Well, that's why you do not let that screen pop up, and you do that by writing proper code. You should not be assigning a drive letter using the New-Partition cmdlet for scripts like this, anyways. Instead you pipe the partition object to the Add-PartitionAccessPath cmdlet with the -AssignDriveLetter, wherein no GUI output is displayed and the access paths become objects themselves. This is the only way to do any sort of disk imaging in a reliable way:

    $Partition = New-Partition -DiskNumber $Disk.Number -Size 32GB
    $Format = Format-Volume -Partition $Partition -FileSystem FAT32 -Force -Confirm:$false
    $Partition | Add-PartitionAccessPath -AssignDriveLetter
    $Drive = ($Disk | Get-Partition).AccessPath[0]

    Instead you have this, which is completely unnecessary.

    $USBDrive = Get-WmiObject Win32_Volume -Filter "DriveType='2'"
    $USBDrive = $USBDrive.DriveLetter
    Format-Volume -NewFileSystemLabel "W10 USB" -FileSystem FAT32 -DriveLetter $USBDrive.Trim(":", " ")

    Again with all this coloring and questions...why not utilize the actual features PowerShell has like ConfirmImpact and SupportsShouldProcess, thus requiring input based on how high the impact of the command may make on a device?

    This script has zero error-handling other than total reliance of the end-user, which PowerShell scripts (and C#, Java, etc.) are not designed for. That's because these wonderful languages have a plethora of ways to do proper error-handling using only the objects that are created and utilized within the script itself.

    I've looked at some of your other scripts a few minutes ago and they're all the same, too. If I uploaded a script like this to any of the coding repositories I put some of my actual projects on, they'd be removed the same hour I uploaded them.
      My ComputersSystem Spec


 
Page 2 of 3 FirstFirst 123 LastLast

Tutorial Categories

PowerShell Scripting - Create USB Install Media for Windows 10 Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


Related Threads
Installing Windows 10 is done in three phases: Boot from install media, run Windows Setup Configure hardware devices Windows Welcome (OOBE) In normal install, user interaction is required in phases 1 and 3, phase 2 being run automatically...
A few weeks after release of Windows 10 version 1703 (Creators Update), Microsoft in April 2017 officially announced that Windows in the future will get biannual feature upgrades: Read more: Windows and Office align feature release schedules...
One of many PowerShell security features is that you can't run a script simply by double clicking it's icon on desktop or in a folder. Doing so will by default open script in Notepad for editing instead. You can right click script and select Run...
General Tips PowerShell Scripting - The Basics in Tutorials
A PowerShell script is a collection of commands and cmdlets to be run in logical order, previous lines in script determining values and variables in command lines thereafter. The principle is the same than in Command Prompt batch files (.bat or...
Hi all. I'm trying to use powershell to create a complex storage space on my 4x6TB HD. I want to make the first 4TB of each HD in simple pool and the remaining space 2TB with Mirror 2way. 4x4TB Simple 4x2TB Mirror 2Way This way should be...
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 16:30.
Find Us