anth
New Member
Posts: 2
|
Post by anth on Apr 23, 2018 15:10:08 GMT
Is it possible to use UI++ to check the drives that are in a computer and then let the user select one? I am thinking for installing the OS onto that drive. A lot of the computers I deploy have multiple hard drives/ssd and at the moment my task sequence formats and installs the OS on drive0 which isn't always the correct on. I am looking to replicate the way you could select the drive in win7.
|
|
|
Post by Jason on Apr 27, 2018 0:41:46 GMT
Yes, this is possible. You can use multiple WMIRead actions and based on their results populate a ChoiceInput drop-down.
|
|
|
Post by cmolstad on Apr 30, 2018 13:14:20 GMT
I'm also interested in doing this, but WMIRead only gives the first value of an array. Can anyone provide of an example of how it could work?
|
|
|
Post by Jason on May 1, 2018 15:41:34 GMT
You are correct. So question then, what is an "installable drive"?
|
|
|
Post by cmolstad on May 2, 2018 1:51:44 GMT
In my opinion it should be any fixed drive that shows up in the WMI path Win32_LogicalDisk with the DriveType of 3 or MediaType of 12.
For a drop down menu, I would like it to show the partition drive letters of the fixed drives (DeviceID), the size in GB (or TB), and the physical drive that the partition is associated with. The Physical drive name has to be queried from Model in Win32_DiskDrive.
|
|
|
Post by cmolstad on May 6, 2018 19:23:46 GMT
Actually after looking at it some more I would just use Win32_DiskDrive and "MediaType" of "Fixed hard disk media".
|
|
anth
New Member
Posts: 2
|
Post by anth on May 9, 2018 9:24:20 GMT
been looking at this a bit more but I'm not good with the syntax and there seems to be very few wmiread examples around.
|
|
|
Post by cmolstad on May 9, 2018 14:24:15 GMT
I don't think you can do it without using an external call and a VB or PS script. I'm working on a VB script that does this.
|
|
|
Post by cmolstad on May 15, 2018 1:58:57 GMT
I had to get some help writing the script and there's probably better ways of doing it, but I got it working. You pick the drive from the ChoiceInput menu that you want to have Windows installed on and that will become the C drive. This line I have in the XML and I have it run right before the DefaultValues runs for the preflight check. <Action Type="ExternalCall" Title="External Command">cscript.exe //NOLOGO //B drives.vbs</Action> These next lines do the math to convert the WMI "size" value from bytes to GB or TB. You can also do this in the script file instead, but for some reason it wasn't working right for me so I decided to do it in the XML. Yes I know 1024 bytes are in a Kilobyte, etc. but I am using the same math that the drive manufacturers do, which is 1000 instead of 1024. <Action Type="TSVar" Name="DriveSize0" Condition='%DriveBytes0% < 1000 ^ 4'>Round(%DriveBytes0% / 1000 ^ 3) & " GB"</Action> <Action Type="TSVar" Name="DriveSize0" Condition='%DriveBytes0% >= 1000 ^ 4 AND %DriveBytes0% < 1000 ^ 5'>Round(%DriveBytes0% / 1000 ^ 4) & " TB"</Action> <Action Type="TSVar" Name="DriveSize1" Condition='%DriveBytes1% < 1000 ^ 4'>Round(%DriveBytes1% / 1000 ^ 3) & " GB"</Action> <Action Type="TSVar" Name="DriveSize1" Condition='%DriveBytes1% >= 1000 ^ 4 AND %DriveBytes1% < 1000 ^ 5'>Round(%DriveBytes1% / 1000 ^ 4) & " TB"</Action> <Action Type="TSVar" Name="DriveSize2" Condition='%DriveBytes2% < 1000 ^ 4'>Round(%DriveBytes2% / 1000 ^ 3) & " GB"</Action> <Action Type="TSVar" Name="DriveSize2" Condition='%DriveBytes2% >= 1000 ^ 4 AND %DriveBytes2% < 1000 ^ 5'>Round(%DriveBytes2% / 1000 ^ 4) & " TB"</Action>
Then further down in one of the Input action windows I have this. I only put 3 drives in the menu because we never see more than 3, but you can specify as many as you want.. Technically the first drive is drive 0 but I named it drive 1 to make it simple. <ChoiceInput Variable="DriveNumber" Question="Choose your Windows boot drive (C: drive):" Required="False" Default="%DriveIndex0%" > <Choice Condition='%DriveIndex0% = "0"' Option="Drive 1 - %DriveSize0% - %DriveModel0%" Value="%DriveIndex0%" /> <Choice Condition='%DriveIndex1% = "1"' Option="Drive 2 - %DriveSize1% - %DriveModel1%" Value="%DriveIndex1%" /> <Choice Condition='%DriveIndex2% = "2"' Option="Drive 3 - %DriveSize2% - %DriveModel2%" Value="%DriveIndex2%" /> </ChoiceInput> Finally, this is the VBscript that creates the task sequence variables for UI++. Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20
Dim objWMIService, objItem, colItems, strComputer strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_DiskDrive", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly) Set env = CreateObject("Microsoft.SMS.TSEnvironment")
iCount = 0 For Each objItem in colItems If objItem.MediaType = "Fixed hard disk media" Then env("DriveIndex" & iCount) = objItem.Index env("DriveModel" & iCount) = objItem.Model env("DriveBytes" & iCount) = ObjItem.Size iCount = iCount + 1 End If Next
You can either use Diskpart to create all the partitions or use conditions with a bunch of partition/format steps like I did. I also wanted to format the other drives if they existed so I used variables for those too. I am thinking about adding in a checkbox to give the option of not formatting the non-OS drives.
|
|
|
Post by Christofarian on Jun 18, 2018 21:30:05 GMT
I am trying to use your vbs script and xml lines to put a "Choose your hard drive" option but i always just get a blank window with the title, doesnt even show the Choiceinputbox Any suggestions
|
|
|
Post by cmolstad on Jun 19, 2018 14:45:42 GMT
I am trying to use your vbs script and xml lines to put a "Choose your hard drive" option but i always just get a blank window with the title, doesnt even show the Choiceinputbox Any suggestions Did you put it under an action, like this? Then end the action after?
<Action Type="Input" Title="Title" Name="Name" ShowBack="True" ShowCancel="True" Size="Tall">
|
|
|
Post by Christofarian on Jun 19, 2018 17:48:31 GMT
yes I did here is my full code , i have tried multiple combos of locations for the VBS script as well i tried the main deployment share and the C drive of the deployment server as well as the local UI++ folder, where does UI++ call external commands from?
<Actions> <Action Type="ExternalCall" Title="External Command">cscript.exe //NOLOGO //B drives.vbs</Action> <Action Type="TSVar" Name="DriveSize0" Condition='%DriveBytes0% < 1000 ^ 4'>Round(%DriveBytes0% / 1000 ^ 3) & " GB"</Action> <Action Type="TSVar" Name="DriveSize0" Condition='%DriveBytes0% >= 1000 ^ 4 AND %DriveBytes0% < 1000 ^ 5'>Round(%DriveBytes0% / 1000 ^ 4) & " TB"</Action> <Action Type="TSVar" Name="DriveSize1" Condition='%DriveBytes1% < 1000 ^ 4'>Round(%DriveBytes1% / 1000 ^ 3) & " GB"</Action> <Action Type="TSVar" Name="DriveSize1" Condition='%DriveBytes1% >= 1000 ^ 4 AND %DriveBytes1% < 1000 ^ 5'>Round(%DriveBytes1% / 1000 ^ 4) & " TB"</Action> <Action Type="TSVar" Name="DriveSize2" Condition='%DriveBytes2% < 1000 ^ 4'>Round(%DriveBytes2% / 1000 ^ 3) & " GB"</Action> <Action Type="TSVar" Name="DriveSize2" Condition='%DriveBytes2% >= 1000 ^ 4 AND %DriveBytes2% < 1000 ^ 5'>Round(%DriveBytes2% / 1000 ^ 4) & " TB"</Action>
<Action Type="Input" Title="DriveSelect" Name="DriveSelect" ShowBack="True" ShowCancel="True"> <ChoiceInput Variable="DriveNumber" Question="Choose your Windows boot drive (C: drive):" Required="False" Default="%DriveIndex0%" > <Choice Condition='%DriveIndex0% = "0"' Option="Drive 1 - %DriveSize0% - %DriveModel0%" Value="%DriveIndex0%" /> <Choice Condition='%DriveIndex1% = "1"' Option="Drive 2 - %DriveSize1% - %DriveModel1%" Value="%DriveIndex1%" /> <Choice Condition='%DriveIndex2% = "2"' Option="Drive 3 - %DriveSize2% - %DriveModel2%" Value="%DriveIndex2%" /> </ChoiceInput> </Action> </Actions> and what shows up is a blank screen that just says DriveSelect on it
|
|
|
Post by cmolstad on Jun 20, 2018 0:17:26 GMT
In my case, UI++ is in a SCCM package and the VBS file is in the same location as the UI++ exe, at the root level of the package. I am not using it in a prestart command boot image, so it gets downloaded from the server when it's time to run it in the TS.
|
|
|
Post by Christofarian on Jun 20, 2018 12:19:55 GMT
Im not using it from a pre start command either or a boot image...Im calling for it right before the format and partition task sequence in MDT
|
|
|
Post by cmolstad on Jun 21, 2018 5:02:25 GMT
Do you have an initial format and partition step at the start of the TS as well (before UI++) that does disk 0? That's what I do, or else strange things tend to happen. I'm also not using MDT, but not sure if that makes a difference.
|
|