Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

PShell and Get-Member

Aug
2,799
144
Code does not work in v36, but worked in v35.

test.btm
Code:
pshell /s "$jlc = new-object -com jlcUtils.clsMath"
pshell /s "$jlc | Get-Member"

Code:
E:\Utils>ver

TCC  35.00.21 x64   Windows 10 [Version 10.0.19045.7058]

E:\Utils>r:\test.btm
pshell  /s "$jlc = new-object -com jlcUtils.clsMath"
pshell  /s "$jlc | Get-Member"


   TypeName: System.__ComObject#{6952cf31-c8e9-40a2-8e84-e3b7d2122072}

Name   MemberType Definition
----   ---------- ----------
ppp    Method     Variant ppp (Variant)
vb6Val Method     double vb6Val (string)
World  Method     Variant World (string)

Code:
R:\>ver

TCC  36.00.17 x64   Windows 10 [Version 10.0.19045.7058]

R:\>test.btm
pshell  /s "$jlc = new-object -com jlcUtils.clsMath"

pshell  /s "$jlc | Get-Member"
PSHELL: You must specify an object for the Get-Member cmdlet.

Joe
 
This demonstrates that there is no persistent PowerShell engine in v36.

Code:
R:\>pshell /s "$fso = New-Object -ComObject Scripting.FileSystemObject"


R:\>pshell /s "$fso | Get-Member"
PSHELL: You must specify an object for the Get-Member cmdlet.

R:\>ver

TCC  36.00.17 x64   Windows 10 [Version 10.0.19045.7058]

This demonstrates that there is a persistent PowerShell engine in v35.

Code:
TCC  35.00.21 x64   Windows 10 [Version 10.0.19045.7058]

R:\>pshell /s "$fso = New-Object -ComObject Scripting.FileSystemObject"

R:\>pshell /s "$fso | Get-Member"


   TypeName: System.__ComObject#{2a0b9d10-4b87-11d3-a97a-00104b365c9f}

Name                MemberType Definition
----                ---------- ----------
BuildPath           Method     string BuildPath (string, string)
CopyFile            Method     void CopyFile (string, string, bool)
CopyFolder          Method     void CopyFolder (string, string, bool)
CreateFolder        Method     IFolder CreateFolder (string)
CreateTextFile      Method     ITextStream CreateTextFile (string, bool, bool)
DeleteFile          Method     void DeleteFile (string, bool)
DeleteFolder        Method     void DeleteFolder (string, bool)
DriveExists         Method     bool DriveExists (string)
FileExists          Method     bool FileExists (string)
FolderExists        Method     bool FolderExists (string)
GetAbsolutePathName Method     string GetAbsolutePathName (string)
GetBaseName         Method     string GetBaseName (string)
GetDrive            Method     IDrive GetDrive (string)
GetDriveName        Method     string GetDriveName (string)
GetExtensionName    Method     string GetExtensionName (string)
GetFile             Method     IFile GetFile (string)
GetFileName         Method     string GetFileName (string)
GetFileVersion      Method     string GetFileVersion (string)
GetFolder           Method     IFolder GetFolder (string)
GetParentFolderName Method     string GetParentFolderName (string)
GetSpecialFolder    Method     IFolder GetSpecialFolder (SpecialFolderConst)
GetStandardStream   Method     ITextStream GetStandardStream (StandardStreamTypes, bool)
GetTempName         Method     string GetTempName ()
MoveFile            Method     void MoveFile (string, string)
MoveFolder          Method     void MoveFolder (string, string)
OpenTextFile        Method     ITextStream OpenTextFile (string, IOMode, bool, Tristate)
Drives              Property   IDriveCollection Drives () {get}

In v35 and v36,
this works as it should,
that is,
since the commands are being executed via test.ps1,
no persistent PowerShell is required.

Note well that in v36,
the Get-Member output format of PowerShell 5.1 is not replicated.

Code:
R:\>type test.ps1
$fso = New-Object -ComObject Scripting.FileSystemObject
$fso | Get-Member

R:\>pshell test.ps1
string BuildPath (string, string)
void CopyFile (string, string, bool)
void CopyFolder (string, string, bool)
IFolder CreateFolder (string)
ITextStream CreateTextFile (string, bool, bool)
void DeleteFile (string, bool)
void DeleteFolder (string, bool)
bool DriveExists (string)
bool FileExists (string)
bool FolderExists (string)
string GetAbsolutePathName (string)
string GetBaseName (string)
IDrive GetDrive (string)
string GetDriveName (string)
string GetExtensionName (string)
IFile GetFile (string)
string GetFileName (string)
string GetFileVersion (string)
IFolder GetFolder (string)
string GetParentFolderName (string)
IFolder GetSpecialFolder (SpecialFolderConst)
ITextStream GetStandardStream (StandardStreamTypes, bool)
string GetTempName ()
void MoveFile (string, string)
void MoveFolder (string, string)
ITextStream OpenTextFile (string, IOMode, bool, Tristate)
IDriveCollection Drives () {get}

Joe
 
Using PowerShell from TCC without a 3rd party .dll

This works for both PowerShell 5.1, and PowerShell 7.x


Joe
 
This demonstrates that there is no persistent PowerShell engine in v36.

Code:
R:\>pshell /s "$fso = New-Object -ComObject Scripting.FileSystemObject"


R:\>pshell /s "$fso | Get-Member"
PSHELL: You must specify an object for the Get-Member cmdlet.

R:\>ver

TCC  36.00.17 x64   Windows 10 [Version 10.0.19045.7058]

This demonstrates that there is a persistent PowerShell engine in v35.

Code:
TCC  35.00.21 x64   Windows 10 [Version 10.0.19045.7058]

R:\>pshell /s "$fso = New-Object -ComObject Scripting.FileSystemObject"

R:\>pshell /s "$fso | Get-Member"


   TypeName: System.__ComObject#{2a0b9d10-4b87-11d3-a97a-00104b365c9f}

Name                MemberType Definition
----                ---------- ----------
BuildPath           Method     string BuildPath (string, string)
CopyFile            Method     void CopyFile (string, string, bool)
CopyFolder          Method     void CopyFolder (string, string, bool)
CreateFolder        Method     IFolder CreateFolder (string)
CreateTextFile      Method     ITextStream CreateTextFile (string, bool, bool)
DeleteFile          Method     void DeleteFile (string, bool)
DeleteFolder        Method     void DeleteFolder (string, bool)
DriveExists         Method     bool DriveExists (string)
FileExists          Method     bool FileExists (string)
FolderExists        Method     bool FolderExists (string)
GetAbsolutePathName Method     string GetAbsolutePathName (string)
GetBaseName         Method     string GetBaseName (string)
GetDrive            Method     IDrive GetDrive (string)
GetDriveName        Method     string GetDriveName (string)
GetExtensionName    Method     string GetExtensionName (string)
GetFile             Method     IFile GetFile (string)
GetFileName         Method     string GetFileName (string)
GetFileVersion      Method     string GetFileVersion (string)
GetFolder           Method     IFolder GetFolder (string)
GetParentFolderName Method     string GetParentFolderName (string)
GetSpecialFolder    Method     IFolder GetSpecialFolder (SpecialFolderConst)
GetStandardStream   Method     ITextStream GetStandardStream (StandardStreamTypes, bool)
GetTempName         Method     string GetTempName ()
MoveFile            Method     void MoveFile (string, string)
MoveFolder          Method     void MoveFolder (string, string)
OpenTextFile        Method     ITextStream OpenTextFile (string, IOMode, bool, Tristate)
Drives              Property   IDriveCollection Drives () {get}

In v35 and v36,
this works as it should,
that is,
since the commands are being executed via test.ps1,
no persistent PowerShell is required.

Note well that in v36,
the Get-Member output format of PowerShell 5.1 is not replicated.

Code:
R:\>type test.ps1
$fso = New-Object -ComObject Scripting.FileSystemObject
$fso | Get-Member

R:\>pshell test.ps1
string BuildPath (string, string)
void CopyFile (string, string, bool)
void CopyFolder (string, string, bool)
IFolder CreateFolder (string)
ITextStream CreateTextFile (string, bool, bool)
void DeleteFile (string, bool)
void DeleteFolder (string, bool)
bool DriveExists (string)
bool FileExists (string)
bool FolderExists (string)
string GetAbsolutePathName (string)
string GetBaseName (string)
IDrive GetDrive (string)
string GetDriveName (string)
string GetExtensionName (string)
IFile GetFile (string)
string GetFileName (string)
string GetFileVersion (string)
IFolder GetFolder (string)
string GetParentFolderName (string)
IFolder GetSpecialFolder (SpecialFolderConst)
ITextStream GetStandardStream (StandardStreamTypes, bool)
string GetTempName ()
void MoveFile (string, string)
void MoveFolder (string, string)
ITextStream OpenTextFile (string, IOMode, bool, Tristate)
IDriveCollection Drives () {get}

Joe

This is what I get with build 18:

Code:
[D:\TakeCommand36\TCConsole]pshell /s "$fso = New-Object -ComObject Scripting.FileSystemObject"

[D:\TakeCommand36\TCConsole]pshell /s "$fso | Get-Member"
   TypeName: System.__ComObject#{2a0b9d10-4b87-11d3-a97a-00104b365c9f}
Name                MemberType Definition
----                ---------- ----------
BuildPath           Method     string BuildPath (string, string)
CopyFile            Method     void CopyFile (string, string, bool)
CopyFolder          Method     void CopyFolder (string, string, bool)
CreateFolder        Method     IFolder CreateFolder (string)
CreateTextFile      Method     ITextStream CreateTextFile (string, bool, bool)
DeleteFile          Method     void DeleteFile (string, bool)
DeleteFolder        Method     void DeleteFolder (string, bool)
DriveExists         Method     bool DriveExists (string)
FileExists          Method     bool FileExists (string)
FolderExists        Method     bool FolderExists (string)
GetAbsolutePathName Method     string GetAbsolutePathName (string)
GetBaseName         Method     string GetBaseName (string)
GetDrive            Method     IDrive GetDrive (string)
GetDriveName        Method     string GetDriveName (string)
GetExtensionName    Method     string GetExtensionName (string)
GetFile             Method     IFile GetFile (string)
GetFileName         Method     string GetFileName (string)
GetFileVersion      Method     string GetFileVersion (string)
GetFolder           Method     IFolder GetFolder (string)
GetParentFolderName Method     string GetParentFolderName (string)
GetSpecialFolder    Method     IFolder GetSpecialFolder (SpecialFolderConst)
GetStandardStream   Method     ITextStream GetStandardStream (StandardStreamTypes, bool)
GetTempName         Method     string GetTempName ()
MoveFile            Method     void MoveFile (string, string)
MoveFolder          Method     void MoveFolder (string, string)
OpenTextFile        Method     ITextStream OpenTextFile (string, IOMode, bool, Tristate)
Drives              Property   IDriveCollection Drives () {get}

[D:\TakeCommand36\TCConsole]
 
Thanks Rex.

Now, that's a persistent PowerShell.

I will test when Build 18 is available for download.

Code:
R:\>aiu
Getting File info for https://jpsoft.com/downloads/v36/TCMD.EXE
Name           : Take Command 36
Product Version: 36.0.17
Release Date   : 2026-04-04
Installed Vers : 36.00.17

1775504851141.webp


Joe
 
Still the same as build 17

Code:
E:\Utils>ver

TCC  36.00.18 x64   Windows 10 [Version 10.0.19045.7058]

E:\Utils>which pshell
pshell is an internal command

E:\Utils>pshell /s "$fso = New-Object -ComObject Scripting.FileSystemObject"

E:\Utils>pshell /s "$fso | Get-Member"
PSHELL: You must specify an object for the Get-Member cmdlet.

Maybe an issue with Debug Solution Configuration versus Release Solution Configuration in VS?

Joe
 
I tried this in the debug build & it worked. I tried it in the release build 18 and it failed. I rebuilt everything from scratch and tried it again in the release build and it worked. I think the MSVC compiler screwed up something during the batch builds and didn't get the latest code for all the modules.

Try it again when I post build 19.
 
Fixed in Build 19.

Code:
R:\>ver

TCC  36.00.19 x64   Windows 10 [Version 10.0.19045.7058]

R:\>which pshell
pshell is an internal command

R:\>pshell /s "$fso = New-Object -ComObject Scripting.FileSystemObject"

R:\>pshell /s "$fso | Get-Member"
   TypeName: System.__ComObject#{2a0b9d10-4b87-11d3-a97a-00104b365c9f}
Name                MemberType Definition
----                ---------- ----------
BuildPath           Method     string BuildPath (string, string)
CopyFile            Method     void CopyFile (string, string, bool)
CopyFolder          Method     void CopyFolder (string, string, bool)
CreateFolder        Method     IFolder CreateFolder (string)
CreateTextFile      Method     ITextStream CreateTextFile (string, bool, bool)
DeleteFile          Method     void DeleteFile (string, bool)
DeleteFolder        Method     void DeleteFolder (string, bool)
DriveExists         Method     bool DriveExists (string)
FileExists          Method     bool FileExists (string)
FolderExists        Method     bool FolderExists (string)
GetAbsolutePathName Method     string GetAbsolutePathName (string)
GetBaseName         Method     string GetBaseName (string)
GetDrive            Method     IDrive GetDrive (string)
GetDriveName        Method     string GetDriveName (string)
GetExtensionName    Method     string GetExtensionName (string)
GetFile             Method     IFile GetFile (string)
GetFileName         Method     string GetFileName (string)
GetFileVersion      Method     string GetFileVersion (string)
GetFolder           Method     IFolder GetFolder (string)
GetParentFolderName Method     string GetParentFolderName (string)
GetSpecialFolder    Method     IFolder GetSpecialFolder (SpecialFolderConst)
GetStandardStream   Method     ITextStream GetStandardStream (StandardStreamTypes, bool)
GetTempName         Method     string GetTempName ()
MoveFile            Method     void MoveFile (string, string)
MoveFolder          Method     void MoveFolder (string, string)
OpenTextFile        Method     ITextStream OpenTextFile (string, IOMode, bool, Tristate)
Drives              Property   IDriveCollection Drives () {get}
 
Back
Top