Microsoft.SMS.TSEnvironment works in VBS but not in PowerShell

Evgenij Smirnov 541 Reputation points
2021-07-02T13:08:43.19+00:00

Hi Community,

it's been a while since I've had to script SCCM so please bear with me.

From back in the day I know about using TSEnvironment to access and manipulate TS variables. I am also still aware of the 32-/64-bit problems we used to have back then. Now I am trying to access some variables from PowerShell and here's what I am seeing (on MECM 2103, TS is being run in Windows rather than in OSD):

  • via VBS (Action: Run batch, cscript dump-tsvars.vbs): works as expected
  • via PowerShell (Action: Run PowerShell, code pasted into the TS Step): does not throw any errors but does not dump any variables either
  • via PowerShell (Action: Run batch, c:\windows**system32**...\powershell.exe -ExecutionPolicy Bypass -File Dump-TSVars.ps1): does not throw any errors but does not dump any variables either
  • via PowerShell (Action: Run batch, c:\windows**sysWoW64**...\powershell.exe -ExecutionPolicy Bypass -File Dump-TSVars.ps1): throws error that the class is not registered

So basically, while the environment as such is only visible in 64-Bit PowerShell, the variables within the environment are not.

Can anybody please shed some light here?

1000 Thanks in advance

Evgenij

Microsoft Security | Intune | Configuration Manager | Other
0 comments No comments
{count} votes

Accepted answer
  1. Evgenij Smirnov 541 Reputation points
    2021-07-04T10:13:39.583+00:00

    OK, figured it out.

    Since the TS steps would not have to run in WinPE, I set them to run under a domain account (that has local admin rights on the endpoint). Apparently, this is good enough to initialize the TSEnvironment COM interface but not good enough to actually interact with it!

    Disabled the checkbox so that the step runs as SYSTEM, and all is well!


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.