in reply to Error compiling script running powershell command

One basic debugging trick in such a case is to put your command line in a string (between double quotes or within the qq// quoting construct if needed) and to try to print it. This way, you can see how Perl interpolates it and what exactly is being passed to the underlying shell (or powershell in your case):
my $string = qq/c:\\windows\\system32\\windowspowershell\\v1.0\\powers +hell.exe -command "Set-ADUser $un -Replace @{thumbnailPhoto=([Byte[]] +(Get-Content $jpeg -Encoding Byte))}"/; print $string;
Once your happy with the quoted string, put it back between backticks.