April 11, 2017 at 8:34 am
Good day -
I have been writing Powershell scripts to use Invoke-sqlcmd to complete some data tasks I need to do. I am running into cases where I need to run this on other windows servers, but they do not have SQL Server installed, and I get "'invoke-sqlcmd' is not recognized as the name of a cmdlet". There may be other PS 4 / SQLPS commands I want to use as well.
I reviewed http://www.jasonq.com/blog/2012/3-things-to-do-if-invoke-sqlcmd-is-not-recognized-in-windows-powershell, and it seems this would be what is needed, but does anyone know this is the case? The machine I am trying to run this on is Windows Server 2012 R2 Standard. The SQL Server that I want to connect is SQL Server 2012.
Any info on this would be greatly appreciated!
April 11, 2017 at 12:35 pm
You will need the SQL Server PowerShell module.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 11, 2017 at 12:38 pm
What is the best way to get that?
April 11, 2017 at 4:18 pm
Use the get-module command. Same thing when you start using Azure, you'll need the AzureRM module.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 11, 2017 at 4:53 pm
I attempted this - it is not doing anything.
To be clear - this is a windows server, it does not have SQL Server installed. I am looking to offload some tasks to other machines, while keeping the DB update to date as it progresses.
Import-Module Sqlps -DisableNameChecking
Import-Module : The specified module 'Sqlps' was not loaded because no valid module file was found in any module directory.
I am inclined to think that I have to install SQL Server, which I do not want to do. I will likely go back to "new-object system.data.sqlclient.sqlconnection"
April 12, 2017 at 7:23 am
No.You shouldn't have to install SQL Server. You just need the PowerShell module. If this ran successfully, it should download that module for you. Here's Microsoft documentation on what you need. You do not have to install SQL Server.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 12, 2017 at 7:38 am
Grant,
Thank you, I had reviewed this, tried this, and this did not work. Today I noticed:
If the sqlps module is not in your path, change to the location of the module or use the full path in the script (using double-quotes of folders in your path have spaces). The sqlps module is located in the Tools\Powershell folder for your SQL Server instance.
This indicates that SQL Server is required, or, I perhaps need to copy this folder from the SQL Server?
April 12, 2017 at 7:50 am
CoryEllingson - Wednesday, April 12, 2017 7:38 AMGrant,Thank you, I had reviewed this, tried this, and this did not work. Today I noticed:
If the sqlps module is not in your path, change to the location of the module or use the full path in the script (using double-quotes of folders in your path have spaces). The sqlps module is located in the Tools\Powershell folder for your SQL Server instance.
This indicates that SQL Server is required, or, I perhaps need to copy this folder from the SQL Server?
Have a look at http://guidestomicrosoft.com/2015/01/13/install-sql-server-powershell-module-sqlps/
This tells you what to download and install. (why is the rest of my text appearing as a hyperlink...)
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
Viewing 8 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy