- Aug
- 2,134
- 92
I discovered something by accident today.
I am using;
In my Powershell profile, C:\Users\jlc\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1, I have, for example, the following function;
If I do the following from TCC;
...the environment variable that I just set in PowerShell via my CDate function is also set in TCC.
Now, if I do;
followed by;
...the environment variable is still set in Powershell, even though I have closed the Powershell interpreter.
From TCC, if I do;
...then from TCC;
...the environment variable that I just set in TCC has also been set in PowerShell.
I have no problem with this, as it eliminates the use of @execstr for getting the output of a PowerShell function, but is this WAD?
Joe
I am using;
Code:
c:\users\jlc\utils>ver
TCC 24.02.46 x64 Windows 7 [Version 6.1.7601]
In my Powershell profile, C:\Users\jlc\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1, I have, for example, the following function;
Code:
function CDate
{
param ([string]$theDate)
$bdate = Get-Date -format D $theDate
$env:cdate=$bdate
}
If I do the following from TCC;
Code:
c:\users\jlc\utils>pshell /c
c:\users\jlc\utils>pshell /s "cdate %_isodate"
c:\users\jlc\utils>echo %cdate
Saturday, March 30, 2019
...the environment variable that I just set in PowerShell via my CDate function is also set in TCC.
Now, if I do;
Code:
c:\users\jlc\utils>pshell /c
Code:
c:\users\jlc\utils>pshell /s "$env:cdate"
Saturday, March 30, 2019
From TCC, if I do;
Code:
c:\users\jlc\utils>set cdate=jajb
c:\users\jlc\utils>echo %cdate
jajb
...then from TCC;
Code:
c:\users\jlc\utils>pshell /s "$env:cdate"
jajb
...the environment variable that I just set in TCC has also been set in PowerShell.
I have no problem with this, as it eliminates the use of @execstr for getting the output of a PowerShell function, but is this WAD?
Joe