Tag Archives: Set-ADPhoto

I have always been careful to avoid the really advanced and cool stuff in Powershell, like functions, arrays and such. But as I created the last script it hit me that it would be really cool to have it in a command, like set-adphoto. After some googling I found that funtions aren’t hard at all! Basically all I really had to do with the ad photo import script was to add “function Set-ADPhoto { ” in front of the script and end it with a } But since I already was at it I decided to to a little more, I added some argument handling and a little help file. Here is the result: function Set-ADPhoto ($user,$photopath) { Import-Module active* $error = “The file is bigger than 12KB. Shrink it or choose another file” $file = Get-Item “$photopath” $filesize = $file.length/1KB if ($filesize -gt 12) { Write-Host $error } else {…

Read more