Load image from base64

Hey everyone,

Was hoping one of y’all can point me to the right path in how to load an image in the dash from base64 return from an Invoke-WebRequest?


Product: PowerShell Universal
Version: 2.0.3

Here you go:

    New-UDDynamic -Content {
        $image = [Convert]::ToBase64String((invoke-webrequest https://gblobscdn.gitbook.com/assets%2F-M6jY7sXTmhiAIMGYw_m%2F-M6k3eif5x0rsco6R228%2F-M6k3lT9Jj6A2nByJvbp%2Fimage.png).content)

        New-UDHTML -Markup "<img src='data:image/png;base64,$image' />"


Will this work with UDListItem under -Icon ?

It should work. You might need to mess with the width and height to get it to look right

I tried that way and different way by using New-UDImage but still got same error for both

New-UDListItem -Label "Hi $Session:currentuser!" -Icon (New-UDDynamic -Content {New-UDHTML -Markup "<img src='data:image/jpeg;base64,$Session:base64img' />"})
New-UDListItem -Label "Hi $Session:currentuser!" -Icon (New-UDImage -Url "http://localhost:5000/usravatar/16d3bdf5-65a8-4d2c-8b36-251a27de5cb9.jpeg")
An error occurred: Cannot bind argument to parameter 'Icon', because PSTypeNames of the argument do not match the PSTypeName required by the parameter: UniversalDashboard.Icon.
Endpoint: nav467f7e34-0ff4-40ed-a5d6-4869379d079c
Session: 0d324fc9-8aee-41ff-be32-9c97f913f5d7
File: C:\ProgramData\UniversalAutomation\Repository\NOC.ps1
Endpoint Start Line: 4
Endpoint End Line: 32
Stack Trace: at <ScriptBlock>, <No file>: line 7

Ah, whoops. We have some validation in the PS1 that is preventing this from working. Really no reason for it though so I can get that removed so it works in the next version.

:grinning_face_with_smiling_eyes: No worries. Really appreciate your responses.

How can I follow next releases ?

I will post on the forum when a new release comes out. 2.1.0 should be out next week.

In the mean time, if you want to work around this, you can edit the PSM1 file directly. You need to remove the PSType attribute from the $Icon parameter. The UniversalDashboard.MaterialUI.psm1 file is located in the installation directory here.

Here’s the edit that will need to be made.

OMG!! Thank you so much!!

Is so kool seeing this simple thing working. Now all it needs, is make the pic round

before login

after login