Link to home
Start Free TrialLog in
Avatar of dbaSQL
dbaSQLFlag for United States of America

asked on

SQL Server PowerShell Console -- syntax?

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.
ASKER CERTIFIED SOLUTION
Avatar of QPR
QPR
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dbaSQL

ASKER

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
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”
Avatar of dbaSQL

ASKER

I am RDP'd into the SQL server, and running everything there, local to the SQL box.

I will try your suggestion.  Back shortly.
Avatar of dbaSQL

ASKER

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.
Avatar of dbaSQL

ASKER

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.