Error message when you use a startup script to start the SQL Server PowerShell provider in SQL Server 2008: “Set-Location: Object reference not set to an instance of an object”
Symptoms
Microsoft SQL Server 2008 installs the SQL Server PowerShell (SQLPS) provider as a feature. When you use a startup script to start the SQL Server PowerShell provider separately without using the SQLPS minishell, the SQL Server PowerShell provider does not let you navigate the SQL Server object hierarchy. Instead, you receive the following exception error message:
Set-Location: Object reference not set to an instance of an object.
Resolution
The SQL Server PowerShell provider requires certain global variables to exist. Typically, the SQLPS minishell sets these global variables. However, when you use a startup script to start the SQL Server PowerShell provider, these global variables are not declared.
