I had a little issue recently when applying the WVD Spring Scaling script.
I went ahead and followed the instructions on the official Microsoft site:
The script installed fine and I had everything set up and ready to go. Set the relevant settings in my Log App and went ahead with a quick test. All good so far!
Then I experienced a problem where the Session Hosts did shutdown, but I did not get the user message. . . . very odd.
I had a look in the logs for the scaling job and could see the job completed, but there were some warnings that it:
Failed to send a log off message and Failed to force log off user
Looking at the warning details I could see the issue was that the User Session ID could not be found?
I loaded up PowerShell and tried to send a message myself using the Send-AzWVDUserSessionMessage command and found I too could not send a message! But I could via the Azure Portal!
After a bit of digging around it appeared that the issue was being caused by the Session Host name.
My Session host was named using capitals as in: SESSIONHOST.domain.com. It appears that the Send-AzWVDUserSessionMessage command is annoyingly case sensitive when it comes to the Session Host name.
If I entered the Session Host name case sensitive then it sent without issue.
Therefore, I had to quickly delve into the code of the Scaling script to resolve this.
In the Scaling script I found on Line 481 that the Session Host name was being obtained via the Get-SessionHostName function but then being converted to lower case.
To resolve my issue I simply removed the .ToLower() from the end of the line.
I saved and published the script and tested. . . . success!