Last active
August 7, 2023 18:53
-
-
Save blakedrumm/025596724dd125e92979a53ccac3d1c9 to your computer and use it in GitHub Desktop.
Gather a list of Usernames and Emails for all users.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Author: Blake Drumm | |
#Date: August 7th, 2023 | |
#----------------------------------------------- | |
# REQUIRED | |
#----------------------------------------------- | |
# Prefil the XPlexToken before running the script | |
$XPlexToken = 'GZZ4qopzCuczOKW9qIPX' | |
#----------------------------------------------- | |
try | |
{ | |
$Data = Invoke-RestMethod -Uri "https://plex.tv/api/users`?X-Plex-Token=$XPlexToken" -Method GET -ErrorAction Stop | |
if($Data.MediaContainer.Size -eq 0) | |
{ | |
return | |
} | |
} | |
catch | |
{ | |
throw $_ | |
} | |
$user = @() | |
############################################################################# | |
# Managed users have no username property (only title). As this module uses 'username', copy title to username: | |
$Data.MediaContainer.User | Where {$_.Username -ne $null } | ForEach-Object { | |
$user += "$($_.Username) ($($_.Email))" | |
} | |
#Output the count of Users | |
Write-Output "----------------------------------------------" | |
Write-Output "List of Users and Email Addresses" | |
Write-Output "----------------------------------------------" | |
Write-Output $user | |
Write-Output "----------------------------------------------" | |
Write-Output "Count: $($user.Count)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment