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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.