Jump to content


JustinL

Trouble running diskpart script in task sequence

Recommended Posts

Hello,

Since moving to CM2012 I’ve been struggling to get my diskpart script that I used in CM2007 to work. The obvious difference between the two is that in my 2007 environment was set to access content directly from the DP and in 2012 I’m trying to stick with the default of download content locally. Here is my senario.

The workstations have 1 disk with two partitions
C: OSDisk
D: Data Partiton
E: ROM Drive

Because of some custom software we run I need the data partition (D:) reassigned to (E:) then in turn the ROM Drive (E:) reassigned to (D:). to accomplish this I run the following run cmd line from my diskpart package
diskpart.exe /s diskpart.txt
diskpart.txt looks like this:
select volume E
assign letter J
select volume D
assign letter E
select volume J
assign letter D
rescan
exit

This was very straight forward in CM2007 when accessing content from the DP but has become troublesome in 2012 because of the fact that the content needed to run the diskpart script in cached locally in the D:_SMSTaskSequence folder. The script itself runs fine until D: is reassigned to E: and the TS cant find the file anymore and bombs.

I know i can always go through and set the packages and the deployment to run from the DP but I’d really like to try and stick with the recommended setting of download locally unless there is no other option. From what I understand the _SMSTaskFolder is defaulted to the drive with the most space. Is there a way that i can hard set the folder to C: instead? This seems like it should be a very simple step but I’ve been struggling with it for a week now. Any ideas on how to get the accomplished successfully would be appreciated.

Thanks,
Justin

Share this post


Link to post
Share on other sites

Just run this step as very first during the Windows Phase and not during the PE Phase. That should do the trick.

 

Or ...

 

Only reassign the drive letter for the DVD drive in your diskpart script, just before the partitioning step. Then you can directly assign drive E to your data Partition during the partitioning.

Share this post


Link to post
Share on other sites

Funnily i was running into a similar problem today, while i was trying to reimage a Bitlocker encrypted Lenovo Helix with Windows 8 x64 in UEFI mode.

You also can't use diskpart there, because the TS can't store the script file.

So i tried a totally different approach by using the Storage Cmdlets of Powershell v3, which worked great.

First i added the optional component WinPE-StorageWMI to my boot image. Then i added a command line step to the task sequence to replace the diskpart command.

The powershell command to clean the disk looks like this.

powershell -ExecutionPolicy bypass -command clear-disk -number 0 -removedata -removeoem -confirm:$false

You should be able to translate your diskpart file into powershell. Just have a look at get-volume and set-volume commands. Here is the cmdlet documentation.

Share this post


Link to post
Share on other sites

Thanks for the replies Peter. I was able to finally get this working with a little different method. In my Format & Partition step on the second partition I checked the box "Do not assign a drive letter to this partition". The task sequence still creates the partition but nothing can run from it because it has no letter assigned. With this in place the _SMSTaskSequence folder now defaults to C:\. I then added the step to run the diskpart script back into the task sequence to run right after Windows boots. The script successfully reassigns the ROM Drive to D: and assigns E: to the second partition.

 

Justin

Share this post


Link to post
Share on other sites

I ended up running in to some issues with my previous solution so I wanted to post an updated solution that has been working. I went back to Technet and started researching the TS built-in variables and came across the SMSTSLocalDataDrive variable.

 

From Technet:

SMSTSLocalDataDrive

Specifies where temporary files are stored on the destination computer while the task sequence is running.
This variable must be set before the task sequence starts, such as by setting a collection variable. Once the task sequence starts, Configuration Manager defines the _SMSTSMDataPath variable once the Task Sequence starts.
Does exactly what I was looking for! I created a collection variable for SMSTSLocalDataDrive and set it to C: on my OSD collections and voila the the _SMSTaskSequence folder now defaults to C: no matter what.
Justin
  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.