Some Storage CMDLets do not work under WinPE

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

May 31st, 2013 8:11pm

and you setup everything in the build for powershell?

To use Windows PowerShell
Free Windows Admin Tool Kit Click here and download it now
May 31st, 2013 8:19pm

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.
May 31st, 2013 9:06pm

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 .

Free Windows Admin Tool Kit Click here and download it now
June 4th, 2013 6:04am

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,

June 6th, 2013 8:25am

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.

Free Windows Admin Tool Kit Click here and download it now
June 6th, 2013 11:22am

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,

June 7th, 2013 9:17am

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.
Free Windows Admin Tool Kit Click here and download it now
June 13th, 2013 1:04pm

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,

June 15th, 2013 7:38am

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.

Free Windows Admin Tool Kit Click here and download it now
June 15th, 2013 5:26pm

Hi,

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

Thanks,

June 19th, 2013 10:27am

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)

Free Windows Admin Tool Kit Click here and download it now
June 24th, 2013 3:21pm

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,

June 25th, 2013 11:05am

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.  

Free Windows Admin Tool Kit Click here and download it now
June 25th, 2013 7:34pm

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.

June 28th, 2013 12:00pm

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.......

Free Windows Admin Tool Kit Click here and download it now
June 18th, 2015 9:12am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics