JosefNemec/Playnite · error · Exception
Cannot load script file, uknown format.
Error message
Cannot load script file, uknown format.
What it means
Thrown by PlayniteScript.FromFile when the script file's extension is neither .psm1 nor .psd1. Playnite only loads PowerShell script modules, so any other extension (or none) is treated as an unknown format and rejected with a hard throw.
Source
Thrown at source/Playnite/Scripting/PlayniteScript.cs:101
public static PlayniteScript FromFile(string path, string name)
{
var extension = System.IO.Path.GetExtension(path).ToLower();
if (extension == ".psm1" || extension == ".psd1")
{
if (PowerShellRuntime.IsInstalled)
{
return new PowerShellScript(path, name);
}
else
{
logger.Warn("Cannot load PowerShell script, PowerShell 3+ not installed.");
return null;
}
}
else
{
throw new Exception("Cannot load script file, uknown format.");
}
}
public override string ToString()
{
return System.IO.Path.GetFileName(Path);
}
public virtual void Dispose()
{
}
public abstract object InvokeFunction(string functionName);
public abstract object InvokeFunction(string functionName, List<object> arguments);
public abstract void InvokeExportedFunction(ScriptFunctionExport function);
public abstract void SetVariable(string name, object value);
public abstract void OnApplicationStarted();
public abstract void OnApplicationStopped();
View on GitHub (pinned to 5911f4e964)
Solutions
- Move or rename the offending file out of the script load path; only .psm1/.psd1 belong there.
- If the script is PowerShell, rename it to a .psm1 module file.
- Delete stray non-module files (READMEs, .ps1 entry points) from the extension's Scripts folder.
- Retry loading the extension.
Example fix
// before — extension folder contains install.ps1 (entry script) // rename it to a module: // install.ps1 -> Installer.psm1
Defensive patterns
Strategy: validation
Validate before calling
var ext = Path.GetExtension(path)?.ToLower();
if (ext != ".psm1" && ext != ".psd1")
throw new NotSupportedException($"Unsupported script extension '{ext}'. Only .psm1/.psd1 are loadable."); Type guard
static bool IsLoadableScript(string path)
{
var ext = Path.GetExtension(path)?.ToLower();
return ext == ".psm1" || ext == ".psd1";
} Try / catch
try { var script = PlayniteScript.FromFile(path, name); }
catch (Exception ex) when (ex.Message.Contains("uknown format")) { /* skip/rename the file */ } Prevention
- Keep only .psm1/.psd1 in the script load directory.
- Move docs, .ps1 entry scripts, and non-module files elsewhere.
- If you author a PowerShell script, use the .psm1 module form.
When it happens
Trigger: PlayniteScript.FromFile(path, name) is called; Path.GetExtension(path).ToLower() is not '.psm1' and not '.psd1', so the else branch at line 100 throws.
Common situations: An extension script directory contains a .ps1, .cs, .txt, or extensionless file that the loader walks. A script was renamed incorrectly. A stray helper file (e.g. README.md, install.ps1) sits where Playnite scans for script modules.
Related errors
- Cannot execute script, no runtime given.
- PowerShell 5.1 is not installed.
- Interactive session is already running
- e.Message
- LOC.ErrorPowerShellNotInstalled
AI-assisted analysis of JosefNemec/Playnite@5911f4e964 (2026-08-13).
Data as JSON: /api/errors/fef2be2a112eb1d5.
Report an issue: GitHub.