PowerShell Execution Policy does not allow to run VisualSVN Server cmdlets

Applies to: VisualSVN Server 3.4 and later

This article describes how to resolve "The term is not recognized" error when you try to run VisualSVN Server PowerShell cmdlets in Windows PowerShell.

Symptoms

Attempting to run a VisualSVN Server PowerShell cmdlet, you receive the following or similar error message in the console:

Get-SvnRepository : The term 'Get-SvnRepository' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-SvnRepository
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-SvnRepository:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Along with the message shown above, the PowerShell execution policy is set to Restricted. Use the Get-ExecutionPolicy cmdlet to show the execution policy that is effective for the current PowerShell session.

Technical background

VisualSVN Server comes with a digitally-signed PowerShell module that provides server and repository administration cmdlets. The module loads automatically by default, except for when loading third-party PowerShell modules is restricted by the PowerShell execution policy. PowerShell execution policy is a safety feature that can prevent third-party modules from loading in order to protect the computer from untrusted scripts. Read Microsoft Docs | About Execution Policies for more information.

When the effective execution policy is Restricted, PowerShell will not load the VisualSVN Server module and you will see errors when trying to run the servers' cmdlets.

Resolution

There are two ways to resolve the problem – by using the dedicated VisualSVN Server PowerShell console to run the cmdlets or by changing the execution policy to RemoteSigned.

Using the dedicated VisualSVN Server PowerShell console

VisualSVN Server cmdlets can be executed anytime using a dedicated VisualSVN Server PowerShell console. The VisualSVN Server PowerShell console automatically runs with at least the RemoteSigned execution policy, thus preventing the error in the first place.

Click the PowerShell icon on the VisualSVN Server Manager toolbar or follow these steps to start the console:

  1. On the Windows taskbar, click Start.
  2. Type VisualSVN Server PowerShell.
  3. Click VisualSVN Server PowerShell.

You can now run cmdlets in the opened VisualSVN Server PowerShell.

Changing the PowerShell execution policy

You need to change the execution policy to RemoteSigned to make PowerShell load the digitally signed modules. Follow these steps to change the execution policy:

  1. Start Windows PowerShell (click Run as administrator).
  2. Run the following command: Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
  3. Choose [Y] Yes to confirm the execution policy change.
  4. Run the Import-Module VisualSVN -Force command.
Tip
Alternatively, the execution policy can be changed only for the current process, or for all users on the current computer. To do so, instead of CurrentUser use the Process or LocalMachine scopes. The Process scope is the most specific one, but it is retained only until the current PowerShell window is closed.

The execution policy will be set to RemoteSigned allowing to load the VisualSVN Server module and hence resolving the problem. Read Microsoft Docs | About Execution Policies for more information.

See also

KB88: VisualSVN Server PowerShell Cmdlet Reference

Last Modified: