?
Solved

SQL Server PowerShell Console -- syntax?

Posted on 2014-04-03
6
Medium Priority
?
461 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 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Suggested Courses

850 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