-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gather Host Pools Function #2
Comments
Please can you check you have the variable set up correctly, with the quotes and if you have two subscriptions to check they are separated by a comma Single Subscription Multiple Subscriptions Being unable to read the text value would suggest it is not getting the AVDSubscriptions value it expected |
So I put the correct Subscription ID. |
This sample code works fine to list user sessions and host pool. I can't reconcile getting the host name of each associated user. So I'd like to use your awesome code. This code works to get one of my host pools user sessions. Would this help in troubleshooting getting your code to work? I'm in SPRING edition. Even if I can just define one host pool that would help me. Please help. Add-Type -AssemblyName PresentationFramework Install required module if not already installedInstall-Module -Name Az.DesktopVirtualizationConnect to Azure accountConnect-AzAccount Set the context to the appropriate subscriptionSet-AzContext -SubscriptionId "53522dc9-55fa-48fa-a0e7-73d261d61f71" Set the target resource group$resourceGroupName = "RG-AVD" Create a simple WPF form$window = New-Object System.Windows.Window Create a ListView$listView = New-Object System.Windows.Controls.ListView Create columns for the ListView$listView.View.Columns.Add((New-Object System.Windows.Controls.GridViewColumn -Property @{Header = "User Session"; Width = 200; DisplayMemberBinding = New-Object System.Windows.Data.Binding 'UserPrincipalName'})) Get all AVD host pools in the specified resource group$avdHostPools = Get-AzWvdHostPool -ResourceGroupName $resourceGroupName Create an empty list to store the data$dataList = New-Object System.Collections.Generic.List[Object] Collect the user session dataif ($avdHostPools -ne $null) {
} else { Populate the ListView with data$dataList | ForEach-Object { Double-click event handler$listView.Add_MouseDoubleClick({ $window.Content = $listView Display the window$window.ShowDialog() | Out-Null |
I have spotted my error and will provided an updated script as soon as I can Plus, I unfortunately gave you the wrong info regarding what to set the Azure Subscription value too, its not the Subscription ID its the Subscription name Single Subscription Multiple Subscriptions |
Thank you so much. Can't wait for the modifications! Anxiousyly await. Thank you so much for your time. |
If it helps I am now getting this: Here is the current code I am using:
##################################################################################################> Variables \ ArraysAzure Tenant ID$AzureTenantId = "f85022b3-aee6-4cd6-a422-37509aec617f" Subscriptions Hosting AVD Environments$AVDSubscriptions = @('LAMPS PLUS') Import Required PowerShell Modulescls Validate VariablesAzureTenantIdIf (!( SubscriptionsIf ($AVDSubscriptions -eq 'LAMPS PLUS') { If ($AVDSubscriptions.Count -eq 0) { $WindowPadSubs = 0 Check to see if Remote Assistance is installed$UseMSTSC = $false Log into AzureWrite-Host ; Write-Host $(Get-Date -Format HH:mm:ss:) -ForegroundColor Gray -NoNewLine ; Write-Host " Log into Azure" Launch Shadow Selector WindowsWrite-Host ; Write-Host $(Get-Date -Format HH:mm:ss:) -ForegroundColor Gray -NoNewLine ; Write-Host " Launching Shadow Selector Screen" $ShadowUser = New-Object system.Windows.Forms.Form $Subscriptions_Label = New-Object system.windows.forms.label If ($AVDSubscriptions.Count -gt 1) {
$HostPool_Label = New-Object system.windows.forms.label $HostPool = New-Object system.Windows.Forms.ComboBox $UserSession_Label = New-Object system.windows.forms.label $UserSession = New-Object system.Windows.Forms.ComboBox #Hidden Value to calculate Session Host the User is connected too #Hidden Value to calculate the Session ID of the Users Session $TakeControl = New-Object system.Windows.Forms.CheckBox $Shadow = New-Object system.Windows.Forms.Button $ShadowUser.controls.Clear() If ($AVDSubscriptions.Count -gt 1) { $HostPool.Add_SelectedValueChanged({ HostPoolSelected }) $UserSession.Add_SelectedValueChanged({ $Shadow.enabled = $true }) $Shadow.Add_Click({ ShadowUserSession }) FunctionsFunction Gather_HostPools {
Function HostPoolSelected {
Function ShadowUserSession {
[void]$ShadowUser.ShowDialog() |
Please download the new version I have just uploaded, should say v3.1 |
Awesome. Thank you. Gather_HostPools : The term 'Gather_HostPools' is not recognized as the name of a cmdlet, function, script file, or operable program.
|
Ok, can you do this while I work out the issue Where you set the Subscription replicate the subscription name so you variable will look like this $AVDSubscriptions = @('LAMPS PLUS','LAMPS PLUS') This is currently working for me and I'll look into the issue when only one subscription is listed |
Here is a sample script I was working on that has no problem getting the active user sessions and host pool. Maybe this will help with your current code to make a fix? If not maybe you can tell me how to take what this script outputs but add something to get the corresponding host name to the active user session? Once I have the host name and session ID filled I can combine with your code. But I can't get those two fields. Either your script or a fix for mine and I'd be all set. Dedicating my day to this so let me know. Thanks again for the prompt responses. My sample code I was working on to fix yours. This gets the sessions and host-pool I define, which would be find to have a seperate script for each host-pool in my use case. Add-Type -AssemblyName PresentationFramework Install required module if not already installedInstall-Module -Name Az.DesktopVirtualizationConnect to Azure accountConnect-AzAccount Set the context to the appropriate subscriptionSet-AzContext -SubscriptionId "53522dc9-55fa-48fa-a0e7-73d261d61f71" Set the target resource group$resourceGroupName = "RG-AVD" Create a simple WPF form$window = New-Object System.Windows.Window Create a ListView$listView = New-Object System.Windows.Controls.ListView Create columns for the ListView$listView.View.Columns.Add((New-Object System.Windows.Controls.GridViewColumn -Property @{Header = "User Session"; Width = 200; DisplayMemberBinding = New-Object System.Windows.Data.Binding 'UserPrincipalName'})) Get all AVD host pools in the specified resource group$avdHostPools = Get-AzWvdHostPool -ResourceGroupName $resourceGroupName Create an empty list to store the data$dataList = New-Object System.Collections.Generic.List[Object] Collect the user session dataif ($avdHostPools -ne $null) {
} else { Populate the ListView with data$dataList | ForEach-Object { Double-click event handler$listView.Add_MouseDoubleClick({ $window.Content = $listView Display the window$window.ShowDialog() | Out-Null |
Changes to the connection commands in the AZ Module required a change to the commands used to connect to the correct subscription New version of the script uploaded |
Hi Gary it works great. I may be adding a refresh button and some search functions, if I do I will send your way. Currently, it works but if I switch between host pools after 1 successfully loads the whole thing freezes. GUI and Console freeze, with no error. I tried waiting a long time and also my session lists aren't that large. Any thoughts on fixing that? With that fixed, the rest will be smooth sailing. |
Hi Gary, Maybe you can revise it to fetch ALL host pool's active sessions and store them so they are cached? Then just add a refresh button? I tried but I'm failing. Could you perhaps do that? I'd be willing to send you some cash do make these changes! Let me know your thoughts. Thanks, |
I'll take a look and see what the options are |
I get the following error and I have the variables correctly set. Please help. I really want to use this code then implement for a big client.
The property 'text' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\ericd\Downloads\New Script\AVD Shadowing.ps1:243 char:5
Gather_HostPools : The term 'Gather_HostPools' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At C:\Users\ericd\Downloads\New Script\AVD Shadowing.ps1:245 char:5
The text was updated successfully, but these errors were encountered: