Well $env:USERNAME relies on the current user and Pulseway runs in the context of the SYSTEM account. Try using this instead:
$user= get-wmiobject -class win32_computersystem | select-object username
wmic UserAccount where name=$user set Passwordexpires=true
$username = $user.username
if ($username -like '*\*')
{
$idx = $username.LastIndexOf('\')
$username = $username.Substring($idx + 1)
}
net user $username /logonpasswordchg:yes
It just removes the domain name or computer name from the username you get from WMI.
-Paul