Solved

SQL Server PowerShell Console -- syntax?

Posted on 2014-04-03
6
453 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
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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
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
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

828 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