PowerShell Error Messages
Windows PowerShell 5.1 and PowerShell 7: shell, scripting language and the base of Microsoft 365 administration.All PowerShell pages
- Cannot convert value "abc" to type "System.Int32". Error: "Input string was not in a correct format."PowerShell could not cast a value to the type you asked for: text to [int], a local date format to [datetime]. Validate first or convert with -as or TryParse.
- PowerShell: A positional parameter cannot be found that accepts argument 'x'.PowerShell got more unnamed arguments than the cmdlet accepts: usually an unquoted path with spaces, a stray space, or a list written without commas. Quote it.
- PowerShell: Cannot bind argument to parameter 'Path' because it is null.A variable passed to a mandatory parameter is $null or empty: a typo in its name, a lookup that found nothing, or a script parameter that was never passed.
- PowerShell: Cannot find path 'C:\...' because it does not exist.The file or folder is not there: a typo, a path relative to another folder, or a name with [ ] read as a wildcard. Check with Test-Path, use -LiteralPath.
- PowerShell: Cannot index into a null array.You indexed a variable that is $null: a command returned nothing, the name is misspelled or a property is missing. Check the value first or wrap it in @().
- PowerShell: Missing closing '}' in statement block or type definition.A { in the script has no matching }, so PowerShell does not run the file at all. The error points at the opening brace that is never closed; check quotes too.
- PowerShell: script.ps1 cannot be loaded because running scripts is disabled on this systemPowerShell refuses to run .ps1 files when the execution policy is Restricted, the Windows default. Set RemoteSigned for the current user or unblock the file.
- PowerShell: The 'x' command was found in the module 'y', but the module could not be loaded.Auto-loading found the module but importing it failed. Run Import-Module with its name to see why: execution policy, a missing file or an assembly conflict.
- PowerShell: The term 'x' is not recognized as the name of a cmdlet, function, script file, or operable programPowerShell found no command by that name: a typo, a module that is not installed, a program not in PATH, or a local script called without its relative path.
- PowerShell: Unable to find type [System.Windows.Forms.MessageBox].A [TypeName] literal names a .NET type that is not loaded. Load its assembly with Add-Type -AssemblyName, fix the namespace, or use using module for classes.
- PowerShell: You cannot call a method on a null-valued expression.You called a method on a value that is $null: a misspelled variable, a property that does not exist or a command that returned nothing. Check it first.
- The specified module 'x' was not loaded because no valid module file was found in any module directory.Import-Module found no module by that name in any PSModulePath folder: it is not installed, was installed for the other PowerShell edition, or is misspelled.