If PowerShell says The term ... is not recognized, treat it as a missing command or module. If it says Unable to find type [TypeName], treat it as a missing .NET type or assembly reference. If it fails on a class declaration, a using namespace line, or C# code passed to Add-Type, the message missing using directive or assembly reference usually points to unresolved .NET namespaces, assemblies, or C# compiler references rather than a missing cmdlet. This guide shows how to tell those cases apart before you change code.

What this error means

What this error means
A Windows error dialog says powershell has stopped working

This wording usually points to a type-resolution or compilation problem, not a simple typo. The script is asking for a .NET type, namespace, or referenced assembly that the compiler or parser cannot resolve yet. Read the exact message, note the line number, and use the symptom text to decide whether you are dealing with a missing command, a missing type, or a C# compilation issue.

Separate the symptom before you change code

PowerShell is a command-line interface and scripting environment for automation, and it handles data as objects rather than plain text. That matters here because one failure can mean several different things: a cmdlet is not available, a type cannot be found, or C# code passed to Add-Type is missing a namespace or assembly reference.

For example, a failure on a line that names Microsoft.SharePoint.Client.ClientContext is a type-resolution problem. A fresh session that says The term 'Get-Process' is not recognized is a command-resolution problem. C# code that triggers missing using directive or assembly reference during Add-Type is a compiler reference problem. The fix path is different for each one.

Likely causes

Most often, the script is missing a required .NET assembly reference or using statement. Less commonly, the script expects a type from an assembly that has not been loaded or referenced yet. Another cause is the wrong PowerShell edition or host. A fourth is a bad namespace or type name in the script itself.

PowerShell modules and cmdlets are not the same thing

PowerShell modules are reusable collections of cmdlets, functions, and variables. Cmdlets are commands such as Get-Process, Start-Service, and Remove-Item. In many cases, a command is unavailable because the module that exposes it has not been imported into that session. Built-in cmdlets are part of PowerShell itself, so they are not simply hidden until a module loads in the general case.

PowerShell can run in different editions and hosts, and many administrative modules are edition-specific. A module may be installed on disk but still not appear in a given shell if that shell cannot load it or if the module path is not visible to that session.

Cmdlets not showing? Check the module first

Cmdlets not showing? Check the module first
PowerShell window shows a command listing cmdlets and module sources

If a command is missing, verify whether its module exists before changing the script. First check whether PowerShell can see the command at all. Then check whether the module is installed. If the module is present, import it in the same shell that runs the script. If the command still does not appear, compare the shell edition and the module path.

  1. Open the same shell the script uses.
  2. Run Get-Module -ListAvailable to list installed modules.
  3. If you know the module name, narrow it with Get-Module -ListAvailable <ModuleName>.
  4. If the module is present, load it with Import-Module <ModuleName>.
  5. Run Get-Command <CommandName> to confirm the command is visible.
  6. Rerun the failing command after the module appears.

Quick verification checklist

Symptom text Likely cause Exact fix
The term 'Name' is not recognized as the name of a cmdlet, function, script file, or operable program. Missing command because the module is not loaded or not available in this edition. Run Get-Command <Name> -All, then Get-Module -ListAvailable <ModuleName>, then Import-Module <ModuleName> in the same shell.
Unable to find type [TypeName]. Missing assembly or type load. Check the type source, then try the relevant assembly load or module import before the line that uses the type.
The error mentions a class body, using statement, or a type name during parsing. PowerShell class or parse-time type resolution problem. Review the class or using namespace line, then load the referenced assembly or module before the parser reaches that code.
Commands appear in one host but not another. Wrong PowerShell edition or host. Run $PSVersionTable.PSEdition in both shells, then use the matching host for the module.
The module exists on disk, but PowerShell cannot see it. Module path not registered for the current session. Run $env:PSModulePath -split ';' and confirm the module folder is on a visible path; fix the path registration or install location.
A type still fails after import. Assembly not loaded even though the module is present. Check loaded assemblies with [AppDomain]::CurrentDomain.GetAssemblies() | Select FullName, then use the required load method for the assembly.

How do I fix missing using directive or assembly reference in PowerShell?

Start with the exact line number and the text in the error. If the script uses a cmdlet, verify the module only if that cmdlet name is actually the failing reference. If it uses a .NET type or C# code directly, add the missing assembly reference, use a fully qualified type name, or correct the namespace before the compiler reaches the failing line. If the error appears while PowerShell is parsing a class or a using namespace statement, treat it as a type-resolution or parse-time issue rather than a missing command problem.

  1. Find the line number in the error message.
  2. Read the type name, namespace, or command name on that line.
  3. If it is C# code passed to Add-Type, add the required reference with -ReferencedAssemblies or correct the using statement.
  4. If it is a PowerShell type reference, use the fully qualified type name or load the required assembly before the reference is parsed.
  5. If the type depends on a directly loaded assembly, load that assembly before the code that references it.
  6. Rerun the same line after the type or reference is available.

Assembly and type references need the right load order

A script can refer to a type before PowerShell knows about it. In that case, the line fails because the type or assembly is unavailable to the parser or compiler, not because the syntax is wrong. If the script loads an assembly directly, load it before the code that depends on it. If the code is inside a class definition or using namespace statement, the reference must already be valid when PowerShell parses that block.

What does Import-Module do in PowerShell?

Import-Module loads a module into the current session so its commands, functions, and variables become visible. Use it when a cmdlet exists on disk but does not appear in Get-Command. It does not fix a C# compiler error or an unresolved .NET type reference by itself; it only makes available commands and exported members that the session can resolve.

Use it before rerunning the command

  1. Run Get-Module -ListAvailable <ModuleName> to confirm the module is installed.
  2. Run Import-Module <ModuleName>.
  3. Run Get-Command <CommandName> to confirm visibility.
  4. Rerun the failing command in the same shell.

Modules can live in a registered module path

If a command is missing at startup, the module may be installed but not registered in the module search path for that session. Check the module folders visible to the shell, and confirm that the folder containing the module is present in the path the shell uses. Starting PowerShell from a different location usually does not expose a module by itself unless the profile, environment, or module path is the issue.

Sometimes, yes. A module can target a different PowerShell edition, and that mismatch can hide commands even when the module is installed. Execution policy is a separate setting; it can block script loading, but it is not usually the first explanation for a missing using directive or assembly reference message.

Compare the shell with the module’s target edition

  1. Check which shell you opened: Windows PowerShell 5.1 or PowerShell 7+.
  2. Run $PSVersionTable.PSEdition to confirm the edition.
  3. Compare that shell with the module’s documented target edition.
  4. Try the same import in the other host if the first one hides the command.
  5. Rerun the failing command in the matching edition before changing code.

Version mismatch can hide SharePoint cmdlets

SharePoint-related modules often depend on Windows PowerShell 5.1 and may not load in PowerShell 7+ unless they support that edition or are exposed through an implicit remoting or compatibility session. If a SharePoint command is missing, confirm the module is installed, then import it in the edition it was built for. If the command appears in one shell but not the other, the edition mismatch is the more likely cause.

How do I load SharePoint cmdlets in PowerShell?

For SharePoint cmdlets, check the module name first, then load it in the host it expects. If the module is visible in Get-Module -ListAvailable, import it with Import-Module <ModuleName>. If the command still does not appear, switch to the other PowerShell edition and retry the import there. If a module only works through a compatibility session or implicit remoting, the import may succeed only in the host that supports that load path.

  1. Run Get-Module -ListAvailable <ModuleName> to confirm the SharePoint module is installed.
  2. Run Import-Module <ModuleName>.
  3. Run Get-Command <SharePointCommand> to verify visibility.
  4. If it is still missing, open the other PowerShell host and repeat the import.
  5. Run the failing SharePoint line again after the command appears.

Scope and path issues can hide commands

If the module loads only in one profile or one host, the path may not be registered in the current session. Check whether the module folder is available to the shell that is running your script. If the module is installed but not visible, correct the module path or install location rather than assuming the command is built in.

Still not working?

Still not working?
A man uses a laptop beside a monitor showing PowerShell commands

If the module is installed, imported, and visible, but the error remains, check the type name, namespace, and assembly reference on the failing line. The next step is to verify that the script is using the correct fully qualified type name and that any referenced assembly is available to the compiler or parser. If the code is inside Add-Type, review the C# reference list rather than only the PowerShell session state.

Keep a short note beside each script that lists the required module name, target PowerShell edition, and any assembly it needs at startup. That makes the next missing-reference failure much easier to diagnose.

  1. Rerun Get-Module -ListAvailable in the exact shell that fails.
  2. Compare the output with the module’s target edition and path.
  3. Open the matching host and retry Import-Module <ModuleName>.
  4. If the line still fails, inspect the type name or assembly reference on that line and load or reference it before the script reaches it.
  5. Escalate to the module vendor or administrator if the module is present but never exposes its commands.

Keep reading

Frequently asked questions

Why does PowerShell say missing using directive or assembly reference?

That wording usually appears when the compiler or parser cannot resolve a .NET namespace, type, or assembly reference on the current line. Start by checking the line number and the name in the error text. If the script uses Add-Type, a class, or a using namespace statement, fix the missing reference or namespace before rerunning the line.

Do I need to import a module before using its cmdlets?

Yes, when the cmdlets are not already in the current session. A module can exist on disk and still hide its commands until you load it. Run Get-Command before and after Import-Module <ModuleName>; if the command appears only after import, the module was the missing piece.

What is the difference between PowerShell modules and cmdlets?

A module is a package that can include cmdlets, functions, and variables. A cmdlet is one command, such as Get-Process, Start-Service, or Remove-Item. When a command is missing, the module that exposes it may not be loaded yet, even though PowerShell itself is running.

Why are some PowerShell commands not showing up in my session?

They are often unavailable because the module is not loaded, the shell is the wrong edition, or the module path is not visible to that session. Check Get-Module -ListAvailable, import the module, and then rerun Get-Command. If the command appears in another host, edition mismatch is likely.