Creating Custom WMI classes for SCCM queries - wmi

I am working to create a custom WMI class for use with SCCM's device collection membership query rules to expose some organization specific information to SCCM for collection creation. I have managed to add a new class in with the MOF file below, and it shows up in the GUI as expected with the desired display name.
The only issue I believe I have left to solve is how to make the generated query work as expected. I know by default joins are not supported in WQL. However Microsoft seems to be using them regularly in these queries, and I have verified they work as expected outside of the application. Is there some sort of joining class I need to create to make this work? Is there some attribute to designate a property as a forigen key??
I have searched through the System Center Configuration Manager SDK documentation, and the WMI reference on the Windows Dev Center site for a few hours without much luck and would really appreciate any helpful input.
MOF File:
#pragma namespace ("\\\\.\\root\\sms\\site_lab")
[DisplayName("CMDB CI Computer")]
class SMS_G_System_MTS_cmdb_ci_computer : SMS_G_System
{
[key] uint32 ResourceID;
string asset_tag;
string dv_company;
string dv_cost_center;
string dv_location;
};
SCCM Generated Query:
select * from SMS_R_System inner join SMS_G_System_MTS_cmdb_ci_computer on SMS_G_System_MTS_cmdb_ci_computer.ResourceID = SMS_R_System.ResourceId
I am testing these commands with the Get-CimInstance command in powershell with the below results
Powershell:
This command returns the joined objects as expected.
Get-CimInstance -Namespace 'root\sms\site_lab' -Query 'select SMS_G_System_PROCESSOR.Architecture from SMS_R_System inner join SMS_G_System_PROCESSOR on SMS_G_System_PROCESSOR.ResourceId = SMS_R_System.ResourceId'
This command throws an "Invalid Query" Error.
Get-CimInstance -Namespace 'root\sms\site_lab' -Query 'select asset_tag from SMS_R_System inner join SMS_G_System_MTS_cmdb_ci_computer on SMS_G_System_MTS_cmdb_ci_computer.ResourceID = SMS_R_System.ResourceId'

Related

Web Service in SSIS

I am trying to use a web service as part of a dataflow task in SSIS. Right now i have a script task within a data flow with a web service reference.
What the task has to ultimately do is: collect all postal codes from an inernal database > use the web service i created to get the lay/long of thos postal codes > export the lat/long to a table.
As i said before i have the scrip set up and looks to be working, but when i go to execute the package i get an CannotCreateUserComponentException error.
Any help on this would be awesome, or another approach to it? I am new to the web services in SSIS so this is the best solution i could come up with.
Edit:
Right now the script is accepting the postal code from an OLE DB Source and will ouput a string in for format of "lat,long" (presumably). The web Service was created by someone within the company and has one method called FindCoordinates which takes in a string value (Postal code)(which i think calls the google geocode xml, not exactly sure what he did). Here is the code that is currently in my script:
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using SC_6c1b642acd544cd5b01c032b6f8dfd03.csproj.MyService;
using System.Xml;
using System.Web.Services;
[WebService(Namespace = "http://microsoft.com/webservices/")]
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
public override void PreExecute()
{
base.PreExecute();
/*
Add your code here for preprocessing or remove if not needed
*/
}
public override void PostExecute()
{
base.PostExecute();
/*
Add your code here for postprocessing or remove if not needed
You can set read/write variables here, for example:
Variables.MyIntVar = 100
*/
}
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
String postal = Row.PostalCode;
Service service = new Service();
Row.LatLong = service.FindCoordinates(postal);
}
}
Hope this help.

wbemtest doesn't show certain data after executing a query

I have BitLocker enabled on my machine and I want to use the wbemtest.exe utility to view properties about the Bitlocker data.
According to the properties section at MSDN, some of the data that I want to retrieve are DeviceID, DriveLetter, PersistentVolumeID, and ProtectionStatus.
However, when I execute the query
SELECT * from Win32_EncryptableVolume
using wbemtest.exe, only one object gets returned, and that is BitLocker DeviceID. I also want this query to return the DriveLetter and the other properties. What do I do to retrieve these? The data should be there, because my C# app using System.Management is able to get data on the other properties without any trouble (by assigning the return value of a ManagementClass GetInstances() method to a a ManagementObjectCollection.)
It turns out that I am able to view the data I need quite simply by using the WMI Code Creator utility.
I found this information on windows-noob

Doctrine2 - No Metadata Classes to process

Something is wrong with documentation or me. I do all what documentation says.
When i put in terminal :
$ php vendor/bin/doctrine orm:schema-tool:create
Output is :
No Metadata Classes to process
I read to many posts, and google and try to many examples but nothing.
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/getting-started.html
I think you took the config example from Doctrine2: getting started:
$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration([__DIR__."/src"], $isDevMode);
The trick is now that the Setup::createAnnotationMetadataConfiguration method uses a SimpleAnnotationReader by default. You can change this behaviour by changing the fifth parameter to false:
$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration([__DIR__."/src"], $isDevMode, null, null, false);
This will force Doctrine to use the not-simple AnnotationReader which can handle your models now!
TL;DR: Make sure the type of metadata you created matches the "create metadata configuration" method you used.
I encountered the same problem while working through the Doctrine "Getting Started" guide. After looking through the Doctrine code a bit I figured out what was going wrong. Basically, the code in the tutorial in the "Obtaining the EntityManager" section is:
$config = Setup::createAnnotationMetadataConfiguration([__DIR__ . "/src"], $isDevMode);
A little further in the tutorial, in the "Starting with the Product" section, it shows us how to set up the metadata, with an example for each of the possible options for this. The tutorial says:
Metadata for entities are configured using a XML, YAML or Docblock Annotations. This Getting Started Guide will show the mappings for all Mapping Drivers. References in the text will be made to the XML mapping.
Because of this statement, I decided to use the XML configuration. Unfortunately, the createAnnotationMetadataConfiguration method in the tutorial code did not seem to be using the XML file I had created. (In hindsight, it seems much more obvious that this method is specifically referring to annotation metadata, not XML metadata!)
After I changed it to createXMLMetadataConfiguration instead, it worked as expected. So it looks like one possible source of this problem is that the "create metadata configuration" method you used may not match the type of metadata you created.
Try clearing the cache:
sudo -u www-data php app/console cache:clear --env=dev
Uncomment the one of the following lines in bootstrap.php:
// or if you prefer yaml or XML
//$config = Setup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode);
//$config = Setup::createYAMLMetadataConfiguration(array(__DIR__."/config/yaml"), $isDevMode);
Which depends if you created yaml or xml meta config files...
Hope this helps.
Had the same issue with custom Doctrine installation. My solution was to re-set metadata driver:
$config->setMetadataDriverImpl(
new Doctrine\ORM\Mapping\Driver\AnnotationDriver(
new Doctrine\Common\Annotations\CachedReader(
new Doctrine\Common\Annotations\AnnotationReader(),
new Doctrine\Common\Cache\ArrayCache()
),
ENTITY_DIR
)
);
Solution from http://support.skipper18.com/1120/how-use-external-tools-generate-doctrine-getters-and-setters?show=1121#a1121
My scenario was generating entities from existing database
The newDefaultAnnotationDriver adds the namespace and the method comments state the following:
If $useSimpleAnnotationReader is true, the notation #Entity will
work, otherwise, the notation #ORM\Entity will be supported.
I had the same problem when creating a new doctrine config in a new ZF2 module.
problem was caused by
'User\Entity' => 'property_entities'
the user part was from the old entity
'Property\Entity' => 'property_entities'
Changing that fixed the issue
If you're using the XML mapping (using Setup::createXMLMetadataConfiguration()), you might want to pay attention to the following:
That your XML mapping files ends by .dcm.xml, not only by .xml.
That your XML file contains the full entity classname, inclusive of the namespace. For example, for a class Company\Solution\Models\User, you must have the Company.Solution.Models.User.dcm.xml mapping file in your XML path.
In my case, the issue was with the number of asterisk used for the annotation
<?php
namespace Models;
use Doctrine\ORM\Annotation\{Id, Column, GeneratedValue, Entity};
/** // I originally used one asterisk here and kept getting the error in question. Error disappeared after doubling the asterisk as it is in this answer
* #Entity(repositoryClass="Doctrine\ORM\Annotation\Id")
*/
class User {
}
?>
you must add the docstring for example:
<?php
// src/User.php
use Doctrine\ORM\Mapping as ORM;
/**
* #ORM\Entity
* #ORM\Table(name="users")
*/
class User
{
/**
* #ORM\Id
* #ORM\Column(type="integer")
* #ORM\GeneratedValue
*/
private $id;
/**
* #ORM\Column(type="string")
*/
private $name;
}
Try the following command:
php vendor/bin/doctrine-module orm:schema-tool:create

How to find the source of ora-01031 insufficient privileges when executing a test on a ref cursor with utPLSQL?

I'm doing research on unit testing in PLSQL. I set up a test database with some tables and packages with functions and procedures. Currently I'm giving the test framework 'utPLSQL' a try but stumbled upon an error when testing on a ref cursor. I can run all of my tests but the result of the test on the ref cursor says "ora-01031 insufficient privileges", that's all I get. How can I find the source of this error? Or does anyone encountered the same problem? The installation of utPLSQL was successful and all the other functionality of the test framework works.
This is the procedure I want to test:
FUNCTION F_Get_Customers_RefCurs(P_LASTNAME IN VARCHAR2)
RETURN cust_refcur
IS
cust_result cust_refcur;
BEGIN
OPEN cust_result FOR
SELECT *
FROM CUSTOMERS
WHERE LASTNAME = P_LASTNAME
ORDER BY email ASC;
return(cust_result);
END F_Get_Customers_RefCurs;
I have declared cust_refcur in the spec of the package which contains my function as following:
TYPE cust_refcur IS REF CURSOR;
And this is the test:
PROCEDURE ut_F_Get_Customers_RefCurs
IS
params utplsql_util.utplsql_params;
BEGIN
utPLSQL_Util.reg_In_Param (1,
'Tester',
params);
UTASSERT.eq_refc_query ('Get customers on last name is successful (refcursor)',
'PK_ORDERS.F_GET_CUSTOMERS_REFCURS',
params,
0,
'SELECT customerid, firstname, lastname, email, password
FROM CUSTOMERS
WHERE LASTNAME = ''Tester''
ORDER BY email ASC');
END;
I tried getting your example to work, but unfortunately, I got weird errors from utPLSQL.
Since the last version of utPLSQL on Sourceforge is from 2005 and Steven Feuerstein is now working on a commercial product that essentially does the same, I'd recommend looking into other solutions for unit testing your PL/SQL code - some links:
Oracle SQL Developer has some built-in unit test-functionality, and it's free
there's also Quest code tester (this one's commercial)
maybe cause by 'RETURN cust_refcur',the type use by utplsql is store in varchar2(10) ,
try 'return refcur' ?
-zhaozb
When running this assertion (eq_refc_query), utPLSQL needs to temporarily create a table. It does this by using EXECUTE IMMEDIATE which requires that the user have the CREATE TABLE privilege granted to them directly, rather than via a role.
[Full disclosure: I am one of the administrators of the utPLSQL project]

C++ Builder XE3, IntraWeb, Display SQL Server database query results

Our company is beginning development on an IntraWeb application which requires access to our SQL Server database(s). I am attempting to creating a very basic application to get one column of data from our database and display it... in any way possible. I have attempted many times to do this but have only seen failure. From what I see I can not even get query results. I am using C++ Builder XE3. This is what I am doing...
Create IntraWeb Application Wizard (Standalone)
Add #include "UserSessionUnit.h" to Unit1.cpp
Set IWServerController->ComInitialization to ciMultiThreaded
Drag TADOConnection to UserSessionUnit
Set ADOConnection1->ConnectionString using builder (Microsoft OLE DB Provider for SQL Server)
Drag TADOQuery to UserSessionUnit
Set ADOQuery1->Connection to ADOConnection1
Set ADOQuery1->SQL to "SELECT Column1 FROM Table1"
Drag TDataSource to UserSessionUnit
Set DataSource1->DataSet to ADOQuery1
Drag TIWDBGrid to Unit1
Set IWDBGrid1->DataSource to IWUserSession.DataSource1
Run the query when IWForm1 is created...
void __fastcall TIWForm1::IWAppFormCreate(TObject *Sender)
{
UserSession()->ADOQuery1->Open();
}
I imagine this should work. The application builds and runs with no errors, but displays only an empty grid...
I replicated this scenario in a C++ Builder VCL Forms Application and it worked no problems (used TDBGrid instead of TIWDBGrid, of course).
I have tried this with several "TIWDB" components to no avail.