none
Some Storage CMDLets do not work under WinPE

    General discussion

  • I have built a custom WinPE based on W2012 and included Powershell and a number of the Powershell CMDLets such as SMB, DISM, and Storage. Everything works fine. When you boot the WinPE disk and do a get-command -module Storage, it shows all of the Storage CMDlets. I am trying to do some simple automation and wrote a very simple script to initialize, partiion and format a disk

    Initialize-disk 1 -PartitionStyle MBR
    New-Partition  -diskNumber 1 -DriveLetter L -UseMaximumSize | `
      Format-Volume -FileSystem NTFS -NewFileSystemLabel "Stuff"

    When I run this script on a W2012 server it works fine. When I run it from by WinPE disk the Format does not work. No error messages. Nothing. The first 2 statments work but the disk never is formatted and no label is assigned. The same is true with the Clear-Disk Cmdlet. I execute it under W2012 and it works fine. When I execute it under Win-PE it just returns to me and does nothing. I even tried just executing the Format-Volume Cmdlet by itself on WinPE and got the same result -- it immediately came back with no error message and did nothing.

    It seems like some cmdlets work and some don't. Anyone have any thoughts?

    Thanks

    Roger


    Roger

    Friday, May 31, 2013 8:11 PM

All replies

  • and you setup everything in the build for powershell?

    To use Windows PowerShell

    • Install WinPE-WMI, WinPE-NetFX4, and WinPE-Scripting before you use WinPE-PowerShell3.

    1. Install WinPE-WMI, WinPE-NetFX4, and WinPE-Scripting before you use WinPE-PowerShell3.

    2. Install WinPE-PowerShell3 before you use the Windows PowerShell® cmdlets (WinPE-DismCmdlets and WinPE-StorageWMI).

    • Install WinPE-Scripting to make sure that full scripting functionality is available when you are using WinPE-NetFX4 and WinPE-HTA.

      The installation order is irrelevant for obtaining full scripting functionality.

    http://technet.microsoft.com/en-us/library/hh824926.aspx

    Friday, May 31, 2013 8:19 PM
  • Thanks for the response. All 4 of those packages are added. I added just about everything before I started. Most of the Powershell stuff is working quite well. I even have some SMB things that are fine. It is just selected commands that fail.

    Roger

    Friday, May 31, 2013 9:06 PM
  • Hi,

    Thank you for your question.

     

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

     

    Thank you for your understanding and support.

    Regards,

    Yan Li

    If you have any feedback on our support, please click here .


    Cataleya Li
    TechNet Community Support

    Tuesday, June 04, 2013 6:04 AM
    Moderator
  • Hi,

    Please check this link to get more syntax about disk management:

    Windows Server 8 – Disk Management with PowerShell 3.0 (en-US)

    http://social.technet.microsoft.com/wiki/contents/articles/9122.windows-server-8-disk-management-with-powershell-3-0-en-us.aspx

    And i am trying to do a lab to check whether i can repro your issue.

    Thanks,


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. 

    Thursday, June 06, 2013 8:25 AM
  • Thanks. Diskpart, does in fact work. That is how I am able to get the functions complete. The syntax of the commands is also correct as when I run the same command on a Windows 2012 server it works fine. For example Clear-disk works on a Server but does not work under Win-PE. Same target disk, same VM just a different hos OS.


    Roger

    Thursday, June 06, 2013 11:22 AM
  • Hi,

    Can you try to run the same command-line on other Win-PEs? To make sure whether this issue is just come from the specific image.

    Thanks,


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. 

    Friday, June 07, 2013 9:17 AM
  • I have run the command on the same machine both from WinPE and from W2012 and saw the same anomoly. I don't have another WinPE with the Storage cmdlets in it. I could build it but it would be probably be the same as the first one. There certainly could be an error in my build process. As ImMax previously suggested, I checked my build and made sure those modules were there. Do you have a particular build procedure that you want me to follow? I am using http://technet.microsoft.com/en-us/library/hh824926.aspx as a guide. Thanks.

    Roger

    Thursday, June 13, 2013 1:04 PM
  • Hi ,

    http://technet.microsoft.com/en-us/library/hh824926.aspx

    The link is so detail to build WinPE, are you sure all the modules you get?

    Also please also try to bulid a new WinPE to test it.

    Thanks,


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. 

    Saturday, June 15, 2013 7:38 AM
  • Yes I am aware of that link. In fact that link is the same link that I provided in my previous post. That link essentially is more detail for which packages you need. The first responder ImMax asked about the required packages and I do have them. I actually mounted the WIM and used DISM to display that all of them were there. As an aside, if you don't have the packages, you don't have the cmdlets at all. I found this out when I originally built the WinPE. Again. All the CMDlets are there, just some of them are not working. There is no error when these do not work. If fact it appears that the worked successfully.

    Thanks.


    Roger

    Saturday, June 15, 2013 5:26 PM
  • Hi,

    Now it seems hard to narrow down the cause of this issue, please try to rebuild WinPE to avoid image error.

    Thanks,


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. 

    Wednesday, June 19, 2013 10:27 AM
  • OK The WinPE Iso was rebuilt with the following procedure

    Copype amd64 C:\WinpePS
    Dism /mount-image /imagefile:c:\WinpePS\media\sources\boot.wim /index:1 /mountdir:C:\WinpePS\mount
    Dism /image:C:\WinpePS\mount /add-package /packagepath:"C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\winpe-NETFX4.cab"
    Dism /image:C:\WinpePS\mount /add-package /packagepath:"C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\winpe-WMI.cab"
    Dism /image:C:\WinpePS\mount /add-package /packagepath:"C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\winpe-Scripting.cab"
    Dism /image:C:\WinpePS\mount /add-package /packagepath:"C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\winpe-PowerShell3.cab"
    Dism /image:C:\WinpePS\mount /add-package /packagepath:"C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\winpe-StorageWMI.cab"
    Dism /unmount-image /mountdir:C:\WinpePS\mount /commit

    I Tested and got the same result. Here is the test procedure

    1) Add a new disk to a W2012 VM

    2) Boot VM. Initialize disk, Create Volume and Format

    3) Issue Clear-Disk 1 -removedata

    This worked fine. The disk was cleared.

    4) I initialized the disk again and recrecreated the partiition and volume

    5) Booted the new WinPE ISO

    6) started Powershell and vefied that the volume was there -- Get-Volume

    7) Issued the Clear-disk 1 -removedata

    Nothing happend. Volume is still there. See reslults below

    So it looks to me like there is a bug. Again other Storage cmdlets seem to work fine. It is just some (Like Clear-Disk and Format) of them that don't work (I haven't done an exhaustive study as I assume MS actualy tests their code)


    Roger

    Monday, June 24, 2013 3:21 PM
  • Hi,

    Thanks for your detailed explanation.

    Here i share you the information about clear-disk for your reference:

    http://technet.microsoft.com/en-us/library/hh848661.aspx

    From the above link,you can get detailed example:

    PS C:\> Clear-Disk -DiskNumber 1 –RemoveData

    PS C:\> Clear-Disk -DiskNumber 1 -RemoveData –RemoveOEM

    Please confirm whether you have data and OEM partitions on the current disk.

    Thanks,


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. 

    Tuesday, June 25, 2013 11:05 AM
  • Well I tried it but it made no difference. Remember this is a Virtual disk that I created, so it would have no OEM partition. Secondly, remember that it is the same disk which works in one case and does not work in the other case.  The only difference in the testing is that in one case the command is issued from a full Windows 2012 and in the other case it is issued from WinPE. The target of the 2 commands is exactly the same. This was done intentionally to isolate the number of variables.

    I am pretty sure that this is a bug but I am hoping someone else can verify this. I have also submitted this through Connect.microsoft.com as a bug but have not heard anything yet.  


    Roger

    Tuesday, June 25, 2013 7:34 PM
  • Hi,

    Thanks a lot for your information.

    Please update here if you have any updates from Connect and at the same time i need to take more time to research to confirm whether it is a bug for WinPE4.

    Thanks for your understanding.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. 

    Friday, June 28, 2013 12:00 PM
  • I came across this article as I am having the exact same problem. I know this is an old thread, but thought I would add that I am having the EXACT same experience. 

    I am using WinPE 5.1 and have added the WinPE-StorageWMI cab which gives you the Storage module. 

    Other cmdlets work in this module, but for the life of me I cannot get the Format-Volume to work. The above threads from WaukeshaGeek are 100% identical to my experience.  Once I am in the OS the cmdlet works perfectly. 

    No doubt there is a bug in this cmdlet while in WinPE. 

    Guess I have to go back to old a$$ diskpart.......

    Thursday, June 18, 2015 1:09 PM
  • The same behaviour can still be observed with Windows 10 ADK and Windows PE 10.
    Monday, June 06, 2016 6:35 PM
  • Hello guys,

    I confirm I am experiencing the issue with Windows 10 1607 in Windows PE with cmdlets Clear-Disk and New-Partition, at least. Those cmdlets just do nothing and produce no error message from within WinPE

    Have anybody heard anything the issue so far?

    Friday, April 21, 2017 7:35 AM