I'm trying to execute a command in Powershell 5.1, but it fails when the path contains Unicode characters.
For example:
(Get-Acl 'E:/test .txt').access
I'm running the command from Node.js:
let childProcess = require('child_process')
let testProcess = childProcess.spawn('powershell', [])
testProcess.stdin.setEncoding('utf-8')
testProcess.stdout.on('data', (data) => {
console.log(data.toString())
})
testProcess.stdout.on('error', (error) => {
console.log(error)
})
// This path is working, I get command output in the console:
// testProcess.stdin.write("(Get-Acl 'E:/test.txt').access\n");
// This path is not working. I get nothing in the console
testProcess.stdin.write("(Get-Acl 'E:/test .txt').access\n");
I cannot use Powershell 7 since I'm making a Node.js app that runs commands on the pre-installed Powershell
Update
This method seems to work:
childProcess.spawn(
'powershell',
['-Command', '(Get-Acl "E:/test .txt").access']
)