Yes it is, it's under (Get-hvlocalsession).id
So I guess that if I filter out the id I can do something like this after;
(Get-hvlocalsession).id.Session_LogoffForced
But What I'm wondering here is how can I past the ID that I want to that line of code that are disconnecting them?
$SessionID = (Get-hvlocalsession).id
(Get-hvlocalsession).id.Session_LogoffForced.$SessionID
or is it wrong? This is what I can't understand.
Like for this script example, I don't want it to ask Q or similare just disconnect the user and get the information from Variable.
$Username and $Session
$hvserver1=connect-hvserver servername -user user -domain domain -password passwords
$Services1= $hvServer1.ExtensionData
$username= Read-Host "Which user do you want to logoff? (no wildcards needed, part of the name is enough)"
$queryService = New-Object VMware.Hv.QueryServiceService
$userdefn = New-Object VMware.Hv.QueryDefinition
$userdefn.queryEntityType = 'ADUserOrGroupSummaryView'
$userfilter1= New-Object VMware.Hv.QueryFilterContains
$userfilter1.membername='base.name'
$userfilter1.value=$username
$userfilter2= New-Object VMware.Hv.QueryFilterEquals
$userfilter2.membername='base.group'
$userfilter2.value=$False
$userfilter=new-object vmware.hv.QueryFilterAnd
$userfilter.filters=@($userfilter1, $userfilter2)
$userdefn.filter=$userfilter
$users=($queryService.QueryService_Create($Services1, $userdefn)).results
for ($i=1;$i -le $users.count; $i++){
Write-Host "$i. $($users[$i-1].base.name)"
$menu.Add($i,($users[$i-1].id))
[int]$ans = read-host "Please select the correct user"
$GlobalSessionQueryService = new-object VMware.Hv.GlobalSessionQueryServiceService
$sessionfilterspec=new-object vmware.hv.GlobalSessionQueryServiceQuerySpec
$sessionfilterspec.user=$user
$sessions=($GlobalSessionQueryService.GlobalSessionQueryService_QueryWithSpec($services1, $sessionfilterspec)).results
for ($i=1;$i -le $sessions.count; $i++){
Write-Host "$i. $($sessions[$i-1].namesdata.basenames.MachineOrRDSServerName)"
$menu.Add($i,($sessions[$i-1].id))
[int]$ans = read-host "Please select the correct VDI Desktop"
$session=$menu.Item($ans)
$Services1.Session.Session_Logoffforced($session)
$queryService.QueryService_DeleteAll($services1)