Trying find state for services in Win32_Service - wmi

I am using wbemtest.exe to execute WQL queries. My goal is to obtain the state of services in Win32_Service class. My query is select State from Win32_Service where DisplayName="Windows Defender". The result I am expecting is Win32_Service.State=Stopped/Running, but it is showing Win32_Service=<no key>. If I do select * from Win32_Service where DisplayName="WIndows Defender", I obtain the only Win32_Service.Name=WinDefend". Thanks in advance.

Related

How to run a simple query using Informatica PowerCenter

I have never used Informatica PowerCenter before and just don't know where to begin. To summarize my goal, I need to run a simple count query against a Teradata database using Informatica PowerCenter. This query needs to be ran on a specific day, but doesn't require me to store or manipulate the data returned. Looking at Informatica PowerCenter Designer is a bit daunting to me as I'm not sure what to be looking for.
Any help is greatly appreciated in understanding how to setup (if needed):
Sources
Targets
Transformations
Mappings
Is a transformation the only way to query data using PowerCenter? I've looked at a lot of tutorials, but most seem to be oriented to familiar users.
You can run a query against a database using informatica, only if you create a mapping, session and workflow to run that. But you cannot see the result unless you store it somewhere, either in a flatfile or a table.
Here are the steps to create it anyway.
Import your source table in source analyzer from Teradata.
Create a flat file target or import a relational target in target analyzer
Create a mapping m_xyz, drag and drop your source into the mapping.
You will see your source and source qualifier in the mapping. Write your custom query in source qualifier, say select count(*) as cnt from table
Remove all the ports from SQ except one numeric port from source to SQ and name it as cnt, count from your select will be assigned to this port.
Now drag and drop this port to an expression transformation.
Drag and drop your target into the mapping
Propagate the column from expression to this flat file/relational target.
Create a workflow and a session for this mapping.
In workflow you can schedule it to run on specific date.
When you execute this, count will be loaded into the column of that flat file or table.

Auto Create statistics in Azure SQL DW

In Azure SQL Datawarehouse i just used the below tsql code to enable auto statistics creation.The command ran successfully , but when i checked in database properties under option tab Auto Create Statistics is till set to False.
ALTER DATABASE MyDB SET AUTO_CREATE_STATISTICS ON;
Please let me know if i'm missing here something. I have the db_owner access for the database also.
I'm guessing that you are using SQL Server Management Studio.
I was able to reproduce the symptom by turning off and on auto_create_statistics.
The issue appears to be that the database metadata is cached in SSMS. Right-click the database name and select "Refresh" before selecting "Properties". Using this method I got the correct setting for auto_create_statistics showing up each time.
My tests were done using SSMS 17.7
(The need to refresh the database metadata can also occur when adding or removing tables, columns, etc)
You can also query sys.databases, the is_auto_create_stats_on column.

WMI Query SID to User

I'm looking for a simple WQL query that can convert an Windows user SID to a username.
There are multiple methods that show this being done through wmic or powershell, I am using a python module which is capable of running WQL queries against some local namespace - and would just need a query.
I am using WBEMTest for testing.
Select * FROM win32_accountSID

Auditing Tables in Informatica

We want to maintain auditing of tables ,
For that my question is
1)will the commit interval in Informatica will be stored anywhere in any variable ,
so that we can maintain the record count for every commit interval.
2)is there any method/script to read the stats from session log and save in audit table.
3)If there are multiple targets in my mapping then in monitor after executing it will show target success count and target reject count as total for all the targets in the mapping.
how to get individual target success and reject count .
You need to use informatica metadata tables which informatica doesn't recommend(still I am mentioning for your reference). So your options are to create a sh/bat script to get these info from session log or create a maplet that collects this kind of statistics and add that maplet in every infa mappings. To answers your questions -
Yes, commit intervals stored in informatica table opb_task_attr where attr_id=14 and select attr_value.
Nope, either you can use some infa mapplet to collct such stats or some shell script.
Yes this is possible. use infomatica view rep_sess_tbl_log for this purpose. Here you can get each target's statistics of a particular session's run.
Koushik

WQL Subquery as field value, CIMV2 WMI WQL query for WMI-Filter

I need help on a WMI query for a Group Policy WMI-Filter. I'm querying the win32_group namespace within the root\CIMV2 WMI provider.
I am doing a search for a Local Security group (like "Administrators") on several window's computer (XP-8, server 03-12). When the query runs on a computer I would like it to inject the computer name into the equivalency field for the Domain.
The base WQL statement looks like this:
SELECT * FROM win32_group
WHERE Domain="currentComputerName" and Name="Administrators"
My goal is to run a WQL statement along these lines, but it is a bad WQL statement:
SELECT * FROM win32_group
WHERE Domain=(SELECT Name FROM Win32_ComputerSystem) and Name="Administrators"
It is important that I am able to inject the current computer's name for the Domain. These computers are part of a Active Directory (AD) domain. By default the win32_group will search all of the AD Domain's groups in addition to the Local Computer's security group (if omitting the Domain parameter). By specifying the local machine name as the domain the query's performance is multitudes faster - which is essential for its purpose.
I have tried some query variations in WBEMTEST with no luck. Does anybody have any ideas on how to inject the computer's name into the WQL WMI Query? Is there possibly a constant that I could use, like HOSTNAME at the command prompt?
Thank you for your help!
What language are you writing this in? Or to be clear, what programming or scripting language you are using to run these WMI queries?
In PowerShell, you could do this by running the following code:
Get-WMIObject -Query "SELECT * FROM Win32_Group WHERE Domain='$env:USERDOMAIN' AND Name='Administrators'"