Adding Run As Account in a Script in Console - Sample PowerShell MP

I have modified Sample PowerShell MP for running SQL Queries using run as account as follows:

 <TypeDefinitions>
    <SecureReferences>
      <SecureReference ID="Microsoft.SQLServer.SQLProbeAccount" Accessibility="Public" Context="System!System.Entity" />
      <SecureReference ID="Microsoft.SQLServer.SQLDefaultAccount" Accessibility="Public" Context="System!System.Entity" />
      <SecureReference ID="Microsoft.SQLServer.SQLDiscoveryAccount" Accessibility="Public" Context="System!System.Entity" />
    </SecureReferences>
    <ModuleTypes>
      <DataSourceModuleType ID="xxx.SQL.TimedPowershell.v1.PropertyBagProvider" RunAs="Microsoft.SQLServer.SQLProbeAccount" Accessibility="Public" Batching="false">
        <Configuration>
          <xsd:element minOccurs="1" name="IntervalSeconds" type="xsd:integer" />
          <xsd:element minOccurs="1" name="SyncTime" type="xsd:string" />
          <xsd:element minOccurs="1" name="TimeoutSeconds" type="xsd:integer" />
          <xsd:element minOccurs="1" name="ScriptName" type="xsd:string" />
          <xsd:element minOccurs="1" name="ScriptBody" type="xsd:string" />
          <xsd:element minOccurs="0" name="Arguments" type="xsd:string" />
        </Configuration>

It seemed to work fine for a while but when created a new monitors, found the queries running under 'NT AUTHORITY\SYSTEM'
How can I add Run As account in the Script  to ensure all the queries are running under RunAsAccount??

Thanks

September 8th, 2015 12:08pm

Are you using Visual Studio - if so, you can add it to the new monitors in Visual Studio. In the monitor properties, under advanced, there is a "Monitor Run As" option.

Regards

Graham

Free Windows Admin Tool Kit Click here and download it now
September 8th, 2015 2:59pm

No, I am not.

I have modified Sample PowerShell MP and added the SecureRefrence and sealed it. Idea is to run SQL Queries needing the account in SCOM Console. I am creating monitor in SCOM Console using PS SQL Query

I am using PS Scriptin SCOM Console

September 8th, 2015 3:29pm

Additional Information: As shown I have added SQL Run As Account in Parameter Section.

Hope this explains what I am trying to do

Free Windows Admin Tool Kit Click here and download it now
September 8th, 2015 4:03pm

Have to admit that I'd do all of this in Visual Studio - to me, it is more straight forward. I can look to add an example on the team blog to walk everyone through it.

This is another option:

http://www.systemcentercentral.com/how-to-create-a-monitor-with-a-different-run-as-account/

September 8th, 2015 5:39pm

Thanks, that would be of great help. I have used VSAE for writing MP but not Visual Studio. Are we on the same page here??

Free Windows Admin Tool Kit Click here and download it now
September 8th, 2015 6:17pm

Got it, That part I have already done when I wrote MP in VSAE but is not acceptable to customer as they do not have expertise to write MP and want to Add/modify SQL Queries on the fly. That's why I am going thru all these hoops and trying to do all this in a SCOM Console. And this is becoming a REAL Challenge.
  • Edited by DCM-1 8 hours 12 minutes ago
September 8th, 2015 6:51pm

Got it, That part I have already done when I wrote MP in VSAE but is not acceptable to customer as they do not have expertise to write MP and want to Add/modify SQL Queries on the fly. That's why I am going thru all these hoops and trying to do all this in a SCOM Console. And this is becoming a REAL Challenge.
  • Edited by DCM-1 Tuesday, September 08, 2015 10:57 PM
Free Windows Admin Tool Kit Click here and download it now
September 8th, 2015 10:50pm

Got it, That part I have already done when I wrote MP in VSAE but is not acceptable to customer as they do not have expertise to write MP and want to Add/modify SQL Queries on the fly. That's why I am going thru all these hoops and trying to do all this in a SCOM Console. And this is becoming a REAL Challenge.
  • Edited by DCM-1 Tuesday, September 08, 2015 10:57 PM
September 8th, 2015 10:50pm

Got it, That part I have already done when I wrote MP in VSAE but is not acceptable to customer as they do not have expertise to write MP and want to Add/modify SQL Queries on the fly. That's why I am going thru all these hoops and trying to do all this in a SCOM Console. And this is becoming a REAL Challenge.
  • Edited by DCM-1 Tuesday, September 08, 2015 10:57 PM
Free Windows Admin Tool Kit Click here and download it now
September 8th, 2015 10:50pm

Visual Studio Authoring Extensions requires Visual Studio:

http://blogs.technet.com/b/manageabilityguys/archive/2015/08/24/visual-studio-management-pack-authoring-series-part-1-download-pre_2d00_requisites.aspx

Perhaps you are using the SCOM 2007 R2 Authoring console (you can use this to create new management packs that work in SCOM 2012 although there are some caveats).

The SCOM console is a real challenge in terms of authoring and places restrictive limitations on what you can do.

September 9th, 2015 2:13am

Thanks Graham for all your suggestions. I have authored couple of MPs for SQL Queries but as said earlier, the customer wants an ability to Add/Modify/change the SQL Queries in SCOM console and unfortunately I am unable to do so in SCOM. Customer is used to simple way this can be achieved in their current PRTG monitoring. I am migrating them from PRTG to SCOM but have run into this roadblock. Planning to take the route by adding a statement to query and making it into stored procedure as mentioned in this

http://www.systemcentercentral.com/forums-archive/topic/running-a-sql-query-in-scom-to-produce-results/

and then following this 

http://jimmoldenhauer.blogspot.com/2013/03/scom-2012-how-to-generate-alerts-from.html

Sincerely wish it was as simple as in current PRTG monitoring where one can Add/Modify SQL Queries on the fly.

Thanks once again

Dilip

Free Windows Admin Tool Kit Click here and download it now
September 9th, 2015 1:08pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics