As far as I can tell, perl really ought to treat the "command" as a string and not attempt to compile it.
Did you expect it to leave $un and $jpeg untranslated as well? Or did you expect perl to parse it and replace it with the contents of those variables?
I suspect something similar it going on here. for some reason it is checking Byte (or maybe its the @{...}) as a replaceable part and then finds [] which it doesnt like.
i would do something like this.
my $command='Set-ADUser '.$un.' -Replace @{thumbnailPhoto=([Byte[]](Ge +t-Content '.$jpeg.' -Encoding Byte))}'; my $result = `c:\\windows\\system32\\windowspowershell\\v1.0\\powershe +ll.exe -command "$command"`;
In reply to Re: Error compiling script running powershell command
by huck
in thread Error compiling script running powershell command
by sweetblood
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |