So, I have this:
Set-ItemProperty -Path "HKLM:\Software\MMSOFT Design\PC Monitor\" -Name ComputerName -Value "$env:UserName"
Which works great from the local machine via PowerShell,
However, when I try to run this as a script/task, the name just shows up as "HOSTNAME$"
Any ideas why?
Ok, that makes more sense. In that case I needed to take advantage of WMI.
My final code is this, which works great!
$temp = Get-WmiObject -Class Win32_ComputerSystem | Select-Object -ExpandProperty username
$UserName = $temp -replace ".*\\", ""
Set-ItemProperty -Path "HKLM:\Software\MMSOFT Design\PC Monitor\" -Name ComputerName -Value "$UserName"
Thanks for the help!