Or, “API Basics for Powershelling Windows Admins”
My team has begun rolling out Cisco’s Webex Teams collaboration platform to our internal users. As is often the case, the IT department is the first customer, kicking the tires and exploring different use cases. I happened to be working on a Powershell-based script to create new Active Directory users, and decided to get creative …
- The Webex APIs provide your applications with direct access to the Cisco Webex Platform, giving you the ability to: Create a Webex space and invite people; Search for people in your company; Post messages in a Webex space; Get Webex space history or be notified in real-time when new messages are posted by others; Execute a command on a Webex RoomOS device.
- You may like: Microsoft Teams and Cisco Webex: The Best of Both Worlds. 4 – Host Webex meetings in Microsoft Teams. For users that prefer Microsoft Teams for messaging and collaboration, but must use Cisco Webex for meetings, there is the Cisco Webex Meeting app. This is perfect for running Cisco Webex meetings direct from Microsoft Teams.
Such a vital part of Cisco Spark needs an equally robust representation in the API, and we’re happy to announce the availability of the new /teams and /team resources. In this blog, we’ll walk you through a few of the typical use cases – creating a team and adding members to it, viewing the members of a team, removing a team membership.
While creating a Powershell process to automatically create new Active Directory users based on data sent via our HRIS system, I wanted a way to notify the Helpdesk team that a user had been added and they needed to do a few follow-up tasks (actions I can’t address via Powershell). I looked at having Powershell write logfiles or send e-mails. Old-fashioned.
Naturally, Webex Teams is fully API-enabled . As a non-developer, the most approachable methods I’d previously seen for addressing Teams via its API had been using Python. However, I found some clues for using Powershell in a Cisco DEVNET lesson introducing the Teams API (sign-in required).
With credit to this article, and through some modification, I got to scripting a sample:
Now to get this working, you’ll need some stuff:
- A Bot account (who’s going to post these messages [or take any other type of action])
- Create one here: https://developer.webex.com/my-apps/
- Your Bot’s access token (you’ll get one after you create the bot account)
- Room ID (where you’re posting the message to)
- Add your new bot to the Webex Teams space you want them to post in
- Look up the RoomID: https://developer.webex.com/docs/api/v1/rooms/list-rooms
- Hit the “Try It” button, and provide the Bearer (access token) of your Bot account; you’ll see each space the Bot is a member of. Copy the “Id”
In my sample above, I’m storing the Bot’s access token in a local text file, reading it in, and storing it as a SecureString to a variable. But you can equally just put it directly in the Bearer section of the Authorization header.
Cisco Webex Teams App For Iphone
Once you execute your code:
Webex Teams Documentation
Ultimately I ended up writing this whole process above as a Powershell function and calling it as needed during my User Creation script. Setting the text to a variable, and changing the contents as needed became easy.
Putting it into action:
Notification of a successful user creation
Conditional error, when licensing a user in Office365 fails.
Seeing how easy it was to cook this up, I’m inclined to try some of the other API actions in and out of Webex Teams using Powershell … you don’t have to be a developer to get dirty with APIs!