If you're using Invoke-Command to run a script block on your local machine, remove the -ComputerName parameter from the cmdlet.
How to run TpmVscMgr.exe (a 32-Bit utility) in a 64-Bit PoweShell Script
I need to run TpmVscMgr.exe, a utility that resides in C:\Windows\System32 (Windows 10), in a PowerShell script that runs in 64-bit mode.
Just straight-up calling the utility leads to an exception that says that the cmdlet cannot be found. I believe it's because TpmVscMgr.exe is a 32-bit utility, as witnessed by the fact that it resides in C:\Windows\System32 on my Windows 10 system.
I tried the following just to destroy a TPM slot for starters. It did not work.
Add-Type -AssemblyName PresentationFramework
[System.Windows.MessageBox]::Show('Test')
try
{
$32bitPSCode =
{
$tpmVscMgrFullyQualified = (Join-Path ([System.Environment]::SystemDirectory) "TpmVscMgr.exe")
$cmdLine = "$tpmVscMgrFullyQualified destroy /instance ROOT\SMARTCARDREADER\0000"
Invoke-Expression $cmdLine
}
Invoke-Command -ScriptBlock $32bitPSCode -ConfigurationName microsoft.powershell32 -ComputerName .
}
catch
{
[System.Windows.MessageBox]::Show($_)
}
This did not even lead to an exception. It just got into a hang, which ended with the following console message being shown.
PS C:\Users\michael.baldamus\Devel\Share> .\test.ps1
OK
[...] Connecting to remote server ... failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the
destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the
WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (...:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : CannotConnect,PSSessionStateBroken
Windows for business | Windows Server | User experience | PowerShell
2 answers
Sort by: Most helpful
-
-
MotoX80 36,401 Reputation points
2023-03-11T17:33:36.03+00:00 I believe it's because TpmVscMgr.exe is a 32-bit utility, as witnessed by the fact that it resides in C:\Windows\System32 on my Windows 10 system.
On a 64 bit Win10 machine, the System32 folder contains the 64 bit OS code where tpmvscmgr.exe resides. If you have a folder named C:\Windows\SysWOW64, then that folder contains the 32 bit "Windows On Windows" code that would allow you to run 32 bit programs on your 64 bit OS.
Your PC is most likely 64 bit. Just run "tpmvscmgr.exe /?" in a Powershell prompt and see if it runs.