Weird characters in Powershell DSC File Contents -
i'm new powershell dsc , i'm writing script should ensure if file present correct content. it's simple:
file batfile { ensure = "present" destinationpath = $batpath contents = "start $($fullpath)" type = "file" } when open file in notepad, contents seem ok. however, when execute error message:
c:\directory>start c:\directory\appiwanttostart.exe 'start' not recognized internal or external command, operable program or batch file. suddenly there's these weird  characters in file! assume sort of encoding problem have no clue how solve this. know of way fix this?
edit: apparently these characters byte order mark (bom) , don't show in notepad due encoding. see this topic. question is: using dsc file resource, can write file content without bom?
(yes, i'm trying create batch script in powershell script. may weird, not relevant question!)
there's no encoding property file-resource , reason think writes using utf-16 w/bom. may try using script-resource.
script batfile { setscript = { "start $($fullpath)" | set-content -path $batpath -force } testscript = { test-path -path $batpath } getscript = { @{batfileexists = (test-path $batpath )} } }
Comments
Post a Comment