Skip to content

2 Getting Started

m1lkman edited this page Mar 17, 2023 · 1 revision

Syntax

Update-PlexMediaServer -UseServerToken [-Plex2FA] [-DisablePlexPass] [-PlexServerHostName <string>] [-PlexServerPort <int>] [-PlexServerSSL] [-UserName <string>] [-LogFile <string>] [-Force] [-ReportOnly] [-NotifySuccess] [-Build {windows-x86 | windows-x86_64}] [-UpdateCleanup <int>] [-EmailNotify] [-AttachLog] [-IncludeLog] [-SmtpTo <string>] [-SmtpFrom <string>] [-SmtpUser <string>] [-SmtpPassword <string>] [-SmtpServer <string>] [-SmtpPort <int>] [-EnableSSL] [-EmailIsBodyHtml] [-SlackNotify] [-SlackChannel <string>] [-SlackToken <string>] [-WhatIf] [-Confirm]  [<CommonParameters>]

Update-PlexMediaServer [[-PlexLogin] <string>] [[-PlexPassword] <string>] -Silent [-Plex2FA] [-DisablePlexPass] [-PlexServerHostName <string>] [-PlexServerPort <int>] [-PlexServerSSL] [-UserName <string>] [-LogFile <string>] [-Force] [-ReportOnly] [-NotifySuccess] [-Build {windows-x86 | windows-x86_64}] [-UpdateCleanup <int>] [-EmailNotify] [-AttachLog] [-IncludeLog] [-SmtpTo <string>] [-SmtpFrom <string>] [-SmtpUser <string>] [-SmtpPassword <string>] [-SmtpServer <string>] [-SmtpPort <int>] [-EnableSSL] [-EmailIsBodyHtml] [-SlackNotify] [-SlackChannel <string>] [-SlackToken <string>] [-WhatIf] [-Confirm]  [<CommonParameters>]

Update-PlexMediaServer [[-PlexLogin] <string>] [[-PlexPassword] <string>] -Passive [-Plex2FA] [-DisablePlexPass] [-PlexServerHostName <string>] [-PlexServerPort <int>] [-PlexServerSSL] [-UserName <string>] [-LogFile <string>] [-Force] [-ReportOnly] [-NotifySuccess] [-Build {windows-x86 | windows-x86_64}] [-UpdateCleanup <int>] [-EmailNotify] [-AttachLog] [-IncludeLog] [-SmtpTo <string>] [-SmtpFrom <string>] [-SmtpUser <string>] [-SmtpPassword <string>] [-SmtpServer <string>] [-SmtpPort <int>] [-EnableSSL] [-EmailIsBodyHtml] [-SlackNotify] [-SlackChannel <string>] [-SlackToken <string>] [-WhatIf] [-Confirm]  [<CommonParameters>]

Update-PlexMediaServer [-PlexToken] <string> [-Plex2FA] [-DisablePlexPass] [-PlexServerHostName <string>] [-PlexServerPort <int>] [-PlexServerSSL] [-UserName <string>] [-LogFile <string>] [-Force] [-ReportOnly] [-NotifySuccess] [-Build {windows-x86 | windows-x86_64}] [-UpdateCleanup <int>] [-EmailNotify] [-AttachLog] [-IncludeLog] [-SmtpTo <string>] [-SmtpFrom <string>] [-SmtpUser <string>] [-SmtpPassword <string>] [-SmtpServer <string>] [-SmtpPort <int>] [-EnableSSL] [-EmailIsBodyHtml] [-SlackNotify] [-SlackChannel <string>] [-SlackToken <string>] [-WhatIf] [-Confirm]  [<CommonParameters>]

Update-PlexMediaServer [-Credential] <pscredential> [-Plex2FA] [-DisablePlexPass] [-PlexServerHostName <string>] [-PlexServerPort <int>] [-PlexServerSSL] [-UserName <string>] [-LogFile <string>] [-Force] [-ReportOnly] [-NotifySuccess] [-Build {windows-x86 | windows-x86_64}] [-UpdateCleanup <int>] [-EmailNotify] [-AttachLog] [-IncludeLog] [-SmtpTo <string>] [-SmtpFrom <string>] [-SmtpUser <string>] [-SmtpPassword <string>] [-SmtpServer <string>] [-SmtpPort <int>] [-EnableSSL] [-EmailIsBodyHtml] [-SlackNotify] [-SlackChannel <string>] [-SlackToken <string>] [-WhatIf] [-Confirm]  [<CommonParameters>]

Update-PlexMediaServer [-PlexLogin] <string> [[-PlexPassword] <string>] [-Plex2FA] [-DisablePlexPass] [-PlexServerHostName <string>] [-PlexServerPort <int>] [-PlexServerSSL] [-UserName <string>] [-LogFile <string>] [-Force] [-ReportOnly] [-NotifySuccess] [-Build {windows-x86 | windows-x86_64}] [-UpdateCleanup <int>] [-EmailNotify] [-AttachLog] [-IncludeLog] [-SmtpTo <string>] [-SmtpFrom <string>] [-SmtpUser <string>] [-SmtpPassword <string>] [-SmtpServer <string>] [-SmtpPort <int>] [-EnableSSL] [-EmailIsBodyHtml] [-SlackNotify] [-SlackChannel <string>] [-SlackToken <string>] [-WhatIf] [-Confirm]  [<CommonParameters>]

Update-PlexMediaServer [[-EmailNotify]] -SmtpTo <string> -SmtpFrom <string> -SmtpUser <string> -SmtpPassword <string> -SmtpServer <string> [-Plex2FA] [-DisablePlexPass] [-PlexServerHostName <string>] [-PlexServerPort <int>] [-PlexServerSSL] [-UserName <string>] [-LogFile <string>] [-Force] [-ReportOnly] [-NotifySuccess] [-Build {windows-x86 | windows-x86_64}] [-UpdateCleanup <int>] [-AttachLog] [-IncludeLog] [-SmtpPort <int>] [-EnableSSL] [-EmailIsBodyHtml] [-WhatIf] [-Confirm]  [<CommonParameters>]

Update-PlexMediaServer [-SlackNotify] -SlackChannel <string> -SlackToken <string> [-Plex2FA] [-DisablePlexPass] [-PlexServerHostName <string>] [-PlexServerPort <int>] [-PlexServerSSL] [-UserName <string>] [-LogFile <string>] [-Force] [-ReportOnly] [-NotifySuccess] [-Build {windows-x86 | windows-x86_64}] [-UpdateCleanup <int>] [-WhatIf] [-Confirm]  [<CommonParameters>]

Examples

For local interactive default execution using Plex Server Online token (requires Plex Server is logged in and claimed) to authenticate to Plex.tv for updates (will honor Plex Server Update Channel Setting):

Update-PlexMediaServer

or remote execution type either:

Invoke-Command -ComputerName Server1 [-Credential] <pscredential> -ScriptBlock {Update-PlexMediaServer}

or if Plex Media Server is running in a user context other than the credentials of PowerShell use -Username parameter:

Invoke-Command -ComputerName Server1 [-Credential] <pscredential> -ScriptBlock {Update-PlexMediaServer -UserName <UserName>}

For local interactive execution with password prompt

Update-PlexMediaServer -PlexLogin '<PlexLogin/PlexID>'

Execute silently using Plex Authentication Token (Use Get-PlexToken to find your token):

Update-PlexMediaServer -PlexToken <Token> -Silane

Execute passively using Plex Server Online Authentication Token (requires Plex Server is logged in and Claimed).

Update-PlexMediaServer -UseServerToken -Passive

or silently check for beta channel (PlexPass) updates using Plex.tv login and password:

Update-PlexMediaServer -PlexLogin <Email/ID> -PlexPassword <Password> -Silent

to disable beta channel (PlexPass) updates and cleanup all Updates from the Updates folder except the latest 2:

Update-PlexMediaServer -DisablePlexPass -UpdateCleanup 2

force checking for build windows-x86_64 even if windows-x86 build is installed, i.g. upgrade to 64-bit

Update-PlexMediaServer -Build 'windows-x86_64'

check plex running on localhost and bypass public IP reverse DNS lookup

Update-PlexMediaServer -PlexServerHostname 'localhost'

To enable email notifications:

Update-PlexMediaServer -EmailNotify -SmtpTo Someone@gmail.com -SmtpFrom Someone@gmail.com -SmtpUser Username -SmtpPassword Password -SmtpServer smtp.server.com

or enable email notifications with custom SMTP port and SSL authentication:

Update-PlexMediaServer -EmailNotify -SmtpTo Someone@gmail.com -SmtpFrom Someone@gmail.com -SmtpUser Username -SmtpPassword Password -SmtpServer smtp.server.com -SmtpPort Port -EnableSSL

#Slack channel notification:

Update-PlexMediaPlayer -SlackNotify -SlackChannel '#ChannelName' -SlackToken <Slack OAuth Token>

Parameters

All parameters can be specified either at the command-line or set in the Parameters section of script file itself if you prefer. Edit at your own risk. See examples below for use cases. Use Get-Help cmdlet for details about parameters and usage.

-AttachLog

Type: Switch
Parameter Sets: 2FA, Silent, Passive, LogFile, EmailNotify

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Build

Forces Plex Media Server Build Architecture. If omitted, Build Architecture is that of the currently installed Plex Media Server Build.

Type: String
Parameter Sets: (All)
Accepted Values: windows-x86, windows-x86_64

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Type: Switch
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Credential

Type: Switch
Parameter Sets: SlackNotify, EmailNotify, NotifySuccess, ReportOnly, Force, Silent, Passive, CredAuth

Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-DisablePlexPass

Disables PlexPass(Beta) Updates

Type: Switch
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-EmailIsBodyHtml

Type: Switch
Parameter Sets: 2FA, Silent, Passive, EmailNotify

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-EmailNotify

Type: Switch
Parameter Sets: 2FA, Silent, Passive, EmailNotify

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-EnableSSL

Type: Switch
Parameter Sets: 2FA, Silent, Passive, EmailNotify

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Force

Type: Switch
Parameter Sets: SlackNotify, EmailNotify, 2FA, Silent, Passive, TextAuth, CredAuth, TokenAuth, ServerAuth, Force

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-IncludeLog

Type: Switch
Parameter Sets: 2FA, Silent, Passive, LogFile, EmailNotify

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-LogFile

Enter Log File path, default is PSScriptRoot\Update-PlexMediaServer.log

Type: String
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: true (ByPropertyName)
Accept wildcard characters: False

-NotifySuccess

Type: Switch
Parameter Sets: SlackNotify, EmailNotify, 2FA, Silent, Passive, TextAuth, CredAuth, TokenAuth, ServerAuth, NotifySuccess

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Passive

Displays minimal UI with no prompts

Type: Switch
Parameter Sets: Passive

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Plex2FA

Enables Plex Two-Factor auth code support

Type: Switch
Parameter Sets: 2FA

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-PlexLogin

Enter Plex.tv Email or ID

Type: String
Parameter Sets: TextAuth
Accepted Aliases: PlexID

Required: True
Position: 0
Default value: None
Accept pipeline input: true (ByPropertyName)
Accept wildcard characters: False

-PlexPassword

Type: String
Parameter Sets: SlackNotify, EmailNotify, NotifySuccess, ReportOnly, Force, Silent, Passive, TextAuth

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-PlexServerHostName

Plex Media Server Hostname for Plex Web Checks. Bypasses detecting hostname using public IP reverse dns lookup.

Type: String
Parameter Sets: (All)

Required: True
Position: Named
Default value: None
Accept pipeline input: true (ByPropertyName)
Accept wildcard characters: False

-PlexServerPort

Enter non-standard Plex Media Server Port, default is 32400

Type: Integer
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: true (ByPropertyName)
Accept wildcard characters: False

-PlexToken

Type: String
Parameter Sets: SlackNotify, EmailNotify, NotifySuccess, ReportOnly, Force, Silent, Passive, TokenAuth

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ReportOnly

Type: Switch
Parameter Sets: SlackNotify, EmailNotify, 2FA, Silent, Passive, ReportOnly

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Silent

Display no UI and no prompts

Type: Switch
Parameter Sets: Silent

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SlackChannel

Type: String
Parameter Sets: 2FA, Silent, Passive, SlackNotify

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SlackNotify

Type: String
Parameter Sets: 2FA, Silent, Passive, SlackNotify

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SlackToken

Type: String
Parameter Sets: 2FA, Silent, Passive, SlackNotify

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SmtpFrom

Type: String
Parameter Sets: 2FA, Silent, Passive, SlackNotify

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SmtpPassword

Type: String
Parameter Sets: 2FA, Silent, Passive, SlackNotify

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SmtpPort

Type: Integer
Parameter Sets: 2FA, Silent, Passive, SlackNotify

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SmtpServer

Type: String
Parameter Sets: 2FA, Silent, Passive, SlackNotify

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SmtpTo

Type: String
Parameter Sets: 2FA, Silent, Passive, SlackNotify

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SmtpUser

Type: String
Parameter Sets: 2FA, Silent, Passive, SlackNotify

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-UpdateCleanup

Enables cleanup of old updates. Set number of Updates to keep in Updates folder.

Type: Inteeger
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-UseServerToken

Type: Switch
Parameter Sets: SlackNotify, EmailNotify, NotifySuccess, ReportOnly, Force, Silent, Passive, ServerAuth

Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-UserName

Specify Windows Username when script is executing in a user context other than Plex Media Server/Plex Media Server Service Wrapper

Type: String
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: true (ByPropertyName)
Accept wildcard characters: False

-WhatIf

Type: Switch
Parameter Sets: (All)
Accepted Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Exit Codes

Beyond the typical success and failure codes the script will output one of the following additional exit codes.

0 - Success
1 - On error (enable verbose output or check the log for more info)
4 - Download fails
6 - Update was deferred due to server having active sessions (in-use)
7 - Update is available (requires -ReportOnly parameter)
10 - Update was downloaded/installed (requires -NotifySuccess Parameter)

Q&A

  • Q: How do you check the current PowerShell execution policy?
  • A: Open PowerShell as an Administrator, and run the following command: Get-ExecutionPolicy -Scope CurrentUser
  • Q: How do you set the current users PowerShell execution policy?
  • A: Open PowerShell as an Administrator, and run the following command: Set-ExecutionPolicy -Scope CurrentUser Unrestricted
  • Q: How do I get a Plex authentication token? (I don't trust your Get-PlexToken code)
  • A: Follow Plex's Support Article Finding an authentication token / X-Plex-Token.
  • Q: How often will you update the module?
  • A: That is entirely up to you! Create some issues or fork and fix/add what you need.