-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Referencing variables in Task Sequence steps #148
Comments
Good Morning, I have worked around this now. But I would like to know how to reference deployment variables as above, if it's possible. Kind Regards, SBolt11 |
Powershell referencing works like this: |
Thanks for the above, but I wasn't look to at PowerShell env variables as such, but OSD variables. So my example could be any of the OSD / MDT variables, not ones I can get any other time. |
Inside a PowerShell script, you can use something like: $tsenv:OSDComputerName You can use variables as conditions on steps too. There are a few variables (e.g. "ScriptRoot") that are copied from the TS environment (tsenv:) to "normal" environment variables (env:), but that's not the case for all of them. |
Thanks for your answer, I will try and give it a go when I next do some testing. Just to be sure, you're saying I'm better off using a script and referencing inside the script instead of directly on the MDT TS step? |
AFAIK, you can't just use a PowerShell command as a TS Step (at least not yet), you have to do so in a script and call that script from the "Run PowerShell Script" step. |
Good Morning all FriendsOfMDT,
I have been using MDT PSD for a little under a year now and I've found it brilliant so far.
I have a question which may or may not be obvious, someone must have already tried this.
My example would be that I want to echo the OSDComputerName variable, which is set in person, in WinPE during the build in the normal way of typing it in, to a text file on C:\Logs.
The CustomSettings.ini sets the computer name field in WinPE to start with, and I edit that with what I actually want it to be. I assume that variable is now set, the build progresses through the TS steps and gets to the step which has a command line of echo %OSDComputerName% > C:\Logs\ComputerName.txt.
My task sequence fails at this point and no file is made. The folder does exist, I make this earlier on in the TS.
I can see in the logs that the TS attempts to do this, the variable listed in the command is %OSDComputerName%, I'm not sure if this should be resolved at this point and listed with the actual computer name or not.
Is this possible? Have I missed something really obvious?
I know I can get the computername from $env variables in another way, but I specifically want to be able to use the TS variable during a TS step, and I'm just using OSDComputerName for testing. I guess this may also apply to the question of: Can you use the %OSDComputerName% variable in an IF statement within the TS? E.g. run this TS step if the computer name is this.
Thank you in advance,
SBolt11
The text was updated successfully, but these errors were encountered: