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)
- Save
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.
I may use a slightly different method to get the CIR Item in my environment, but huge thanks for posting this. - Honkytonk 4 years ago
The user's details (user.name@domain.com) are being found and passed in as a CIR. If I run the custom action manually through CLI it opens them up straight away. If I run the custom action Teams loads but says 'We weren't able to find that Content'.
If I check the CIR item in the machine, the item shows as 'user.name@domain.com [string]' - is the [string] element causing this to not work, and if so, how did you get around that issue? - Honkytonk 4 years ago
On which SMA version are you? I am on 10.1.99. Otherwise the syntax is very important when you create your device Action and how you get your CIR.
When I look at the CIR in my inventory, there is no ' sign at the beginning and at the end. It does show like this: 1) CIR-USERNAME: first.last@company.com [string].
You said that you are using a "slightly" different method to get the CIR. Could you let me know what you are doing? unless to tried already my way and there is no difference. I tested again right now and it does work. - OlivierH 4 years ago
Your CI looks identical to mine, I just included the 'quotes' to delimit it here. So there's absolutely nothing wrong with your instructions here, which is good news. :)
My SMA is on the Beta testing 10.2.211, so that could be the cause - I'll run the .231 update that's advertised on my console and let you know if it makes a difference. - Honkytonk 4 years ago
Here is the error I am getting:
Alert
Device actions can only be requested from Windows computers that are currently in inventory.
Any ideas? - civilnj 3 years ago
I had high hopes for this...
-Jim - civilnj 1 year ago