The following snippet should upload an image to Active Directory. The powershell command runs from a cmd prompt fine, howerver I get a syntax error during compilation when I try to run from my perl script. As far as I can tell, perl really ought to treat the "command" as a string and not attempt to compile it.
#!/usr/bin/perl -w
use strict;
my $un = 'steve gilbert';
my $jpeg = 'v:/employee photos/out/steve gilbert.jpg';
my $result = `c:\\windows\\system32\\windowspowershell\\v1.0\\powershe
+ll.exe -command "Set-ADUser $un -Replace @{thumbnailPhoto=([Byte[]](G
+et-Content $jpeg -Encoding Byte))}"`;
I have tried various forms of the string, but I still receive the following error message. I have a feeling that this is one of those really simple bugs that 2 eyes are just not enough to see. If anyone else sees something please let me know.
Thanks!
syntax error at C:\Users\steveg\adimg-test.pl line 5, near "Byte["
Execution of C:\Users\steveg\adimg-test.pl aborted due to compilation
+errors.