VMware Horizon Community
butlpau1
Contributor
Contributor

Finding Obsolete Assigned VMs to Reuse

Hi there,

Using VMware View 4.5.  Users come and go in our Company on a regular basis, all of which are assigned a VMware View desktop during their time.  I am trying to find a way to free up VMs of Users who have left.  We are using persistent desktops for a specific reason.

These Users are removed from AD soon after they leave.  They could leave their VM is a Disconnected or Available state.

Is there a Powershell command to find out the last time a User has logged on - has been disconnected for x duration - of if a User isn't in AD but assigned a desktop on a Pool

I could then use this information to unassign Desktops (scripted).

Any thoughts or help would be appreciated.

Best Regards,

Paul.

0 Kudos
4 Replies
mittim12
Immortal
Immortal

You could try the vdmadmin -O command from a connection broker.  That command shows assigned machines that are unentitled.

0 Kudos
butlpau1
Contributor
Contributor

Thanks for the reply - would this be the same as the Unentitled User Connected / Unentitled User Dicsonnected is the Dashboard view in the Broker?

Screenshot Attached.

If Users were disabled in AD would this also be the case?

Thanks,

Paul.

0 Kudos
mittim12
Immortal
Immortal

Do you mean the unassigned user connected and disconnected?     No that one means someone is logged into the VM that is not assigned that VM.     The vdmadmin -0 reports on VM's that are assigned to users who no longer have access to the pool (they could have been deleted from AD or something).

butlpau1
Contributor
Contributor

Created a quick VBS script to check against a list of exported Users from VMware View (Users.txt) against deleted accounts in AD if its of any assistance, maybe somewhere else... cheap and cheerful.

********************************************************************************************************************************************

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\temp\Users.txt", ForReading)

Const ForReading = 1

Dim arrFileLines()
Dim myFSO, Update
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set Update = myFSO.OpenTextFile("c:\temp\Deleted_Accounts.txt", 8, True)
i = 0
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine


strUserName = arrFileLines(i)
dtStart = TimeValue(Now())
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.CommandText = _
    "<LDAP://dc=eu, dc=ad, dc=my_company,dc=com>;(&(objectCategory=User)" & _
         "(samAccountName=" & strUserName & "));samAccountName;subtree"
 
Set objRecordSet = objCommand.Execute

If objRecordset.RecordCount = 0 Then
    Update.WriteLine(strUserName)
Else
   
End If

i = i + 1
Loop

SET Update = NOTHING
SET myFSO = NOTHING
objFile.Close

objConnection.Close
'Update.Close

********************************************************************************************************************************************

Exports list of Users to a text file.

E&OE !

Paul.

0 Kudos