none
MDT 2013 U1 diskpart script not executing RRS feed

  • Question

  • I have been having alot of trouble trying to deploy Win 7 Pro on MDT 2013 Update 1 (6.3.8298.1000) as i cannot do diskpart. The TS does not even reach the stage of copying of the WIM image.

    Mt MDT error is:

    Litetouch deployment failed, Return Code = -2147467259 0x80004005

    I have followed various forum threads using methods like:

    - adding empty "format disk" TS before the diskpart TS (MDT error will have an additional error saying no valid partition selected)

    - using the DONOTFORMATANDPARTITION=YES

    - open a new deployment share and re-add image and TS

    - Read about the drive letters jumping around and assigned drive letter "C" in diskpart script

    All these methods didnt work. Funny thing is, all the methods threw the same error code.

    My diskpart script is as follows: diskpart /s "SCRIPTROOT\diskpart.txt" (start in is empty)

    SELECT DISK 0
    SELECT PARTITION 2
    FORMAT FS=NTFS LABEL="OS" QUICK
    ACTIVE
    EXIT


    My MDT logs:

    https://onedrive.live.com/redir?resid=8A2AF7F0CAC03D65!474&authkey=!AGVUkAbkej8nuIA&ithint=folder%2clog




    • Edited by sianzb0i Thursday, December 31, 2015 5:07 AM
    Monday, December 21, 2015 2:14 PM

Answers

  • I ran into this problem with MDT 2013 update 2. I was able to use a part of the ZTIDiskpart.wsf to make my own script to format my specific partition. I made my own file called ZTIDisk_MyPart.wsf. You have to update this in a few places within the script to get it to start working. Next, I removed most of the main functionality. I only have about 7 or 8 lines of code. Using the MDT oUtility Class, I was able to format the required partition.

    Example: oUtility.RunCommandWrite oExec, "sel dis 0"

    Obviously, you need more than this but not going to type out the whole thing. This did take a few attempts, but I was able to get it to format. 

    The main problem was that something (not sure what) is still accessing the partition that needs to be formatted, which is causing the error. Using a diskpart script, it does not show you the error, but I could see the error in the MDT logs by using the custom script above. So after my long story, I am going to use my custom script to format, but I believe a second work around that may be able to add the override switch to your format command in your diskpart script.

    Example: format fs=ntfs quick override

    Although, I have not tried it. Hope this helps someone.

    Actually, i was able to get past the diskpart issue a few days ago without script modification.

    What i did was, use a diskpart script to assign a drive letter to my desired OS partition (sel disk 0 select partition 2 assign letter blah blah).

    Then i used a set TS variable OSDisk = drive letter that i assigned.

    With DoNotPartitionAndFormat=Yes in customSettings.ini and the Orginal Formation and partition TS step set to continue on error (the step must not be empty or else another non fatal error will be flagged), I was able to get past all the diskpart issues.

    BUT, this led me to another problem, which i am not sure if it is related to the diskpart.

    I have posted it here.

    • Marked as answer by sianzb0i Saturday, October 8, 2016 2:05 AM
    Saturday, October 8, 2016 1:53 AM

All replies

  • You will want to let the Task Sequence handle the disk partitioning using one of the Diskpart steps.

    Logs are very important. https://keithga.wordpress.com/2014/10/24/video-mdt-2013-log-files-basics-bdd-log-and-smsts-log/ Mention any customizations you have made.

    Monday, December 21, 2015 6:53 PM
    Moderator
  • You will want to let the Task Sequence handle the disk partitioning using one of the Diskpart steps.

    Logs are very important. https://keithga.wordpress.com/2014/10/24/video-mdt-2013-log-files-basics-bdd-log-and-smsts-log/ Mention any customizations you have made.

    Hi Glander,

    I am not sure what you mean by that.

    I created a task under "run command line" and used my diskpart script with the diskpart command.

    Is it wrong? How should i do it then?

    Tuesday, December 22, 2015 12:37 AM
  • Using a Diskpart step in your task sequence not necessarily a command line that runs Diskpart.

    Logs are very important. https://keithga.wordpress.com/2014/10/24/video-mdt-2013-log-files-basics-bdd-log-and-smsts-log/ Mention any customizations you have made.

    Tuesday, December 22, 2015 1:22 AM
    Moderator
  • Using a Diskpart step in your task sequence not necessarily a command line that runs Diskpart.

    Logs are very important. https://keithga.wordpress.com/2014/10/24/video-mdt-2013-log-files-basics-bdd-log-and-smsts-log/ Mention any customizations you have made.

    Are you suggesting to me to not use "Run Command Line" TS to run the diskpart script?

    If so, how do I go about doing it?

    I cannot use the "Format & Partition Disk" TS as it does achieve my requirement of formatting a particular partition. I do not want to format the whole partition. I just want to format a particular partition.

    Please guide me along. I am totally new to MDT.


    • Edited by sianzb0i Tuesday, December 22, 2015 1:20 PM
    Tuesday, December 22, 2015 1:14 PM
  • It's not supported to retain any partitions.
    USMT on the other hand is a supported option which would allow you to backup and restore specific data.

    Someone has achieved what you're after in this thread with the current MDT build:
    https://social.technet.microsoft.com/Forums/en-US/828f612b-72c5-4478-9251-bf0920c2c443/task-sequence-cannot-continue?forum=mdt

    But please remember that this is a completely unsupported procedure if you are not using USMT!

    Tuesday, December 22, 2015 9:37 PM
  • It's not supported to retain any partitions.
    USMT on the other hand is a supported option which would allow you to backup and restore specific data.

    Someone has achieved what you're after in this thread with the current MDT build:
    https://social.technet.microsoft.com/Forums/en-US/828f612b-72c5-4478-9251-bf0920c2c443/task-sequence-cannot-continue?forum=mdt

    But please remember that this is a completely unsupported procedure if you are not using USMT!

    I am not transferring any data hence i didnt use USMT.

    What i am trying to achieve is just to format the OS partition.

    I followed what was mentioned in the thread you provided. I will still have the same error with an additional error saying no valid partition selected. this is due to the empty "format disk and partition" TS step.

    (I think the TS didnt even get pass the formatting stage as my partitions are intact. The thread mentioned, was able to boot into windows. Meaning "Install OS" TS has been executed successfully.)

    Are they any workarounds for formatting a specific partition?



    • Edited by sianzb0i Wednesday, December 23, 2015 2:52 PM
    Wednesday, December 23, 2015 8:46 AM
  • Please let me know if you want to retain one logical partition, on the same drive and format and reinstall the other?


    Modassir Khan


    Thursday, December 24, 2015 9:20 AM
  • Please let me know if you want to retain one logical partition, on the same drive and format and reinstall the other?


    Modassir Khan


    Hi,

    I want to retain all partitions and format a particular partition (disk 0 partition 2)

    Thursday, December 24, 2015 10:20 AM
  • Use the diskpart scipt as SELECT DISK 0 SELECT PARTITION 1 FORMAT FS=NTFS LABEL="OS" QUICK ACTIVE However to retain the existing partition, use the wmi Condition for this task sequence as If all condition are true root\cimv2 select * from win32_logicalDisk Where VolumeName Like "%yourseparatepartitionlogicalname%" Now this used to work till mdt 2010 but with some modification in Ztidiskpart.wsf in mdt 2013. U need to create a blank format and partition task sequence Above ur diskpart task sequence and provide the wmi condition as above And tick the option to continue with error. This will do the trick and u will be able to retain ur disk partition on the same disk.

    Modassir Khan

    Thursday, December 24, 2015 2:05 PM
  • Use the diskpart scipt as SELECT DISK 0 SELECT PARTITION 1 FORMAT FS=NTFS LABEL="OS" QUICK ACTIVE However to retain the existing partition, use the wmi Condition for this task sequence as If all condition are true root\cimv2 select * from win32_logicalDisk Where VolumeName Like "%yourseparatepartitionlogicalname%" Now this used to work till mdt 2010 but with some modification in Ztidiskpart.wsf in mdt 2013. U need to create a blank format and partition task sequence Above ur diskpart task sequence and provide the wmi condition as above And tick the option to continue with error. This will do the trick and u will be able to retain ur disk partition on the same disk.

    Modassir Khan

    So the key here is to use a wmi query/condition. If this is the key to make it work, then its great. But I wont be back at work till next week. I will try and report back.

    A small question: What if i am not sure if my C drive has a name?

    EDIT: I just read through your other Thread regarding the same issue. I see that you used a WMI query to query for ur data drive. if the data drive exists, then u run the script. Is there such a need for the query?

    I tried your method without the WMI query and MDT error will have an additional error saying no valid partition selected.


    • Edited by sianzb0i Friday, December 25, 2015 6:49 AM
    Thursday, December 24, 2015 4:38 PM
  • For me the concern was to retain the partition if data drive exists else format the entite disk and do the installation For that i used a seperate dispart script. Now ur concern ..... Yes the query decides what to select and my script decides what to do with the selection.

    Modassir Khan

    Friday, December 25, 2015 9:45 AM
  • For me the concern was to retain the partition if data drive exists else format the entite disk and do the installation For that i used a seperate dispart script. Now ur concern ..... Yes the query decides what to select and my script decides what to do with the selection.

    Modassir Khan

    I do not think the WMI query will make a difference in my case but i will give it a shot.

    What is your MDT version number?

    Sunday, December 27, 2015 2:03 PM
  • Currently I am using 2013

    Modassir Khan

    Wednesday, December 30, 2015 6:06 AM
  • Currently I am using 2013

    Modassir Khan

    just 2013? not the latest Update 1?
    Wednesday, December 30, 2015 10:57 AM
  • The script is ok except for the "" characters.

    The correct form is: diskpart /s %scriptroot%\diskpart.txt

    It' will work without any problem, howerver, you don't need to do that because MDT have the process to do that.

    Greetings,

    Jason

    Wednesday, December 30, 2015 3:37 PM
  • Just an update.

    Today I tried all the methods proposed here.

    1) Modassir Khan's method with WMI Query. I gave the Partition the name OS and i changed the name accordingly but the TS skipped my diskpart instead. So somehow the Query was not true. So I removed the Query and I got back the same error with additional error which I ASSUME is due to the empty "Format Disk and Partition" step.

    I will update the logs accordingly

    2) I tried Jason's method without the quotes as well. Same Error as previous tries

    EDIT:

    My diskpart script is on my DeploymentShare$\Scripts folder.

    When the deployment failed, a command prompt came up with X:\ Drive. I went in to the Deploy Folder and there were Scripts and Tools folder. I couldn't find the script there.

    My Query: Where is %SCRIPTROOT% pointing to?


    • Edited by sianzb0i Thursday, December 31, 2015 5:00 AM
    Thursday, December 31, 2015 4:38 AM
  • You only want to DONOTFORMATANDPARTITION=YES when you have a data partition to keep. Set the DONOTFORMATANDPARTITION=YES in your task sequence using WMI (similar to earlier in the thread) as a filter.

    Logs are very important. https://keithga.wordpress.com/2014/10/24/video-mdt-2013-log-files-basics-bdd-log-and-smsts-log/ Mention any customizations you have made.



    Thursday, December 31, 2015 5:11 AM
    Moderator
  • Also post your ts.XML to OneDrive or something similar.

    Logs are very important. https://keithga.wordpress.com/2014/10/24/video-mdt-2013-log-files-basics-bdd-log-and-smsts-log/ Mention any customizations you have made.

    Thursday, December 31, 2015 5:16 AM
    Moderator
  • Hi Glander

    I do not understand or how to do the following:

    Set the DONOTFORMATANDPARTITION=YES in your task sequence using WMI (similar to earlier in the thread) as a filter

    DONOTFORMATANDPARTITION=YES should be part of the Rules/custom settings.ini isnt it?

    I tried the WMI method but it totally skipped it. I do have a partition with the name OS but somehow it was skipped. Is there anyway to test this?

    Where do i extract TS.XML? Must it be after it failed?

    Also, I dont see why i need a WMI Query as I will definitely need to execute this step for the TS


    • Edited by sianzb0i Thursday, December 31, 2015 7:28 AM
    Thursday, December 31, 2015 7:07 AM
  • I think I was not clear in my earlier statement. so when you say

    "I gave the Partition the name OS and i changed the name accordingly but the TS skipped my diskpart instead"

    At this point does that machine had any other logical partition other than c:?



    Modassir Khan

    Thursday, December 31, 2015 8:48 AM
  • I think I was not clear in my earlier statement. so when you say

    "I gave the Partition the name OS and i changed the name accordingly but the TS skipped my diskpart instead"

    At this point does that machine had any other logical partition other than c:?



    Modassir Khan

    I boot MDT off my USB pen drive using GRUB and the LiteTouch x64.iso.

    So there will be 2 physical drives: my pendrive and my HDD.

    The HDD itself has 3 partitions: Partition 1 is the 100MB partion created by Win 7 during installation. Partition 2 is where the OS itself resides. Partition 3 is HP Recovery Partition.

    Thursday, December 31, 2015 9:14 AM
  • So the Whole Idea is to keep the recovery Partition intact.. and Format and reinstall the OS Partition.

    From your machine that has the HP recovery partition, can you run the wmi query and test of this returns any value?

    root\cimv2 select * from win32_logicalDisk Where VolumeName Like"%your recoverypartition logical name%"

    Modassir Khan

    Thursday, December 31, 2015 9:42 AM
  • Have you looked in the task sequence editor to add set task sequence variable? And your ts.XML is in .\Control\<TSID>

    Logs are very important. https://keithga.wordpress.com/2014/10/24/video-mdt-2013-log-files-basics-bdd-log-and-smsts-log/ Mention any customizations you have made.


    Thursday, December 31, 2015 10:44 AM
    Moderator
  • 1) Can someone explain to me why do I need a WMI query?

    I just want to execute the diskpart script to format the windows partition, which is partition 2. It doesnt matter of the third partition is a Data partition or a Recovery partition. Am I not getting the concept right?

    2) I will look into the TS.XML on monday as i loss connection to my MDT system remotely.

    3) Can someone enlighten me where does %SCRIPTROOT% points to during deployment in WinPE?

    Friday, January 1, 2016 5:58 AM
  • Scriptroot is always in .\Scripts relative to deployroot.

    The solution to your stated problem of if you have a data partition then don't wipe the whole disk is to check if the data partition exists (the WMI query to check if a partition with a certain name exists) then set DoNotFormatAndPartition to YES(save the data partition also don't set this normally if you want to wipe the disk for nondata partition scenarios)  Everything real requirement you have is covered by that.

    I don't think running a diskpart script is the right solution. If your requirement is you want to run a custom diskpart script via command line regardless then I don't know how to help.


    Logs are very important. https://keithga.wordpress.com/2014/10/24/video-mdt-2013-log-files-basics-bdd-log-and-smsts-log/ Mention any customizations you have made.


    Friday, January 1, 2016 6:39 AM
    Moderator
  • Scriptroot is always in .\Scripts relative to deployroot.

    The solution to your stated problem of if you have a data partition then don't wipe the whole disk is to check if the data partition exists (the WMI query to check if a partition with a certain name exists) then set DoNotFormatAndPartition to YES(save the data partition also don't set this normally if you want to wipe the disk for nondata partition scenarios)  Everything real requirement you have is covered by that.

    I don't think running a diskpart script is the right solution. If your requirement is you want to run a custom diskpart script via command line regardless then I don't know how to help.


    Logs are very important. https://keithga.wordpress.com/2014/10/24/video-mdt-2013-log-files-basics-bdd-log-and-smsts-log/ Mention any customizations you have made.


    I created a virtual environment to test it out the whole scenario. MDT 2013 Update 1 and windows 10 ADK.

    Captured a new custom WIM (I am using Windows 8.1 ENT Eval image). Imported to MDT and created the Standard Installation TS.

    I am still getting the EXACT same error. 

    So I read through the log again. I saw that DeployRoot is at X:\Deploy. Upon deployment failure, I navigated to that path, there is only "Scripts" and "Tools" folders. Inside "Scripts" only those MDT "standard" scripts are in there. My diskpart script is not there.

    My understanding is that upon entering the credentials at the beginning of the deployment, it will connect to the deploymentshare$ folder and map to the folder. but seems like it is not.

    Summary: I suspect is the missing diskpart script that is causing the error. How do I make the script inclusive or force it to connect to deploymentshare$ folder

    EDIT: I read in another log file that Z:\ is connected to DeploymentShare$. I guess it is disconnected when the deployment fails


    • Edited by sianzb0i Saturday, January 2, 2016 4:51 PM
    Saturday, January 2, 2016 4:14 AM
  • I did another run with MDT 2012 Update 1 with Windows 8.1 ADK.

    I had some errors regarding DISM deployment did not complete properly but at least my diskpart script ran properly and applied the image to the right partition.

    However i cannot boot past the "specialize" stage.

    Looks like i got to revert my Production MDT to 2012 and cannot do mass deployment for windows 10 anytime soon

    Sunday, January 3, 2016 2:32 PM
  • You might be able to do the fully qualified path to your diskpart script in your run command. Something like:

    Diskpart /s \\server\share\scripts\blah.txt


    Logs are very important. https://keithga.wordpress.com/2014/10/24/video-mdt-2013-log-files-basics-bdd-log-and-smsts-log/ Mention any customizations you have made.

    Sunday, January 3, 2016 8:47 PM
    Moderator
  • You might be able to do the fully qualified path to your diskpart script in your run command. Something like:

    Diskpart /s \\server\share\scripts\blah.txt


    Logs are very important. https://keithga.wordpress.com/2014/10/24/video-mdt-2013-log-files-basics-bdd-log-and-smsts-log/ Mention any customizations you have made.

    Ok, I will have a last run at this before i revert back to MDT 2012
    Tuesday, January 5, 2016 3:10 AM
  • I already gave up on MDT 2013 Update 1.

    I reverted to MDT 2013 (i made a mistake, it wasnt MDT 2012), ran with diskpart script and had the SMSTaskSequencer error. I enabled the format disk and partition TS, added DONOTFORMATANDPARITION=YES to my CS.ini and everything worked like it should.

    Maybe I will run a separate MDT 2013 Update 1 for deploying Windows 10 in the future.

    Friday, January 8, 2016 4:35 PM
  • Now we are deploying windows 10. 

    1) is it a must to use ADK 10 when deploying windows 10?

    2) the MDT scripts (ZTIDiskPart) that are affecting my diskpart, are they part of MDT or ADK?

    Thursday, February 4, 2016 3:50 AM
  • I just tried it on MDT 2013 U2 with ADK 10.0.26624.0. Same old error.

    Is there a new workaround for this?

    Or I must always wipe the whole disk?

    Friday, March 18, 2016 8:51 AM
  • I ran into this problem with MDT 2013 update 2. I was able to use a part of the ZTIDiskpart.wsf to make my own script to format my specific partition. I made my own file called ZTIDisk_MyPart.wsf. You have to update this in a few places within the script to get it to start working. Next, I removed most of the main functionality. I only have about 7 or 8 lines of code. Using the MDT oUtility Class, I was able to format the required partition.

    Example: oUtility.RunCommandWrite oExec, "sel dis 0"

    Obviously, you need more than this but not going to type out the whole thing. This did take a few attempts, but I was able to get it to format. 

    The main problem was that something (not sure what) is still accessing the partition that needs to be formatted, which is causing the error. Using a diskpart script, it does not show you the error, but I could see the error in the MDT logs by using the custom script above. So after my long story, I am going to use my custom script to format, but I believe a second work around that may be able to add the override switch to your format command in your diskpart script.

    Example: format fs=ntfs quick override

    Although, I have not tried it. Hope this helps someone.

    Tuesday, May 17, 2016 12:56 PM
  • I ran into this problem with MDT 2013 update 2. I was able to use a part of the ZTIDiskpart.wsf to make my own script to format my specific partition. I made my own file called ZTIDisk_MyPart.wsf. You have to update this in a few places within the script to get it to start working. Next, I removed most of the main functionality. I only have about 7 or 8 lines of code. Using the MDT oUtility Class, I was able to format the required partition.

    Example: oUtility.RunCommandWrite oExec, "sel dis 0"

    Obviously, you need more than this but not going to type out the whole thing. This did take a few attempts, but I was able to get it to format. 

    The main problem was that something (not sure what) is still accessing the partition that needs to be formatted, which is causing the error. Using a diskpart script, it does not show you the error, but I could see the error in the MDT logs by using the custom script above. So after my long story, I am going to use my custom script to format, but I believe a second work around that may be able to add the override switch to your format command in your diskpart script.

    Example: format fs=ntfs quick override

    Although, I have not tried it. Hope this helps someone.

    Actually, i was able to get past the diskpart issue a few days ago without script modification.

    What i did was, use a diskpart script to assign a drive letter to my desired OS partition (sel disk 0 select partition 2 assign letter blah blah).

    Then i used a set TS variable OSDisk = drive letter that i assigned.

    With DoNotPartitionAndFormat=Yes in customSettings.ini and the Orginal Formation and partition TS step set to continue on error (the step must not be empty or else another non fatal error will be flagged), I was able to get past all the diskpart issues.

    BUT, this led me to another problem, which i am not sure if it is related to the diskpart.

    I have posted it here.

    • Marked as answer by sianzb0i Saturday, October 8, 2016 2:05 AM
    Saturday, October 8, 2016 1:53 AM