Does anyone know if the script to remove old devices includes devices without a LastSeenAt entry?

jmac999
jmac999 Posts: 23 ✭✭
edited September 2021 in Deployment & Integrations

I originally raised a ticket with TeamViewer support but despite me being a corporate customer, they were unwilling to assist in this query. I'm hoping better luck within the community.

Any assistance is greatly appreciated :-)

I have been told by TeamViewer that our managed device count has exceeded the limit that our license allows and have been told to run the following script to remove old devices of say 365 or 730 days:

https://teamviewer.sharepoint.com/:u:/s/DataStore/EZ5eCVQKXp9Io3t0g77BOScBoz-ac8wSQpakn1SXXiQRAQ?e=xRoWCf

Before I went ahead and ran that, I wanted to see what data is in the system to ensure it will only remove the data I want it to remove, so carried out the following steps:

-1. Open PowerShell as an admin

 -2. Install-Module TeamViewerPS

 -3. Connect-TeamViewerApi

 -4. $devices = Get-TeamViewerDevice

 $devices | Select-Object -Property "Name","TeamViewerId","IsAssignedToCurrentAccount","LastSeenAt" | Export-Csv -Path 'C:\Temp\test.csv'

 5. Insert your API Token

 6. Open "test.csv" (Path C:\Temp)I hope this overview can cover your request, since you are able to filter within the .csv-file "isAssigendToCurrentAccount" and "LastSeenAt".


The results of the output file shows plenty of devices with dates that I'm happy to have removed, which is fine.

However, there are many entries in the output where the "LastSeenAt" field is empty. Of those, I have a split of ID's that are active and known existing devices that I connect to regularly, as well as devices I know that have not been online for some time and can be removed.

Can someone confirm whether the script ignores the ID's where the "LastSeenAt" field is blank or includes all those fields as it effectively sees them as older than the amount of days entered?

I cannot afford to lose access to devices I regularly connect to so need to be sure what this script will do before running it.

Thank you in advance for any assistance.

Best Answer

  • Joey_PCIISD
    Joey_PCIISD Posts: 3 ✭✭
    Answer ✓

    Looking at the scrip, there's a condition to check if the lastseen item is null, and it doesn't include it if it is.

    In addition, there is a confirmation prompt where all the IDs are listed, and then you have to confirm if you want to remove them, so you could do a sanity check at that point.


Answers

  • Joey_PCIISD
    Joey_PCIISD Posts: 3 ✭✭
    Answer ✓

    Looking at the scrip, there's a condition to check if the lastseen item is null, and it doesn't include it if it is.

    In addition, there is a confirmation prompt where all the IDs are listed, and then you have to confirm if you want to remove them, so you could do a sanity check at that point.


  • jmac999
    jmac999 Posts: 23 ✭✭

    Awesome!


    Thank you very much for your input 😃