question

Evgenij-Smirnov avatar image
0 Votes"
Evgenij-Smirnov asked saldana-msft edited

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

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



mem-cm-generalmem-cm-sdk
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Evgenij-Smirnov avatar image
0 Votes"
Evgenij-Smirnov answered HanyunZhu-MSFT commented

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!

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,

Thanks for your sharing! This may help others who has the similar issue.
If you have any questions in future, we warmly welcome you to post in Microsoft Q&A forum again.

Have a nice day!

0 Votes 0 ·