Questions tagged [sqlps]

The sqlps utility starts a Windows PowerShell 2.0 session with the SQL Server PowerShell provider and cmdlets loaded and registered.

The sqlps utility starts a Windows PowerShell 2.0 session with the SQL Server PowerShell provider and cmdlets loaded and registered. You can enter PowerShell commands or scripts that use the SQL Server PowerShell components to work with instances of SQL Server and their objects.

Click Here for documentation.

58 questions
16
votes
6 answers

Problems with RelocateFile property in the Restore-SqlDatabase cmdlet

I trying to restore a database by using the Restore-SqlDatabase cmdlet. I need to relocate the files but I'm getting the following errror Restore-SqlDatabase : Cannot bind parameter 'RelocateFile'. Cannot convert the…
Lars H
  • 163
  • 1
  • 1
  • 4
14
votes
2 answers

PowerShell 4 - Import-Module : The specified module 'SQLPS' was not loaded because no valid module file was found in any module directory

Previously working with PowerShell 3. Upgraded to PowerShell 4 and uninstalled it as facing error stated. Import-Module : The specified module 'SQLPS' was not loaded because no valid module file was found in any module directory. But all SQL…
Yogesh Patel
  • 818
  • 2
  • 12
  • 26
10
votes
6 answers

How to connect to SQL Server LocalDB using Invoke-Sqlcmd?

I have sqlcmd.exe from both SQLServer 2008 and SQLServer 2012: PS C:\> Get-Command sqlcmd.exe Definition ---------- C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SQLCMD.EXE By…
Gian Marco
  • 22,140
  • 8
  • 55
  • 44
8
votes
1 answer

Powershell - User Mapping SQL Server 2012

I am trying to script User Mapping for different Login accounts. I have scripted the creation of users and individual server roles, but I can't figure out how to set User Mapping with Powershell, I will also need to set the Database Role…
JMeterX
  • 438
  • 1
  • 8
  • 19
6
votes
3 answers

SQL installed but powershell not picking up sqlps commands (like invoke-sqlcmd)

I installed ms sql server with chocolatey: choco install SQLServer2012DeveloperEditionWithSP1 -y -f -source 'http://choco.developers.tcpl.ca/chocolatey' -c "$env:WINDIR\temp" SQL seems to be installed and working well outside of powershell where it…
Chris
  • 169
  • 1
  • 2
  • 14
5
votes
3 answers

Powershell Invoke-SQLCmd and SQLPS

Windows 7 workstation POSH 3.0 SS 2012 SP1 Abstract: Developer 1 cannot run Invoke-SQLCmd Developer 2 with similar SS Client tools installation can run Invoke-SQLCmd Developer 1 cannot run Import-Module SQLPS When I try to run a query from my…
Riskworks
  • 201
  • 2
  • 3
  • 9
4
votes
4 answers

Cannot install SQLServer module in Powershell

I try to install Powershell SQLSERVER module by executing the following command as admin (win10, 64Bit) but it fails PS C:\WINDOWS\system32> Install-Module -Name SqlServer PackageManagement\Install-Package : No match was found for the specified…
user3417479
  • 1,830
  • 3
  • 18
  • 23
4
votes
1 answer

"Error in TypeData" errors when using Backup-SqlDatabase in Powershell

I'm unable to run Backup-SqlDatabase due to errors. I get the following: PS C:\Users\Mik> Backup-SqlDatabase Backup-SqlDatabase : The 'Backup-SqlDatabase' command was found in the module 'SqlServer', but the module could not be loaded. For more…
Mik
  • 63
  • 1
  • 5
3
votes
1 answer

How to diagnose this exception from Invoke-Sqlcmd?

I'm running the following command (smallest reproducible example I could come up with): Invoke-Sqlcmd "select * from sys.databases" | %{ Invoke-Sqlcmd "select 1" } I'm getting the following error: Invoke-Sqlcmd : Could not find any…
Andrew Savinykh
  • 25,351
  • 17
  • 103
  • 158
2
votes
2 answers

Escaping single quote in string within Powershell before passing value to SQL

I have a script that retrieves information relating to the files within a given folder path, and then passes those values via the SQLPS module and the SQL INSERT INTO command to populate my database table. That works fine except for a few occasions…
Keith Langmead
  • 785
  • 1
  • 5
  • 16
2
votes
1 answer

correct syntax for putting a powershell script into a variable with double quotes

I have a need to put a PowerShell script into a variable with double quotes like so. However I am not aware of the correct syntax for this as I see syntax errors with $script variable when I try this. $script = "Invoke-Command -ComputerName…
1JS1-2
  • 23
  • 2
2
votes
1 answer

Powershell Import-Module SqlServer and SQLPS dont get along

In a current Powershell session i am running the following commands Import-Module SqlServer Import-Module SQLPS The Import-Module Command for SqlServer works fine, but Import-Module command for SQLPS fails PS C:\windows\system32> Import-Module…
RAnand
  • 89
  • 2
  • 14
2
votes
0 answers

SQLPS equivalent to SqlServer Get-SqlServer?

I currently am working with a script that utilizes the SQLPS module. This is due to the current version of my PowerShell, 4.0. I have a script that works on a coworkers machine, but not mine, that utilizes the SqlServer module, specifically the…
Matthew
  • 21
  • 4
2
votes
1 answer

Exception calling ".ctor" with "2" argument(s): "SetParent failed for Database 'XXX' ."

I have a problem with running SQLPS commands to create a DB on Windows Server 2012R2 and Powershell v4 #Import SQL Server Module called SQLPS Import-Module SQLPS -DisableNameChecking #Your SQL Server Instance Name $Inst = "sql03" $Srvr = New-Object…
MSalem
  • 21
  • 1
  • 3
2
votes
0 answers

Connecting to remote SQL Server instance using SQL auth via SqlPowershell?

I'm trying to use SqlPowershell/SqlPS (Import-Module sqlps) to connect to a server on my local network. I followed the instructions here to create a function that predefines a server/database and the login and prompts each time for the…
Benjin
  • 2,264
  • 2
  • 25
  • 50
1
2 3 4