Problem creating GPT VHD automatically

Page 3 of 4 FirstFirst 1234 LastLast

  1. Posts : 13,561
    Windows10
    Thread Starter
       #21

    hsehestedt said:
    Fantastic. Thanks!
    These may be of use

    Code:
    FeatureName : Printing-PrintToPDFServices-Features
    State       : Enabled
    FeatureName : Printing-XPSServices-Features
    State       : Enabled
    FeatureName : SearchEngine-Client-Package
    State       : Enabled
    FeatureName : MSRDC-Infrastructure
    State       : Enabled
    FeatureName : TelnetClient
    State       : Disabled
    FeatureName : TFTP
    State       : Disabled
    FeatureName : TIFFIFilter
    State       : Disabled
    FeatureName : LegacyComponents
    State       : Disabled
    FeatureName : DirectPlay
    State       : Disabled
    FeatureName : Printing-Foundation-Features
    State       : Enabled
    FeatureName : Printing-Foundation-InternetPrinting-Client
    State       : Enabled
    FeatureName : Printing-Foundation-LPDPrintService
    State       : Disabled
    FeatureName : Printing-Foundation-LPRPortMonitor
    State       : Disabled
    FeatureName : SimpleTCP
    State       : Disabled
    FeatureName : MicrosoftWindowsPowerShellV2Root
    State       : Enabled
    FeatureName : MicrosoftWindowsPowerShellV2
    State       : Enabled
    FeatureName : Windows-Identity-Foundation
    State       : Disabled
    FeatureName : Client-ProjFS
    State       : Disabled
    FeatureName : NetFx4-AdvSrvs
    State       : Enabled
    FeatureName : NetFx4Extended-ASPNET45
    State       : Disabled
    FeatureName : WCF-Services45
    State       : Enabled
    FeatureName : WCF-HTTP-Activation45
    State       : Disabled
    FeatureName : WCF-TCP-Activation45
    State       : Disabled
    FeatureName : WCF-Pipe-Activation45
    State       : Disabled
    FeatureName : WCF-MSMQ-Activation45
    State       : Disabled
    FeatureName : WCF-TCP-PortSharing45
    State       : Enabled
    FeatureName : IIS-WebServerRole
    State       : Disabled
    FeatureName : IIS-WebServer
    State       : Disabled
    FeatureName : IIS-CommonHttpFeatures
    State       : Disabled
    FeatureName : IIS-HttpErrors
    State       : Disabled
    FeatureName : IIS-HttpRedirect
    State       : Disabled
    FeatureName : IIS-ApplicationDevelopment
    State       : Disabled
    FeatureName : IIS-NetFxExtensibility
    State       : Disabled
    FeatureName : IIS-NetFxExtensibility45
    State       : Disabled
    FeatureName : IIS-HealthAndDiagnostics
    State       : Disabled
    FeatureName : IIS-HttpLogging
    State       : Disabled
    FeatureName : IIS-LoggingLibraries
    State       : Disabled
    FeatureName : IIS-RequestMonitor
    State       : Disabled
    FeatureName : IIS-HttpTracing
    State       : Disabled
    FeatureName : IIS-Security
    State       : Disabled
    FeatureName : IIS-URLAuthorization
    State       : Disabled
    FeatureName : IIS-RequestFiltering
    State       : Disabled
    FeatureName : IIS-IPSecurity
    State       : Disabled
    FeatureName : IIS-Performance
    State       : Disabled
    FeatureName : IIS-HttpCompressionDynamic
    State       : Disabled
    FeatureName : IIS-WebServerManagementTools
    State       : Disabled
    FeatureName : IIS-ManagementScriptingTools
    State       : Disabled
    FeatureName : IIS-IIS6ManagementCompatibility
    State       : Disabled
    FeatureName : IIS-Metabase
    State       : Disabled
    FeatureName : WAS-WindowsActivationService
    State       : Disabled
    FeatureName : WAS-ProcessModel
    State       : Disabled
    FeatureName : WAS-NetFxEnvironment
    State       : Disabled
    FeatureName : WAS-ConfigurationAPI
    State       : Disabled
    FeatureName : IIS-HostableWebCore
    State       : Disabled
    FeatureName : WCF-HTTP-Activation
    State       : Disabled
    FeatureName : WCF-NonHTTP-Activation
    State       : Disabled
    FeatureName : IIS-StaticContent
    State       : Disabled
    FeatureName : IIS-DefaultDocument
    State       : Disabled
    FeatureName : IIS-DirectoryBrowsing
    State       : Disabled
    FeatureName : IIS-WebDAV
    State       : Disabled
    FeatureName : IIS-WebSockets
    State       : Disabled
    FeatureName : IIS-ApplicationInit
    State       : Disabled
    FeatureName : IIS-ASPNET
    State       : Disabled
    FeatureName : IIS-ASPNET45
    State       : Disabled
    FeatureName : IIS-ASP
    State       : Disabled
    FeatureName : IIS-CGI
    State       : Disabled
    FeatureName : IIS-ISAPIExtensions
    State       : Disabled
    FeatureName : IIS-ISAPIFilter
    State       : Disabled
    FeatureName : IIS-ServerSideIncludes
    State       : Disabled
    FeatureName : IIS-CustomLogging
    State       : Disabled
    FeatureName : IIS-BasicAuthentication
    State       : Disabled
    FeatureName : IIS-HttpCompressionStatic
    State       : Disabled
    FeatureName : IIS-ManagementConsole
    State       : Disabled
    FeatureName : IIS-ManagementService
    State       : Disabled
    FeatureName : IIS-WMICompatibility
    State       : Disabled
    FeatureName : IIS-LegacyScripts
    State       : Disabled
    FeatureName : IIS-LegacySnapIn
    State       : Disabled
    FeatureName : IIS-FTPServer
    State       : Disabled
    FeatureName : IIS-FTPSvc
    State       : Disabled
    FeatureName : IIS-FTPExtensibility
    State       : Disabled
    FeatureName : MSMQ-Container
    State       : Enabled
    FeatureName : MSMQ-DCOMProxy
    State       : Disabled
    FeatureName : MSMQ-Server
    State       : Enabled
    FeatureName : MSMQ-ADIntegration
    State       : Disabled
    FeatureName : MSMQ-HTTP
    State       : Disabled
    FeatureName : MSMQ-Multicast
    State       : Disabled
    FeatureName : MSMQ-Triggers
    State       : Disabled
    FeatureName : IIS-CertProvider
    State       : Disabled
    FeatureName : IIS-WindowsAuthentication
    State       : Disabled
    FeatureName : IIS-DigestAuthentication
    State       : Disabled
    FeatureName : IIS-ClientCertificateMappingAuthentication
    State       : Disabled
    FeatureName : IIS-IISCertificateMappingAuthentication
    State       : Disabled
    FeatureName : IIS-ODBCLogging
    State       : Disabled
    FeatureName : NetFx3
    State       : DisabledWithPayloadRemoved
    FeatureName : SMB1Protocol-Deprecation
    State       : Disabled
    FeatureName : MediaPlayback
    State       : Enabled
    FeatureName : WindowsMediaPlayer
    State       : Enabled
    FeatureName : DataCenterBridging
    State       : Disabled
    FeatureName : ServicesForNFS-ClientOnly
    State       : Disabled
    FeatureName : ClientForNFS-Infrastructure
    State       : Disabled
    FeatureName : NFS-Administration
    State       : Disabled
    FeatureName : SmbDirect
    State       : Enabled
    FeatureName : HostGuardian
    State       : Disabled
    FeatureName : MultiPoint-Connector
    State       : Disabled
    FeatureName : MultiPoint-Connector-Services
    State       : Disabled
    FeatureName : MultiPoint-Tools
    State       : Disabled
    FeatureName : AppServerClient
    State       : Disabled
    FeatureName : DirectoryServices-ADAM-Client
    State       : Disabled
    FeatureName : Client-EmbeddedBootExp
    State       : Disabled
    FeatureName : Client-EmbeddedLogon
    State       : Disabled
    FeatureName : Client-KeyboardFilter
    State       : Disabled
    FeatureName : Client-UnifiedWriteFilter
    State       : Disabled
    FeatureName : Windows-Defender-Default-Definitions
    State       : Disabled
    FeatureName : WorkFolders-Client
    State       : Enabled
    FeatureName : SMB1Protocol
    State       : Enabled
    FeatureName : SMB1Protocol-Client
    State       : Enabled
    FeatureName : SMB1Protocol-Server
    State       : Disabled
    FeatureName : Microsoft-Windows-Subsystem-Linux
    State       : Disabled
    FeatureName : HypervisorPlatform
    State       : Enabled
    FeatureName : VirtualMachinePlatform
    State       : Disabled
    FeatureName : Containers-DisposableClientVM
    State       : Disabled
    FeatureName : Microsoft-Hyper-V-All
    State       : Enabled
    FeatureName : Microsoft-Hyper-V
    State       : Enabled
    FeatureName : Microsoft-Hyper-V-Tools-All
    State       : Enabled
    FeatureName : Microsoft-Hyper-V-Management-PowerShell
    State       : Enabled
    FeatureName : Microsoft-Hyper-V-Hypervisor
    State       : Enabled
    FeatureName : Microsoft-Hyper-V-Services
    State       : Enabled
    FeatureName : Microsoft-Hyper-V-Management-Clients
    State       : Enabled
    FeatureName : Client-DeviceLockdown
    State       : Disabled
    FeatureName : Client-EmbeddedShellLauncher
    State       : Disabled
    FeatureName : Windows-Defender-ApplicationGuard
    State       : Disabled
    FeatureName : Containers
    State       : Disabled
    Last edited by Barman58; 16 Jul 2020 at 14:32.
      My Computer


  2. Posts : 2,768
    Windows 11 Pro, 21H2
       #22

    Thanks, Cereberus.
      My Computers


  3. Posts : 13,561
    Windows10
    Thread Starter
       #23

    Kari said:
    @Martin, I would appreciate if you could test this PowerShell script of mine:

    Download

    Reading it in OneDrive, all remarks and comments are clearly shown as green. I recommend reading all remarks. Most important thing is variables in lines 78 to 80:

    Attachment 288103

    In lines 209 to 222, you tell the script which Windows optional features will be added to Windows image and VHD:

    Attachment 288104

    Please test the script and tell me what you think about it. Download the script, unblock it (important!), right click it, and select Run with PowerShell.

    Kari
    I have run into some issues as it kerps complaining about some command not having recurse option. Not at pc yest but problem arose after I stopped the script as I had to reboot pc due to an unrelates issue.

    I will post some error message later.
    I think it is related to temporary files not being cleaned up or stale mountpoints.

    From a general viewpoint, it needs to be a little more flexible.

    I think you need to modify the driver section.

    Currently, it backups up all user drivers and injects them which takes time and can be overkill.
    .

    You should be able to configure a default driver directory and choose to use that, or just use host drivers as it does at moment.

    There are times I do not want to inject host drivers e.g. I intend to use vhd on a different pc eventually.

    Not clear if vhdx is expandable or fixed. This should be configurable.

    With a little extra effort, you can set it up to install in S mode. See my command script. This would be handy do you could have a guest VHD more locked down.

    Also, when you create a boot entry for the vhd, it becomes the default boot option. You should not change the default option from Host unless user choose to do so. Currently you have to run MSConfig afterwards to reset it.

    On a more basic level, I would not expect a user to copy install.wim to a default directory.

    Most users would just have an iso which could have install.wim or install.esd.

    I would just tell users to mount an iso and specify directory. Thereafter the script copies install.wim or install.esd (converting it if necessary to install.wim).

    I do not know if you could automate this e.g. configure iso path and name and mount it.

    You could configure it to use install.wim as it does now as an option.

    All temporary folders should be on same drive as the one creating VHD by default. I am thinking about pcs with limited space on Physical drive with C partition.


    Optional future development - having gone through effort to create a vhd injecting drivers, I think you should allow user to create an iso bit that does require adk to be installed. I have no idea of this can be script automated.

    Another optional feature would be to crrate a dual boot pc without using a vhd but this would need some unallocated space and probably only for UEFI pcs.

    This would be handy for users who want to say put an Insider version and dual boot it. The problem as you know, is yiu cannot upgrade vhds without resorting to using a VM to do the upgrade - fairly easy for Pro users with HyperV , less so for Home users.

    Overall, it has the makings of a great tool but I feel it needs a bit of work to make it really useful.

    As an aside, my command prompt script does most of this now, so maybe publish both as mot all users are powershell experienced.
      My Computer


  4. Posts : 17,636
    Windows 10 Pro
       #24

    Thanks Martin, seems I need to work more with the script.

    About the drivers, yes I think it would be better to offer three option: add all host drivers, add user specified drivers from user specified folder, or add no drivers.

    The recurse error should not happen. For instance the drivers folder, it will be created in Temp:

    $DriverFolder = Join-Path $env:Temp '\Drivers'

    Then when user is asked if drivers should be added, script checks if the folder exists, and if yes, deletes it and with -Recurse parameter all files in it, then recreates an empty folder for exported drivers:

    Code:
    $AddDrivers = Read-Host -Prompt ' Do you want to add host device drivers to Windows image (Y or N)?'
    
        if (($AddDrivers -match 'Y') -or ($AddDrivers -match 'y'))
                {
                if (Test-Path $DriverFolder) {Remove-Item $DriverFolder -Recurse}
                $DriverFolder = New-Item -ItemType Directory -Path $DriverFolder

    Anyway, this is an interesting project. Thanks for your thoughts, I will continue working on it.

    Kari
      My Computer


  5. Posts : 13,561
    Windows10
    Thread Starter
       #25

    Kari said:
    Thanks Martin, seems I need to work more with the script.

    About the drivers, yes I think it would be better to offer three option: add all host drivers, add user specified drivers from user specified folder, or add no drivers.

    The recurse error should not happen. For instance the drivers folder, it will be created in Temp:

    $DriverFolder = Join-Path $env:Temp '\Drivers'

    Then when user is asked if drivers should be added, script checks if the folder exists, and if yes, deletes it and with -Recurse parameter all files in it, then recreates an empty folder for exported drivers:

    Code:
    $AddDrivers = Read-Host -Prompt ' Do you want to add host device drivers to Windows image (Y or N)?'
    
        if (($AddDrivers -match 'Y') -or ($AddDrivers -match 'y'))
                {
                if (Test-Path $DriverFolder) {Remove-Item $DriverFolder -Recurse}
                $DriverFolder = New-Item -ItemType Directory -Path $DriverFolder

    Anyway, this is an interesting project. Thanks for your thoughts, I will continue working on it.

    Kari
    Something has glitched. It happened after I interrupted a job part way through. I am guessing things did not cleanup.

    I suggest you cleanup first (just in case), do job, cleanup again.
      My Computer


  6. Posts : 13,561
    Windows10
    Thread Starter
       #26

    cereberus said:
    Something has glitched. It happened after I interrupted a job part way through. I am guessing things did not cleanup.

    I suggest you cleanup first (just in case), do job, cleanup again.
    Yeah - as I suspected, because I had interrupted a run, the mount directory and mount point had not been deleted and script fell over as shown.

    Once I deleted them (had to go to Reflect in PE mode because of permissions to delete mount folder -quicker than messing around changing file onwerships), the script ran ok.

    Just testing now.

    Problem creating GPT VHD automatically-image.png
      My Computer


  7. Posts : 17,636
    Windows 10 Pro
       #27

    When you interrupt the script, you can clear mount folder with following PS command:

    Dismount-WindowsImage -Discard -Path $MountFolder

    Kari
      My Computer


  8. Posts : 2,768
    Windows 11 Pro, 21H2
       #28

    Kari, I hope you don't mind my jumping in. I took a real quick glance at your script, and I was just wondering if you wanted to maybe add a quick check for the use of bitlocker on the C: drive prior to updating BCD. If I'm not mistaken, if bitlocker is in use on that drive, then modifying the the BCD will trigger it to ask for the recovery key on the next boot.

    Bitlocker can be suspended prior to updating the BCD like this:

    Code:
    manage-bde -protectors -disable C:
    Note that upon reboot, bitlocker will re-enable itself.

    Also, the whole issue of interrupting an operation while a mountpoint was still active was a big problem for me for a while. I noticed that sometimes simply performing a discard operation was not enough.

    I found that I sometimes had to run a series of 3 commands like this:

    Code:
    dism /Unmount-Image /MountDir:"D:\Project\Mount" /Discard
    dism /Cleanup-WIM
    dism /cleanup-mountpoints
    I know that you are running a powershell command, so my apologies if that command basically does what all 3 of these do. I just wanted to mention it in case it could be of any help.
      My Computers


  9. Posts : 13,561
    Windows10
    Thread Starter
       #29

    hsehestedt said:
    Kari, I hope you don't mind my jumping in. I took a real quick glance at your script, and I was just wondering if you wanted to maybe add a quick check for the use of bitlocker on the C: drive prior to updating BCD. If I'm not mistaken, if bitlocker is in use on that drive, then modifying the the BCD will trigger it to ask for the recovery key on the next boot.

    Bitlocker can be suspended prior to updating the BCD like this:

    Code:
    manage-bde -protectors -disable C:
    Note that upon reboot, bitlocker will re-enable itself.

    Also, the whole issue of interrupting an operation while a mountpoint was still active was a big problem for me for a while. I noticed that sometimes simply performing a discard operation was not enough.

    I found that I sometimes had to run a series of 3 commands like this:

    Code:
    dism /Unmount-Image /MountDir:"D:\Project\Mount" /Discard
    dism /Cleanup-WIM
    dism /cleanup-mountpoints
    I know that you are running a powershell command, so my apologies if that command basically does what all 3 of these do. I just wanted to mention it in case it could be of any help.
    It has helped me - just created a batch file if I run into issue again.
      My Computer


  10. Posts : 17,636
    Windows 10 Pro
       #30

    A PS one-liner to check if $MountFolder has any files left from a previous mount, thus being not empty:

    if (Test-Path $MountFolder\*) {Dismount-WindowsImage -Discard -Path $MountFolder}

    Kari
      My Computer


 

  Related Discussions
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 08:04.
Find Us




Windows 10 Forums