我正在尝试加载ps.command来执行powershell函数,因为我需要先加载ps文件,然后执行我的函数。
ps.addCommand(“。。\ New-SecurePassword.ps1)///文件名 ps.addCommand(“ New-Password)///函数名称
function App(){
// Create the PS Instance
let ps = new powershell({
executionPolicy: 'unrestricted',
noProfile: true
})
ps.addCommand(". .\New-SecurePassword.ps1")
ps.addCommand("New-Password.ps1")
ps.invoke()
.then(output => {
console.log(output);
})
.catch(err => {
console.log(err);
});
}
return App();
我遇到以下错误
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:3
+ . .New-SecurePassword.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (.New-SecurePassword.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException