{"record":{"id":"fef2be2a112eb1d5","repo":"JosefNemec/Playnite","slug":"cannot-load-script-file-uknown-format","errorCode":null,"errorMessage":"Cannot load script file, uknown format.","messagePattern":"Cannot load script file, uknown format\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"source/Playnite/Scripting/PlayniteScript.cs","lineNumber":101,"sourceCode":"\r\n        public static PlayniteScript FromFile(string path, string name)\r\n        {\r\n            var extension = System.IO.Path.GetExtension(path).ToLower();\r\n            if (extension == \".psm1\" || extension == \".psd1\")\r\n            {\r\n                if (PowerShellRuntime.IsInstalled)\r\n                {\r\n                    return new PowerShellScript(path, name);\r\n                }\r\n                else\r\n                {\r\n                    logger.Warn(\"Cannot load PowerShell script, PowerShell 3+ not installed.\");\r\n                    return null;\r\n                }\r\n            }\r\n            else\r\n            {\r\n                throw new Exception(\"Cannot load script file, uknown format.\");\r\n            }\r\n        }\r\n\r\n        public override string ToString()\r\n        {\r\n            return System.IO.Path.GetFileName(Path);\r\n        }\r\n\r\n        public virtual void Dispose()\r\n        {\r\n        }\r\n\r\n        public abstract object InvokeFunction(string functionName);\r\n        public abstract object InvokeFunction(string functionName, List<object> arguments);\r\n        public abstract void InvokeExportedFunction(ScriptFunctionExport function);\r\n        public abstract void SetVariable(string name, object value);\r\n        public abstract void OnApplicationStarted();\r\n        public abstract void OnApplicationStopped();\r","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Scripting/PlayniteScript.cs#L83-L119","documentation":"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.","triggerScenarios":"PlayniteScript.FromFile(path, name) is called; Path.GetExtension(path).ToLower() is not '.psm1' and not '.psd1', so the else branch at line 100 throws.","commonSituations":"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.","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."],"exampleFix":"// before — extension folder contains install.ps1 (entry script)\n// rename it to a module:\n// install.ps1  ->  Installer.psm1","handlingStrategy":"validation","validationCode":"var ext = Path.GetExtension(path)?.ToLower();\nif (ext != \".psm1\" && ext != \".psd1\")\n    throw new NotSupportedException($\"Unsupported script extension '{ext}'. Only .psm1/.psd1 are loadable.\");","typeGuard":"static bool IsLoadableScript(string path)\n{\n    var ext = Path.GetExtension(path)?.ToLower();\n    return ext == \".psm1\" || ext == \".psd1\";\n}","tryCatchPattern":"try { var script = PlayniteScript.FromFile(path, name); }\ncatch (Exception ex) when (ex.Message.Contains(\"uknown format\")) { /* skip/rename the file */ }","preventionTips":["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."],"tags":["scripting","powershell","extension","validation","playnite"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}