The following post will explain how to initiate a Microsoft Teams "Chat" action directly from the SMA console in the Inventory view or in a ticket using "Device Actions".
To be able to do this we will need to collect the email address of the person actually connected/logged-In to the machine. As this information is in the registry under HKCU, we will need a script that will collect this information so that we can use this information via a "Custom Inventory rule".
Here is how it will work with Microsoft Teams:
- you need to create a “script” that will run under the user context or all connected users to get the users email address.
- I use an “Online Script”, don't forget to check "Enabled" once you have tested and validated your script
- Select the machines or the "Smart labels" that you want to use to collect the users email address from
- Select the Operating Systems, probably "Windows 10 (All)
- Under "Windows Run-As": select "Logged-in user" or "All logged-in users" if multiple users can connect to the system
- Set to run at 5AM and check to run “Run on next connection if offline”
- Add a new Task. I go directly to "On Success" but it would better to check first if the folder where you want to write the result exist.
Here the command line that will get the actual email address of the current user from the registry under HKCU:
Launch “SYS\Powershell” with params “(Get-ItemProperty -Path ”HKCU:\Software\Microsoft\Office\16.0\Common\Identity“).ADUserName >c:\temp\UserName.txt”.
Please check first on your systems if this exist, otherwise you will need to search for a similar entry.
In my example this will write a text file “UserName.txt” in the temp folder.
** This will only work if this registry exist, so for other products he could be somewhere else!
The next step is to collect the email address stored in the UserName.txt file.
2. Create a Custom Inventory Rule (CIR) called “CIR-USERNAME” to get the content of the file:
- Go to "Inventory > Software" - Choose Action - New
- Enter the name listed below CIR-USERNAME, add a version and a Publisher
- Select your supported Operating systems
- Add the following command under "Custom Inventory Rule:"
- ShellCommandTextReturn(cmd.exe /C type c:\temp\username.txt)
The last step will be to create the Device Action that will be able to use the collected email address and run Microsoft Teams using the "sip" parameter.
3. Create your Device action:
- Go to "Settings › Control Panel › General Settings
- Nearly to the end you are able to add a Device Action
- Type in a Name like "Teams_Chat"
- Leave "Custom actions..." and add the following command line:
- C:\Users\%username%\AppData\Local\Microsoft\Teams\current\Teams.exe sip:KACE_CUSTOM_INVENTORY_CIR-USERNAME
** This will only work if Microsoft Teams is installed on the system running the SMA Console!
And this is how will look like in the Console:
In the Inventory View:
In a Ticket:
This will allow you to start TEAMS CHAT directly from the Kace Inventory console or from a ticket with the related user recorded in the associated Device inventory.