Jump to content

Update Computer Name with Logged on Username


Quenten Grasso
 Share

Recommended Posts

Hey Fellow PW users,

I've created a script which allows the system to change its name to %computername%-Current logged on username, which makes life a little easier when trying to remote to their computers on the remote control tool/Webapp.

To get started, create your script in the script editor, in my example,

Name: Update Computer Name with Logged on Username

Windows/Powershell Code: 

$pwqusers = quser | Select-Object -skip 1
$pwquserfmt = $pwqusers.substring(1,22).Trim() -join ","
Set-ItemProperty -Path "HKLM:\Software\MMSOFT Design\PC Monitor\" -Name ComputerName -Value "$env:computername-$pwquserfmt"

Click Save.

Next we create at new task,

Name: Update Computer Name with Logged on Username

Current Scope -> Windows Workstations

Enable Scheduling -> (I've set it to run once a day) Every weekday (Monday to Friday), starting on 12 August 2018 at 09:00 (Australia/Brisbane)

Scripts tab, Select/add your new script you just created and once that's done click save.

You can now run the task on demand as well which will update all of the PC's in your windows workstations scope to Computer Name-Logged on usernames

This works for RDSH hosts as well however it could get a bit of out hand if you have 5-10+ users logged in so I probably wouldn't recommend it to be used on servers.

I Hope this helps you somehow, these scripts/suggestions come with no warranty and I bear no responsibility if this breaks anything, use at your own risk etc..etc..

Cheers,

Quenten

Edited by Quenten Grasso
Link to comment
Share on other sites

  • 1 year later...

So I wanted the full display name so I have updated your script.

$dom = $env:userdomain
$getusr = quser | Select-Object -skip 1
$usr = $getusr.substring(1,22).Trim() -join ","
$display = ([adsi]"WinNT://$dom/$usr,user").fullname
Set-ItemProperty -Path "HKLM:\Software\MMSOFT Design\PC Monitor\" -Name ComputerName -Value "$env:computername - $display"

 

Link to comment
Share on other sites

  • 5 months later...
  • 3 weeks later...

I had written something similar resently and posted, I tested yours and I don't think your pulling in the last logged in user just machine name as I could not get to run, when you run this as a script in session 0 it does not get the current logged in user, it seems to be pulling in session 0 which is blank  

 

Also, If I may, I suggest you run at at each logon event, this way its always current for the current user on the machine 100% of the time.

Link to comment
Share on other sites

  • 10 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Similar Content

    • By Jamie Taylor
      Pulseway Client Portal now includes a built-in chat function that allows the end user to communicate directly with a technician. This can be started automatically as a step in a troubleshooter, or you can give users the option to start it directly themselves.   A summary of the chat is recorded and can be sent to the technician. Automation Workflows: Run assigned patch policy
      Start patching systems as they get added to Pulseway using the new Run Assigned Patch Policy action, now available for the System Registered workflow trigger.
      Remote Desktop Improvements
      Introducing Adaptive FPS to deliver the optimum resolution for the current network connection, resulting in an enhanced user experience.
       
    • By Tim Hall
      After receiving a verification on my phone I get this nasty gram.
       
      So far:
      .Net 4.0 install was blocked because a later version was already installed. So I don't think it is a .net version issue.
      Any help would be appreciated.
       
      --Tim

      I blocked out the server name to keep it annonymous
      I blocked out the server name to keep it anonymous. Also, please ignore the localhost:8443 page. It is irrelevant as far as I know.
    • By Jamie Taylor
      You can now trigger workflow executions from Performance Counter notifications and evaluate Name, Category and Instance in conditions to build even more customizable workflows for your IT processes.
    • By Jamie Taylor
      You can now create interactive, conditional troubleshooters that can be used to ask questions, provide answers, and run self remediation scripts and tasks based on user input. Pulseway's Client Portal can be used to standardize IT processes, empower end-users and reduce the workload on your support team.

       

       
    • By crakpot
      I would really like to see an outlook add-in that can be pushed through office 365 to all users that would allow them to submit tickets with drop down menus for ticket type, sub-type, priority and description. 
       
×
×
  • Create New...