login vsi company logo login vsi company logo 250x40
  • Home
  • Blog
  • Login PI
  • How To: Login PI bulk administration through RESTfull API and Powershell

How To: Login PI bulk administration through RESTfull API and Powershell

Login PI

For a large Login PI deployment a method was needed to change the workload on all profiles. The Login PI RESTfull API (API) easily enables this. To get started create a Powershell script. For this blogpost the Windows Powershell ISE was used.

Code capture 1 Login PI

 

 

Create the variables that will be reused. In this case the PI base URL. This script will be ran directly on the PI server. This script assumes PI is installed on the default port 8080. These values will need to be changed if the PI server is configured for SSL. See https://loginvsi.zendesk.com/hc/en-us/articles/115004469265-Login-PI-Configure-Management-Console-for-SSL.

The second variable is the workload that the script will set on every profile. In this case one of the default workloads.

Code capture 2

 

 

Next the script will collect all the available profiles on the PI server. The script first defines where those profiles will be retrieved. The PI base URL was defined earlier. The profilesapi/profiles path was retrieved using a method that will be described in a future blog post.

Using the profiles API URL the script will retrieve all available profiles using the invoke-restmethod command. Note that UseDefaultCredentials is specified. Login PI uses authenticated API endpoints. This parameter specifies that the credentials of the user running the Powershell script should be passed to the API endpoint for authentication. This assumes that the user account running the script is a Login PI administrator. The profiles are stored in a variable for later use.

Code capture 3

 

 

Once all the available profiles are collected the script will iterate through the profiles. Using a so called for each loop each available profile in the collection of profiles is put in a variable so that each profile can be operated on separately.

Code capture 4

Inside the for each loop the ID of the profile is stored in a separate variable. Next the API URL used for setting the workload is defined. This URL is made up out of the PI base URL, the profile ID for the profile currently being processed by the for each loop and the URL path components for the API endpoint.

Login PI uses JSON as the syntax to define data. Powershell can convert a hashtable to a JSON object. So the script defines a hashtable with the appropriate names for the different fields expected by the workloadsettings API endpoint. Note the office language, operating system language and office version are hardcoded. These IDs can be determined by looking at the list of these values in the PI dashboard.

Code capture 5

Please note that your values can differ but are likely the same.

Once the JSON data is properly formatted by the ConvertTo-JSON command the API URL is called using Invoke-RestMethod using the UseDefaultCredentials parameter discussed earlier. The Invoke-RestMethod command is also configured to use content type JSON. This lets the API endpoint know that the data is in the JSON format/syntax. Last but not least the HTTP method PUT is used. The JSON data is attached in the body of the request.

Code capture 6

Finally the script will ask the PI server to parse the new workload. Using the same principles discussed earlier. A request URL is created out of the PI base URL, profile ID and API endpoint URL components. The resulting URL is then invoked using the POST method. No body is attached as the parseworkload API endpoint doesn’t require a body. It simply uses the profile ID that is part of the request URL to understand which workload to parse. Last but not least the script outputs on which profile the workload has been changed.

A future blogpost will describe how to enhance this script to allow a CSV file to potentially specify a different workload per profile.

Please note that much of the structure of this script was originally written by Henk Hofs. I merely adapted it to fit my needs.

Disclaimer: many of the API endpoints mentioned in this blog post are not supported. Meaning they may change from release to release. This blogpost is therefor provided AS-IS.

 

Our industry-standard software is built to help you avoid problems, lower costs and improve performance. Request a Quote or get your (free!) Trial below, and benefit from our award-winning services:

Request Quote Request Trial

 

 

About the author

Dennis Geerlings started at Login VSI about 4 years ago and worked as a consultant within Login Consultants. He supported multiple customers in migration projects. Presently, Dennis is support manager and lead consultant at Login VSI. In these roles he supports customers and partners in the US and Canada, co-develops the Login VSI product, and serves as a pre-sales engineer for enterprise customers. 


Tags: How-to, Login PI

Popular Blogs

login-vsi-vdi-performance-summit

The VDI Performance Summit - Virtual Conference and Expo

Visit the VDI Performance Summit to gain knowledge and experience about performance and tuning VDI, improving End-User Experience and IT service. Join us at the ONLY virtual event 100% dedicated to VDI performance and tuning | May 2, 2019 This 1-day event offers key-notes presented by the best VDI performance experts in the world, technical and business oriented breakout sessions, the possibility to chat with experts directly to discuss your own situation, and a virtual exhibit hall featuring… Continue Reading

Scalability testing Parallels Remote Application Server with Login VSI

Recently I went to VMworld in Barcelona where Login VSI had a booth on the expo... While I can’t remember exactly how many conversations I had - there had been so many that I lost my voice on day one. What was new this year is that quite a few people asked if our software is compatible with the solutions from Parallels specifically their Remote Application Server (RAS) (Datasheet). Continue Reading
Login VSI Blog Article - Microsoft Windows 10 Default FTA Associations - Teaser Image

Windows 10 Default File Type Associations and Login VSI

When Login VSI 4.1 was released, the majority of desktops were running Windows 7 and life was easy. We’d set the default filetype for an application and it would simply work. The default and industry standard workloads in Login VSI include launching and using Adobe Reader as part of the virtual user simulation. Because Login VSI doesn’t always know which version of Adobe Reader is installed, or where it’s installed, the workload relies on the file type association (FTA) for .pdf documents to be… Continue Reading
Login VSI - Press Release - IGEL - Login VSI Partner to Optimize End User Computing Experience Image

[Press Release] IGEL Partners with Login VSI to Optimize the End User Computing Experience

Login PI enables organizations to better protect the performance and availability of their IGEL OS-powered virtual desktop environments San Francisco, USA, Feb. 6, 2019: IGEL, a world leader in software-defined endpoint optimization and control solutions for the secure enterprise, today announced that it is partnering with Login VSI, provider of software solutions to test and actively monitor the performance and availability of virtual desktop environments, including VDI and… Continue Reading
Login VSI - Blog - Login PI Blog Teaser Image - Windows Virtual Desktop: How To Monitor User Experience With Login PI

Windows Virtual Desktop – How to Monitor User Experience?

Microsoft has just announced the public preview of their new Windows Virtual Desktop (WVD) offering at Microsoft Ignite on Tour in Amsterdam today. For those of you who’ve not followed the rumors or the private beta, here’s the outline... Continue Reading
Investigating Online Application Performance with Login PI

Investigating Online Application Performance with Login PI

As many companies do, we use a CRM system. Recently, I have been getting complaints about our cloud CRM system, Microsoft Dynamics, being slow. I tried to investigate this by shadowing one of our users to see what was wrong. As expected, everything was fast. 15 minutes later, the same user reported slowness again. How could I investigate this without bothering the users? Continue Reading
Cookie Settings