I want to set the local account photo (the image that shows up in the start menu and above the password prompt when logging in) using PowerShell and an image saved in a certain location.
the same as if you go to: Settings >> Accounts >> Your Info >> Create your picture >> Browse for one >> Go to "C:\custom-folder\img.jpg" >> select "okay"
Here is the script I started working on:
<#
.SYNOPSIS
Sets the specified image as the user's user photo
.PARAMETER Image
(Mandatory) Provide the exact path to the image
.EXAMPLE
setAccountPhoto.ps1 -Image "C:\custom-folder\img.jpg"
#>
param (
[parameter(Mandatory=$True)]
# Provide path to image
[string]$Image
)
$user = "$env:UserName"
Set-UserPhoto -Identity $user -PictureData ([System.IO.File]::ReadAllBytes($Image))
is the below needed?
rundll32.exe user32.dll, UpdatePerUserSystemParameters
Now I am trying this:
<#
.SYNOPSIS
Sets the specified image as the user's user photo
.PARAMETER Image
(Mandatory) Provide the exact path to the image
.EXAMPLE
setAccountPhoto.ps1 -Image "C:\custom-folder\img.jpg"
#>
param (
[parameter(Mandatory=$True)]
# Provide path to image
[string]$Image
)
$registryPath = "HKCU:\ ? "
$nameAttr = " ? "
Set-ItemProperty -Path $registryPath -Name $nameAttr -Value $Image
is the below needed?
rundll32.exe user32.dll, UpdatePerUserSystemParameters
I assume the second approach may be better but am too new to know.
Need help with what I should put for the question marks in my code? Or if there is a better way to do this. I am open to suggestions...