Skip to content

create a variable in SCCM TS for logged in user

Featured Replies

Is there a way that I could create a variable that refers to the logged in user in SCCM TS here is an example where I want to use it

 

post-21787-0-78360300-1426862493_thumb.jpg

There are several ways to do that, how do you intend to input the logged in user name and are you doing this in WinPE or after the OS is installed? Outline of a couple script ways below. You can also create the variable within the TaskSequence through the Add - General - Set Task Sequence Variable; but I don't think that was your intent....

 

----

.vbs file

 

'Setup the environment

Set oTSEnv = CreateObject("Microsoft.SMS.TSEnvironment")

strName = strInputName

'Write the TSVariable
oTSEnv("genericTSvariablename") = strUserName
Then call %genericTSvariablename% as you do in your example
-----
.ps1
#Call SMS environment
$Tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$strName = $Tsenv.value("genericTSvariablename")

 

Then call %genericTSvariablename% as you do in your example

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.