PowerShell - Export device info with OS, Folder and reg key
Device name, Folder, Product type, Product Version, OS Name, Os Version, Registration Key, LegacyAuth Username
Script Events
- Discovers all devices and their details
- Collects date and time
- Saves the details into csv file in the current user's desktop folder with current date and time of running the script
- lists the details of within the terminal window
- opens the folder where .csv is saved
Script Example
Script:
Import-Module ThinscaleManagement
$NOW = Get-Date -UFormat "%d-%a-%Y--%H-%M"
$uri = "uri" #write here the full uri of your server
$destination = "${env:userprofile}\Desktop" #the file will be saved on the current user's desktop by default
$file = "$destination\AllDevices_$NoW.csv" #the name of the file is AllDevices_current date and time
#do not edit after this part
Get-Credential | Connect-TSTMGMTServer -Uri $uri
$devices = Get-TSTMGMTDevices | Select DeviceName, @{n='Folder';e={(Get-TSTMGMTFolder -folderId $_.FolderId).FolderName}}, ProductType ,ProductVersion, LastUsed, @{n='ActiveProfile';e={(Get-TSTMGMTProfile -ProfileId $_.ActiveProfileId).ProfileName + ' rev.' + (Get-TSTMGMTProfile -ProfileId $_.ActiveProfileId).ProfileRevision}}, @{n='OSName'; e={($_ | Get-TSTMGMTDeviceInventory).OperatingSystemName}}, @{n='OSversion'; e={($_ | Get-TSTMGMTDeviceInventory).OperatingSystemVersion}}, @{n='AccessKeyName'; e={(Get-TSTMGMTAccessKey -AccessKeyId $_.AccessKeyId).KeyName}}, @{n='LegacyAuthUser'; e={(Get-TSTMGMTAccessKey -AccessKeyId $_.AccessKeyId).LegacyAuthUsername}}, @{n='RegistrationKey'; e={(Get-TSTMGMTAccessKey -AccessKeyId $_.AccessKeyId).RegistrationKey}}
$devices | Export-Csv $file -NoTypeInformation
$devices
Start-Process -FilePath $destination