Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.81k forks source link

[Feature]: Send-AzWvdUserSessionMessage to utilise Id property from Get-AzWvdUserSession #18134

Open robinmalik opened 2 years ago

robinmalik commented 2 years ago

Description of the new feature

Currently, use of Send-AzWvdUserSessionMessage is a touch cumbersome. In order to run it, you need to first get (at least) a session id from Get-AzWvdUserSession -ResourceGroupName RGNAME -HostPoolName HOSTPOOLNAME. Example returned object:

ActiveDirectoryUserName : DOMAIN\user
ApplicationType         : Desktop
CreateTime              : 12/05/2022 11:18:58
Id                      : /subscriptions/GUID/resourcegroups/RGNAME/providers/Microsoft.DesktopVirtualization/hostpools/HOSTPOOLNAME/sessionhosts/SESSIONHOSTNAME.domain.com/usersessions/6
Name                    : HOSTPOOLNAME/SESSIONHOSTNAME.domain.com/6
ObjectId                : 00000000-0000-0000-0000-000000000000
SessionState            : Active
Type                    : Microsoft.DesktopVirtualization/hostpools/sessionhosts/usersessions
UserPrincipalName       : user@domain.com

Based on this output (noting the absense of properties for UserSessionId or SessionHostName), an example of what must be then provided to send a message to a single user:

Send-AzWvdUserSessionMessage -ResourceGroupName RGNAME -HostPoolName HOSTPOOLNAME -SessionHostName SESSIONHOSTNAME.domain.com -UserSessionId 6 -MessageTitle 'This is a message from PowerShell' -messagebody 'Hello!'

This requires parsing properties from the output of Get-AzWvdUserSession for the UserSessionId and SessionHostName.

Proposed implementation details (optional)

The Id property on the object returned from Get-AzWvdUserSession contains enough data to pipe to Send-AzWvdUserSessionMessage; it contains the resource group name, the host pool name, the session host name and the id of the session.

To send a message to all users:

Get-AzWvdUserSession -ResourceGroupName RGNAME -HostPoolName HOSTPOOLNAME | Send-AzWvdUserSessionMessage -MessageTitle 'This is a message from PowerShell' -messagebody 'Hello!'

Failing pipeline support, an additional property could be added to the Send cmdlet, that accepts the Id value from the Get cmdlet.

Get-AzWvdUserSession -ResourceGroupName RGNAME -HostPoolName HOSTPOOLNAME | Foreach-Object { Send-AzWvdUserSessionMessage -NewPropertyName $_.Id -MessageTitle 'This is a message from PowerShell' -messagebody 'Hello!' }

ghost commented 2 years ago

Thank you for your feedback. This has been routed to the support team for assistance.

navba-MSFT commented 2 years ago

@robinmalik Apologies for the late reply. Thanks for reaching out to us and sharing this feedback. I am tagging the Service Team to look into this Feature Request ask.