[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

SQL Server PowerShell Console -- syntax?

Posted on 2014-04-03
6
Medium Priority
?
459 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 29

Accepted Solution

by:
QPR earned 1500 total points
ID: 39976813
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
ID: 39976835
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
ID: 39976859
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 your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 17

Author Comment

by:dbaSQL
ID: 39976866
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
ID: 39976937
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
ID: 40000296
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

650 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