Is there a way to export the results of a WMI query using wbemtest? - wmi

Give this query,
Select * from Win32_GroupUser Where GroupComponent <> "Win32_Group.Domain='domain',Name='AnswerGroup'"
can I export the results using wbemtest? If not, I can create a script that will do it, but I was curious if I could do it directly from wbemtest.
Thanks for the help.

No i don't think Wbemtest provides any such functionality. You can use:
Export-Clixml
Export-csv

Related

What WMI class stores Deployment Type installation program on MECM

I need to retreive a data related the MECM Application via WMI classes, more specifically, I need to get Application Deployment Type properties - Installation / Uninstallation programs.
Could you please help me, what exact WMI class can I use to obtain this information.
Thank you for any help.
This is unfortunately not very easy to get information afaik, but with some help from powershell (or any programming language that can access wmi really) it can be done.
The information itself is stored within the Class SMS_Application in the Property SDMPackageXML.
Now the first thing you will notice if you query this is it is probably empty. That is because it is a lazy property. To work around this in PS you have to for example call an extra get() on your wmi object.
If you do this (or have some tool that just shows all lazy parameters anyway) you will notice it is - as suggested by the name - basically an XML document, that stores the information you need deep inside. So you have to extract it from within the XML.
Some example code on how to do this for a single app would be:
$app = Get-WmiObject -Class SMS_Application -Namespace "root\SMS\site_sitecode" -computer "your site server" -Filter "LocalizedDisplayName='your app name'"
$app.Get()
$installCMD = (([xml](($app).SDMPackageXML)).AppMgmtDigest.DeploymentType.Installer.InstallAction.Args.Arg | where {$_.Name -ieq "InstallCommandLine"}).'#text'
$uninstallCMD = (([xml](($app).SDMPackageXML)).AppMgmtDigest.DeploymentType.Installer.InstallAction.Args.Arg | where {$_.Name -ieq "UninstallCommandLine"}).'#text'
I'm not great with xml parsing so there might be a better way to do it or maybe you don't need the parsing but can just string compare the xml digest. Just start by looking at a SDMPackageXML and then you will probably see how to best analyze it for your own needs.

django-rest-swagger==2.1.1 query parameter

i have an api(web service) in django like this:
http://127.0.0.1:9000/api/back_office/appointments/days/?branch=1
that in swagger i want to input query parameter named branch but don't work this(all of my Apis have same problem!!).
before, i use older version of swagger and for enter query parameters use like --param_name syntax, but now in django-rest-swagger==2.1.1 don't work this syntax.
can anyone help me?
Perhaps i should use get_customizations in OpenAPIRenderer class?
Thanks in advance.
For adding query parameters to swagger please, go through this post

Postgres select function in Django annotation

I have old database and need custom select.
in sql i can use:
SELECT x(geometry) FROM table
but I dont know how to force x() function in django select.
You can create a custom function using Expressions.
class GeoX(Func):
function = 'X'
MyModel.objects.annotate(x=GeoX('field'))
This will result in the geometry X function being invoked and it's result being annotated to a field labeled x in your model. However this is the inferior solution. The better solution is to install geodjango. That provides full access to almost every single function in PostGIS. Also works with spatialite and msyql spatial extensions.
I managed to solve problem using Func()
Func(F('geometry'), function='x')

Doctrine2 apply function to query parameter

I use the doctrine query builder to build my query.
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select(array('u'))->from('Account', 'a');
-- problem here
$qb->where('lower_unaccent(u.email) LIKE :search');
$qb->setParameter('search', $search['search'] . '%');
This works fine, but I would also like to apply the lower_unaccent function to the search parameter.
Is there a way to do this with the query builder?
Because when I do LOWER_UNACCENT(u.email) LIKE LOWER_UNACCENT(:search) I get the following error:
Error: Expected Doctrine\ORM\Query\Lexer::T_STRING, got 'LOWER_UNACCENT'
Even if I change LOWER_UNACCENT TO LOWER, I get the same error message.
You have to use $qb->expr()->lower('u.email') and $qb->expr()->lower(':search'). To create the "LIKE" pass those as arguments to $qb->expr()->like().
There doesn't seem to be a unaccent method though, but maybe there is a way to customize this. Let me know how it went.
EDIT:
Looking into lower()'s code, it seems like you can use any function you want like this:
new Expr\Func('LOWER', array($x));
By default, I'm pretty sure you can't do that.
lower_unaccent is not standard SQL, and as far as I can see, not supported by Doctrine.
What you can do is extend DQL with user-defined functions, which will do whatever you want. It is not so hard to implement. Here is some documentation:
http://docs.doctrine-project.org/en/2.0.x/cookbook/dql-user-defined-functions.html
http://docs.doctrine-project.org/en/2.0.x/reference/dql-doctrine-query-language.html#adding-your-own-functions-to-the-dql-language

Doctrine automatically create all the database tables?

is there any way to tell doctrine automaticaly create schema tables without using this command :
doctrine:schema:update --force
Using SchemaTool and EntityManager you can do this:
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($entityManager);
$classes = $entityManager->getMetadataFactory()->getAllMetadata();
$schemaTool->createSchema($classes);
I'm not sure what you want to do, but if you want to do it from php code, you can check how the doctrine command works and copy the code. You can find it here:
vendor/symfony/src/Symfony/Bundle/DoctrineBundle/Command/CreateDatabaseDoctrineCommand.php
If you check the execute method, you will see how it's done. Apparently you need to get a connection through the DBAL DriverManager, which gives you access to a schema object, which in turn has a createDatabase method. I have not tried this myself.