Question about setting ts variables
I see in the documentation that "New TS variables must be declared explicitly in BootStrap.ini or CustomSettings.ini". So I have to create a variable in customsettings.ini like such:
Properties=foo
So can I run a PowerShell script to set a var like so still?
$tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment $tsenv.Value('foo') = 'bar'
?
Thanks in advance, and to everyone that works on this project, it is appreciated!
Pretty much. You shouldn't have to set a new com object when within the TS. I use the PowerShell command Set-Item like so:
Set-Item tsenv:Foo -Value 'bar
Here is an example of what I did within a function on the Computer_readienss.ps1 file called during the PSDWizard:
So is that tsenv automatically created or do I need to create it? I am assuming it is already created, but watching a deployment and running get-psdrive several times I never see it listed.
You won't see it if your launching a separate instance of Powershell. You need to use it within the instance running; Meaning within the tasks sequence itself. If ur looking to simulate this you would need to use a MDT simulation. I've wrote one that I use for development. https://github.com/PowerShellCrack/MDTTSSimulator
@jengstrom440 Were you able to utilize the $tsenv in your solution?
@jengstrom440 Were you able to utilize the $tsenv in your solution?
Not yet, I haven't had luck yet. If I were to run a small PowerShell script to run a PowerShell form to set a TS variable, is that just as simple as adding a task sequence step and running it?
@jengstrom440 Were you able to utilize the $tsenv in your solution?
So I did download it an use it but I am having some problems. I ran the batch file as admin, and selected entered the unc path to my deployment root, selected b for ISE and B again for PSD. When I run the desktop shortcut as admin, it opens up an ISE powershell script. When I run it, it gives me this error:
To Map deploymentshare: New-PSDrive -Name DeploymentShare -PSProvider mdtprovider -Root \<Server><deploymentshare> Import-Module : The specified module '\Modules\Microsoft.BDD.TaskSequenceModule' was not loaded because no valid module file was found in any module directory. At C:\MDTSimulator\TSEnv.ps1:70 char:1
- Import-Module "$MDTSimulatorPath\Modules\Microsoft.BDD.TaskSequenceMo ...
-
+ CategoryInfo : ResourceUnavailable: (\Modules\Micros...kSequenceModule:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module '\Modules\PSDUtility' was not loaded because no valid module file was found in any module directory. At C:\MDTSimulator\TSEnv.ps1:71 char:1
- Import-Module "$MDTSimulatorPath\Modules\PSDUtility"
-
+ CategoryInfo : ResourceUnavailable: (\Modules\PSDUtility:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Import-Module : The specified module '\Modules\PSDGather' was not loaded because no valid module file was found in any module directory. At C:\MDTSimulator\TSEnv.ps1:72 char:1
- Import-Module "$MDTSimulatorPath\Modules\PSDGather"
-
+ CategoryInfo : ResourceUnavailable: (\Modules\PSDGather:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Unable to get TS environment
Install_Dir : C:\Program Files\Microsoft Deployment Toolkit
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Deployment 4
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft
PSChildName : Deployment 4
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
Upon further investigation, it appears that one no longer needs to copy the module folder over as they were already populated per the instructions. At line 70 though, it appears that the variable $MDTSimulatorPath is null so therefore this path won't work. I don't see where this variable is assigned a value. Am I missing something? Looking forward to trying this tool.
I'm not following what you are trying to do? Are you trying to run the MDT simulator or use Tsenv: within your task sequence? Are you trying to load the MDT simulator on a client for the task sequence? The simulator is for development purposed only and it's not a 1:1 like running a task sequence; it really just to get the PS Drives for MDT so I can test TSenv: variables.
With that, to run the simulator, did you follow the instructions?
THE MUSTS:
- You need to have MDT installed on the same system your running the simulator on.
- You must run the simulators from
C:\MDTSimulatorfolder - You must run SetupMDTSimulator.cmd to setup the simulator. This will copy all the files over to
C:\MDTSimulator