Ok something so simple is just not working for me. I got a cmdlet that accepts a single parameter. I am trying to call a cmdlet within a Windows batch file. The batch fil
The problem is in the ps1 file - you declare a function but you don't call it. I would modify it like this:
param($path)
function convert-utf8-to-utf16 {
$tempfile = "C:\temp.txt"
set-ExecutionPolicy Unrestricted
get-content -Path $args[0] -encoding utf8 | out-file $tempfile -encoding Unicode
set-ExecutionPolicy Restricted
}
convert-utf8-to-utf16 $path
it will work. However, it is not needed, you can simply ommit the function declaration and move the body into the script itself:
param($path)
$tempfile = "C:\temp.txt"
set-ExecutionPolicy Unrestricted
get-content -Path $path -encoding utf8 | out-file $tempfile -encoding Unicode
set-ExecutionPolicy Restricted