Solved

SQL Server PowerShell Console -- syntax?

Posted on 2014-04-03
6
449 Views
Last Modified: 2014-10-14
SQL v2012.   Unfortunately, I have always tasked the PowerShell efforts to staff members... I've never really had any hands-on before, and now I am having some problems invoking a script.

I am using the instructions from http://epmframework.codeplex.com/, in the EPM Configuration Documentation v3.docx.  I am in SSMS, connected to my CMS server, and have started PowerShell.  I have attempted the first statement here, within the console, but it does nothing.   The 2nd one works fine --

This does nothing -- No errors, no output, nothing:
>> SL "D:\directoryName\EPM_EnterpriseEvaluation_3.0.0.ps1" -ConfigurationGroup "myGroupName" -PolicyCategoryFilter " " –EvalMode “Check”

Yet this works:
>>Invoke-Sqlcmd -Query "SELECT @@VERSION;" -QueryTimeout 3


As I said, the top one does nothing.  I just carriage return to another line prefaced with the two carrots.

>>


I'm surfing for all kinds of how-tos for powershell in SQL.  I found this:
http://www.mssqltips.com/sqlservertip/1745/using-powershell-with-sql-server-management-objects-smo/

A 1/4 or so down, it says this:

By default, you wouldn't be able to execute scripts in Windows PowerShell due to the security policy.

Is that my problem?  I have attempted to set the set-executionpolicy, but that also returns no response within the console.


I needed this darned thing done a week ago.  Any instruction is appreciated.  Hugely.
0
Comment
Question by:dbaSQL
  • 4
  • 2
6 Comments
 
LVL 29

Accepted Solution

by:
QPR earned 500 total points
Comment Utility
Have you tried the discussion board on codeplex for this feature?
http://epmframework.codeplex.com/discussions

Without knowing what the PS script should do it's not easy to try and work out what is going wrong.
0
 
LVL 17

Author Comment

by:dbaSQL
Comment Utility
Sure, I understand your point on knowing what the ps script is doing, but I don't believe that is even applicable yet.   I am just asking how to properly invoke it from the PowerShell console, launched within SSMS.

As I mentioned, I am using the help doc from the EMP Framework link that I referenced earlier.  I have attached it now, but everything in the carrots is cut/pasted from the doc, and it is what I am trying to do.  I tried it as you see here, and it did absolutely nothing.  I believe the problem is that I am just not familiar enough with SQL Server Powershell yet.  


>>>>>
To test the script prior to creating a job, open PowerShell in SQL Server 2008 Management Studio.  
a.      Open SQL Server Management Studio.  Connect to the Central Management Server.
b.      In Object Explorer, right-click on the Server and select “Start PowerShell”
c.      Configure the following commands to your environment.  Paste the commands to the SQL Server PowerShell console.  

SL "Insert script folder location”
.\EPM_EnterpriseEvaluation_3.0.0.ps1 -ConfigurationGroup "Insert Central Management Server Group" -PolicyCategoryFilter "Insert Policy Category" –EvalMode “Check”
>>>>>>>>
EPM-Configuration-Documentation-.docx
0
 
LVL 29

Expert Comment

by:QPR
Comment Utility
Are you running SSMS on your client or on the SQL box?
Is the path to the PS1 relevant to your client or the sql box?

Try

PowerShell -NoExit -Command "D:\directoryName\EPM_EnterpriseEvaluation_3.0.0.ps1" -ConfigurationGroup "myGroupName" -PolicyCategoryFilter " " –EvalMode “Check”
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 17

Author Comment

by:dbaSQL
Comment Utility
I am RDP'd into the SQL server, and running everything there, local to the SQL box.

I will try your suggestion.  Back shortly.
0
 
LVL 17

Author Comment

by:dbaSQL
Comment Utility
Nope.  No difference.  I'm not sure what I am missing here, but I am not getting anything back from the console, if I go in with the methods I've posted, or even your own.

It just returns and gives me no output at all.
0
 
LVL 17

Author Closing Comment

by:dbaSQL
Comment Utility
No reason to keep this open.  I believe I just need to get more familiar with Powershell.  I will award the points, QPR.  Thank you for your time.
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now