Jump to content


Jepeto 46

SCCM Custom Variable question

Recommended Posts

I am trying to create a variable which will capture user data to a USB drive. I run the following command line to get the USB drive

cmd /c powershell.exe -executionpolicy bypass -command "& {$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment; $tsenv.Value('USBDrive') = (Get-WMIObject Win32_Volume | ? { $_.Label -eq 'USMT' }).Name}"
Dumping the variables, it seems right

OSDEnableTCPIPFiltering = false
OSDStateStorePath = USBDrive
SMSTSDisableWow64Redirection = false
SMSTSLocationMPs = http://ConfigMGR.lab.local
SMSTSRebootMessage = 
SMSTSRebootReason = 
SMSTSRebootRequested = 
SMSTSRetryRequested = 
SMSTSUser = 
USBDrive = E:\

In the end of the variable dump I see this:

SMSTSUserStatePath = C:\_SMSTaskSequence\UserState

however when I try to redirect the capture to the %USBDrive% it's not working. Everything works perfect if I hard code it with E: (which I really prefer not to do).

The TS order is below

 

Share this post


Link to post
Share on other sites

I had to change mindset and finally got a standalone media which can capture USMT as well. I had to dump the variables in order to find out I was not in the right path. I ended up creating a new variable (it's all one line)

cmd /c powershell.exe -executionpolicy bypass -command "& {$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment; $tsenv.Value('USBDrive') = (Get-WMIObject Win32_Volume | ? { $_.Label -eq 'CMBOOT' }).Name.substring(0,2)}"

After hours of testing I realized that substring(0,2)} is the most important part, it will not capture to E:\ but will to E:

Now I could set the OSDStateStorePath variable to %USBDrive% and everything started working.

Here is the basic TS

 

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.