Trying to pipe Get-AzWvdUserSession result to Send-AzWvdUserSessionMessage, can't pass session ID...

%3CLINGO-SUB%20id%3D%22lingo-sub-1404391%22%20slang%3D%22en-US%22%3ETrying%20to%20pipe%20Get-AzWvdUserSession%20result%20to%20Send-AzWvdUserSessionMessage%2C%20can't%20pass%20session%20ID...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1404391%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20rebuild%20equivalent%20scripts%20that%20I%20did%20for%20fall%202019%20module%2C%20but%20I%20get%20an%20issue%20with%20the%20send%26nbsp%3BSend-AzWvdUserSessionMessage.%26nbsp%3B%20%26nbsp%3B%20I%20want%20to%20get%20all%20sessions%20from%20a%20specific%20session%20host%20and%20send%20them%20a%20message%20on%20the%20screen.%26nbsp%3B%20The%20only%20parameter%20that%20blocks%20me%20it%20the%20session%20ID%2C%20it%20does%20not%20accept%20the%20format%20of%20the%20session%20ID%20variable%20provided%20by%26nbsp%3BGet-AzWvdUserSession.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20the%20example%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3EGet-AzWvdUserSession%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EResourceGroupName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3EResourceGroupName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EHostpoolName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3EHostPoolName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ESessionHostName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3EPoolTest1vm-0.solulan.int%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%7C%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EForEach-Object%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3CSPAN%3ESend-AzWvdUserSessionMessage%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EResourceGroupName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3EResourceGroupName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EHostPoolName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3EHostPoolName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ESubscriptionId%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3ESubscriptionID%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ESessionHostName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3ESessionHostName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EUserSessionId%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3E_.Id%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EMessageTitle%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3EWatchout!%26nbsp%3BYOu%26nbsp%3Bneed%26nbsp%3Bto%26nbsp%3Blogoff%26nbsp%3Bin%26nbsp%3B60%26nbsp%3Bsecondes%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EMessageBody%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3EGood%26nbsp%3Bbye!%26nbsp%3B%26nbsp%3Bsee%26nbsp%3Byou%26nbsp%3Blater%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20get%20the%20following%20error%20message%3A%26nbsp%3BSend-AzWvdUserSessionMessage%20%3A%20The%20server%20responded%20with%20a%20Request%20Error%2C%20Status%3A%20NotFound...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20manually%20set%20the%20session%20ID%20with%20only%20the%20session%20number%20(3)%2C%20it%20work%2C%20but%20it%20becomes%20useless%20to%20script%20that.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20idea%20what%20am%20I%20doing%20wrong%3F%20or%20if%20it%20is%20a%20bug%20that%20needs%20to%20be%20addressed%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1421243%22%20slang%3D%22en-US%22%3ERe%3A%20Trying%20to%20pipe%20Get-AzWvdUserSession%20result%20to%20Send-AzWvdUserSessionMessage%2C%20can't%20pass%20session%20I%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1421243%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F158374%22%20target%3D%22_blank%22%3E%40Patrick%20Brodeur%3C%2FA%3E%26nbsp%3BIt%20looks%20like%20you%20need%20to%20use%20just%20the%20session%20number%20at%20the%20end%20of%20that%20long%20string.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CSPAN%3EGet-AzWvdUserSession%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EResourceGroupName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3EResourceGroupName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EHostpoolName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3EHostPoolName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ESessionHostName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3EPoolTest1vm-0.solulan.int%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%7C%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EForEach-Object%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3CSPAN%3ESend-AzWvdUserSessionMessage%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EResourceGroupName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3EResourceGroupName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EHostPoolName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3EHostPoolName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ESubscriptionId%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3ESubscriptionID%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ESessionHostName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3ESessionHostName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EUserSessionId%20(%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3E_.Id%20-split%20'%2F')%5B-1%5D%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EMessageTitle%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3EWatchout!%26nbsp%3BYOu%26nbsp%3Bneed%26nbsp%3Bto%26nbsp%3Blogoff%26nbsp%3Bin%26nbsp%3B60%26nbsp%3Bsecondes%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EMessageBody%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3EGood%26nbsp%3Bbye!%26nbsp%3B%26nbsp%3Bsee%26nbsp%3Byou%26nbsp%3Blater%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1421451%22%20slang%3D%22en-US%22%3ERe%3A%20Trying%20to%20pipe%20Get-AzWvdUserSession%20result%20to%20Send-AzWvdUserSessionMessage%2C%20can't%20pass%20session%20I%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1421451%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F440658%22%20target%3D%22_blank%22%3E%40bakegreg%3C%2FA%3E%26nbsp%3B%20%26nbsp%3BThank%20you!%26nbsp%3B%20I%20was%20thinking%20about%20doing%20something%20like%20this%20to%20get%20the%20session%20number%20out%20of%20the%20string%2C%20but%20not%20very%20good%20yet%20at%20it.%26nbsp%3B%20I%20was%20about%20to%20study%20that%20tomorrow%2C%20but%20thanks%20you%20found%20it%20for%20me!%26nbsp%3B%20%26nbsp%3BI'll%20try%20it%20and%20give%20you%20some%20news%20in%20dew%20days.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hi,

 

I'm trying to rebuild equivalent scripts that I did for fall 2019 module, but I get an issue with the send Send-AzWvdUserSessionMessage.    I want to get all sessions from a specific session host and send them a message on the screen.  The only parameter that blocks me it the session ID, it does not accept the format of the session ID variable provided by Get-AzWvdUserSession.

 

Here is the example:

 

Get-AzWvdUserSession -ResourceGroupName $ResourceGroupName -HostpoolName $HostPoolName -SessionHostName "PoolTest1vm-0.solulan.int" | ForEach-Object {Send-AzWvdUserSessionMessage -ResourceGroupName $ResourceGroupName -HostPoolName $HostPoolName -SubscriptionId $SubscriptionID -SessionHostName $SessionHostName -UserSessionId $_.Id -MessageTitle "Watchout! YOu need to logoff in 60 secondes" -MessageBody "Good bye!  see you later"
}

 

I get the following error message: Send-AzWvdUserSessionMessage : The server responded with a Request Error, Status: NotFound...

 

If I manually set the session ID with only the session number (3), it work, but it becomes useless to script that.

 

Any idea what am I doing wrong? or if it is a bug that needs to be addressed?

 

Thanks!

 

 

 

 

 

 

2 Replies
Highlighted

@Patrick Brodeur It looks like you need to use just the session number at the end of that long string.

 

Get-AzWvdUserSession -ResourceGroupName $ResourceGroupName -HostpoolName $HostPoolName -SessionHostName "PoolTest1vm-0.solulan.int" | ForEach-Object {Send-AzWvdUserSessionMessage -ResourceGroupName $ResourceGroupName -HostPoolName $HostPoolName -SubscriptionId $SubscriptionID -SessionHostName $SessionHostName -UserSessionId ($_.Id -split '/')[-1] -MessageTitle "Watchout! YOu need to logoff in 60 secondes" -MessageBody "Good bye!  see you later"
}
Highlighted

@bakegreg   Thank you!  I was thinking about doing something like this to get the session number out of the string, but not very good yet at it.  I was about to study that tomorrow, but thanks you found it for me!   I'll try it and give you some news in dew days.