Skip to content

awakecoding/pwsh-native-host

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PowerShell Native Host

Getting Started

Install PowerShell 7.2.0-preview6 or later for the required LoadAssemblyFromNativeMemory function, then export the PowerShell base installation path:

$Env:PWSH_BASE_PATH="${Env:ProgramFiles}\PowerShell\7-preview"
$Env:PWSH_BASE_PATH="/opt/microsoft/powershell/7-preview"

Build the PowerShell native host program:

mkdir build && cd build
cmake ..
cmake --build .
.\native-host app
mkdir build && cd build
cmake -G "Visual Studio 16 2019" -A x64 ..
cmake --build . --config Release
.\Release\native-host.exe lib

The application native host loads pwsh.exe and launches it with its command-line interface, yet it will not spawn a subprocess: it literally loads the PowerShell application to execute it within the current process. This is useful to avoid leaking sensitive data in command-line parameters.

The library native host loads the PowerShell SDK APIs and calls a few functions for testing.

References

About

pwsh native host experiment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published