Share via


How to access the environment variables of the remote machine( Windows Core OS) through TShell script?

Question

Thursday, September 26, 2019 8:07 AM

Through TShell I connected to the Windows Core os(UWP) using command :

-> Open-Device "ip address"Open-Device "ip address"

And tried to access the environment variables of the remote system using following commands,But its giving information of my local machine not remote machine.

-> [Environment]::GetEnvironmentVariables()

-> Get-WMIObject -Class Win32_Environment 

-> [environment]::GetEnvironmentVariable("TMP","machine")

-> Invoke-Command -ComputerName "abc" -ScriptBlock {[Environment]::GetEnvironmentVariable(“Temp”,”Machine”)}

All replies (13)

Thursday, September 26, 2019 8:34 AM

/en-us/windows/iot-core/connect-your-device/powershell

\(ツ)_/


Thursday, September 26, 2019 8:53 AM

I my case i can able to make connection with the Windows core os through TShell using command (Open-Device "IPAddress").Also i can able to copy file in the remote system and back,But i cant able to access the environment variables of Windows core system.Can you please share the command to get the environment variables of remote machine(UWP).


Thursday, September 26, 2019 9:05 AM

You have to use a remoting command or an Invoke-Command

Help Invoke-Command -online

\(ツ)_/


Thursday, September 26, 2019 11:20 AM

Invoke-Command -ScriptBlock {[Environment]::GetEnvironmentVariable("TEMP","Machine")}

Command mentioned above works but its not showing the path stored in the  environment variable TEMP(Verified through telnet)

Observed : C:\WINDOWS\TEMP

Expected : C:\Data\Users\DefaultAccount\AppData\Local\Temp

Any idea whats wrong?


Thursday, September 26, 2019 3:52 PM

Try "Get-ChildItem env:"

"Temp" may not  is a User or Process variable.  On IoT this may not exist as a machine variable.

\(ツ)_/


Friday, September 27, 2019 6:09 AM

Executed below commands

-> Get-ChildItem env:

-> Invoke-Command -ScriptBlock {Get-ChildItem env:}

This also showing environment variables of my local system(Windows 10) not windows core os(UWP)

Through telnet i connected to the windows core (UWP) system and verified the value stored in the environment variable TEMP=C:\Data\Users\DefaultAccount\AppData\Local\Temp


Friday, September 27, 2019 11:32 AM

I found and command to get environment variable of UWP machine connected remotely through TShell and it works

- > cmdd "set"

How to write these data to a text file I tried by using below below command

- > cmdd "set" > "sample.txt"

File is created but their is no data.Instead of that its printing  as  Exit Code : 0

 


Friday, September 27, 2019 1:16 PM

** Invoke-Command -ScriptBlock {Get-ChildItem env:}  -ComputerName <remote system>**

\(ツ)_/


Monday, September 30, 2019 5:06 AM

I want to get the environment variables of the remote machine(UWP) using TShell and save those details into a text file.I tried using below command its not working

cmdd "set" > "sample.txt"

File created but environment variable are not save in that,Instead its printing as Exit Code : 0

Any idea what wrong ?


Monday, September 30, 2019 5:16 AM

Invoke-Command -ScriptBlock {Get-ChildItem env:}  -ComputerName <remote system>

Above command not working its showing error message as 

"[minwinpc] Connecting to remote server minwinpc failed with the following error message : WinRM cannot process the request."

Below command works fine:-

-> cmdd "set"

But i am not able to write environment variables into a text file.I tried using below command

-> ** cmdd "set" > "sample.txt"**

Text file created but environment variable are not printing into it instead it printing as Exit Code :0

Any idea how to perform this?


Monday, September 30, 2019 5:22 AM

Please do not repost the same question multiple times. It will not get you an answer in this forum.

\(ツ)_/


Monday, September 30, 2019 5:27 AM

It is obvious that your IoT de3vice is not running Windows, PowerShell or WinRM. YOU need to post your issue in an IoT forum for your device and its OS.

\(ツ)_/


Thursday, October 3, 2019 2:10 AM

Hi,

Was your issue resolved?

If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

If no, please reply and tell us the current situation in order to provide further help.

Best Regards,

Lee

Just do it.