MY PS Script:
$admin = "TEST"
$Password = ConvertTo-SecureString "Test12345" -AsPlainText -Force
$Credential = [PSCredential]::new( $admin, $Password)
if ($Credential -is [System.Management.Automation.PSCredential]) {
return "PS Credentials - true"
} else {
return "PS Credentials - false"
}
RESULT in PS ISE: enter image description here
MY NODE JS Script:
"use strict";
const { exec } = require("child_process");
exec(
"powershell.exe -File C:\\Users\\fschiller\\Desktop\\Projekt_Node\\Libary\\TEST.ps1",
(error, stdout, stderr) => {
console.log(stdout)
}
)
RESULT in VSCode from Node Script: enter image description here
I Dont know how to Fix it. Can Someone Help ? or know the Problem and how to work around it?
tried ExecFile, other ways to creat PSCredential Object, "terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "Bypass"]
It works if I specify the module to the full path -