xben Posted January 22, 2022 Posted January 22, 2022 Hi Guys, I though I would begin to write a couple of post on how I manage certain things in Pulseway. I love Pulseway it is a good product so far but some features are lacking and those scripts makes life way easier, at least for me. If you find that post helpful let me know and I will post more of my scripts on how I manage stuff. You are also more then welcome to let me know how you do it or any amelioration suggestions. Disclaimer : I am not a programmer at all so bare whit me on the coding part LOL To name computers I though it was essential that I could put a description in it so I made a custom field noteinname for Per Systems. So when I need to have a description on the machine I add the custom field to it. In that example LAB VM. Then I also thought that I really wanted the username in the name and Pulseway support gave me a script for that but when no user are logged in it removes the name. So I script it to put the last logged in user if no users were logged in. That way you can also search for the username when looking for an agent. Here is the script I use. After that I created a task to rename the computers every day. That's it. Works perfectly. $user1 = quser | Select-Object -skip 1 #Adds a - to $notes if not empty if (!$notes){ write-output "-- Not modifying variable Notes NULL" }else{ write-output "-- Notes not NULL adding a -" $notes= "-$notes" } if (!$user1) { write-output '-- No user connected applying lastlogged user' $user2 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI' -Name LastLoggedOnUser ` | Select-Object -ExpandProperty LastLoggedOnUser $user2mod = $user2 -creplace '^[^\\]*\\', '' write-output "-- Name to be applied $env:computername$notes-$user2mod" Set-ItemProperty -Path "HKLM:\Software\MMSOFT Design\PC Monitor\" -Name ComputerName -Value "$env:computername$notes-$user2mod" } else { write-output '-- A user is logged applying logged username' $user1mod = $user1.substring(1,22).Trim() -join "," write-output "-- Name to be applied $env:computername$notes-$user1mod" Set-ItemProperty -Path "HKLM:\Software\MMSOFT Design\PC Monitor\" -Name ComputerName -Value "$env:computername$notes-$user1mod" } Here is the result. Hope this helps ! Cheers. Jamie Taylor 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now