Currently logged in user could be different from the current console user (I am using a rmm terminal logged in as a system user, not the desktop logged user)
I suggest to modify:
$currentUserName = (Get-WmiObject -Class Win32_ComputerSystem).UserName
into
$currentUserName = whoami
Currently logged in user could be different from the current console user (I am using a rmm terminal logged in as a system user, not the desktop logged user) I suggest to modify:
$currentUserName = (Get-WmiObject -Class Win32_ComputerSystem).UserName
into$currentUserName = whoami