Featured

TechBytes on Linux

This is a growing list of Linux commands which might come handy for the of Linux users. 1. Found out i had to set the date like this: ...

Tuesday, November 8, 2022

How to use WMI from a .NET Application

To start with, let us see what is WMI and what it offers. WMI is an acronym for Windows Management Instrumentation, which is basically an interface to the Windows OS system settings, drivers, and parameters. It also allows managing Windows personal computers and servers through it.

A .NET developer can use WMI to obtain information about drivers installed on the client machine, verify whether the system is licensed or not, check for hardware configuration and a lot more.

Quoting Linus Torvalds, “Talk is cheap. Show me the code”, let’s get to the basics of WMI usage. To get data through WMI, a SQL-like query is used. The specific query type is called WQL (WMI Query Language). Don’t let the name confuse you. It is still very similar to SQL.

Before diving into code, you should know that Windows comes with a tool called WMI Test Tool, which lets you test WQL queries, to check their correctness and returned results. It is a bit harder to track wrong query results in code, so this tool can save some time for the developer. To run it, just start the Run dialog (or the Command Prompt) and type wbemtest.

Once it is started, you will see a window like this:


Click on Connect and you will see a dialog like this:




It lets you connect to a namespace on your local Windows computer. You can use your credentials (although for most queries this is not a requirement) and select the impersonation and authentication levels (once again, for most queries the default settings are acceptable). Once you click connect, you will be able to execute WMI queries, as well as perform other tasks (for example, enumerate classes in a superclass to review its possibilities).

Before creating a query, you need to understand what information you want to obtain. The query is executed against a WMI class – you can read the complete list here. Let’s take the Win32_Processor class as an example here. Querying against this class will give us information about the CPU installed on a machine. If the machine runs with multiple CPUs, a query result will be returned for each one of them.

The Win32_Processor class exposes the following properties:
AddressWidth
Architecture
Availability
Caption
ConfigManagerErrorCode
ConfigManagerUserConfig
CpuStatus
CreationClassName
CurrentClockSpeed
CurrentVoltage
DataWidth
Description
DeviceID
ErrorCleared
ErrorDescription
ExtClock
Family
InstallDate
L2CacheSize
L2CacheSpeed
L3CacheSize
L3CacheSpeed
LastErrorCode
Level
LoadPercentage
Manufacturer
MaxClockSpeed
Name
NumberOfCores
NumberOfLogicalProcessors
OtherFamilyDescription
PNPDeviceID
PowerManagementCapabilities[]
PowerManagementSupported
ProcessorId
ProcessorType
Revision
Role
SocketDesignation
Status
StatusInfo
Stepping
SystemCreationClassName
SystemName
UniqueId
UpgradeMethod
Version
VoltageCaps

Most of these are have self-descriptive names, but if you are ever confused about one of them, you can always refer to the MSDN documentation for the class, that explains each one of them.

Now, let’s try to get the values of the above mentioned properties in your .NET application. In my examples I am using C#, but if you are using another .NET language, you shouldn’t have a problem adapting the code.

First, you need to add a reference to the System.Management and System. Management.Instrumentation namespaces. This is done by right-clicking on References in the Solution Explorer and selecting Add Reference. Then, you can select the above mentioned libraries from the .NET list:



Once selected, you need to reference the proper namespaces in your code:using System.Management;
Now, to the actual code. I am going to create a function that can be called from anywhere in the code to simplify this task.void GetCPUInfo()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Processor");
foreach (ManagementObject obj in searcher.Get())
{
if (!(obj == null))
Debug.Print(obj.Properties["CpuStatus"].Value.ToString());
}
}


The ManagementObjectSearcher is the key element here – it gets the returned properties based on the query. The parameter I am passing to it when instantiating is the actual query. As you see, it is very similar to SQL. My current query will retrieve all properties available in Win32_Processor. I iterate through them (note that each result is a ManagementObject – the property holder, in this case will be a separate instance for each CPU that is found) and print in the Output window the value of the CpuStatus property:



The 1 here is exactly what is returned. It is a good practice to consult the documentation before reading specific properties, to understand the possible returned values. 1 for CpuStatus means that the CPU is installed and is active.

Important note: Some of the readers might be curious, why there is a null value verification. Some of the classes require user authentication to get the correct data and some properties are simply not available, being the cause of multiple exceptions, depending on the authentication methods and property types. Therefore, to avoid exceptions, this code security measure is used here.

If only one property is needed to be retrieved, then the query can be organized like this:SELECT CpuStatus FROM Win32_Processor


The important thing to remember here is that when you only retrieve one property, the rest of them are unavailable for that specific query result. Therefore, trying to get their value will cause an exception.



Courtesy: Original source is from Denzel D at - https://dzone.com/articles/how-use-wmi-net-application

Saturday, October 29, 2022

Powercube multi socket adapter by allocacoc review


A very useful utility when you are traveling or at home where you have limited power socket outlets.
Powercube multi-socket adapter has 4 number of 3 pin female socket ports & 2 female usb A charging sockets. This is a boon for travelers and gadget freaks that have a lot of devices that require to be charged.
This is also useful when you have limited power sockets at home and you dont want to deal with the messy power strips or wired flex boxes !

Created By Madhukar Rupakumar
Powercube adapter Amazon link - https://amzn.to/3Wax0ah 
Usb A to C female converter from Wayona Amazon link - https://amzn.to/3Wax0ah

 
Follow me on below Social media platforms: Youtube, Twitter, Instagram: krmadhukar 

Sunday, October 16, 2022

My Amazon.in shopping | FireTV Stick 4K Max Unboxing & Overview


I went ahead & bought the Amazon FireTV stick 4K max in this season's Amazon great Indian festival sale. I have 2 televisions at home. One is the Google TV which is the latest software on a Sony 4K 
KD-55X80AJ. The other one is a 43 inches Sony 4K TV with 200 Hz refresh rate which was a great purchase that continues to serve me very well till today since 6-7 years. However, its software had gone a bit old now it being Android TV. Hence I went ahead with this purchase.

Checkout out more details about it in the video.
Here is the link to buy the FireTV 4K Max.

Thursday, September 1, 2022

Sunday, May 15, 2022

Secrets of a successful presentation


1. Practice makes you perfect. If you want to improve your presentation skills, keep practicing, and do more presentations.

2. Your main objective of most presentations is to motivate the audience or convey the message/content you have created clearly. For this, you need to understand what the audience wants and deliver the content nicely to create an impression.

3. It is important to understand your audience and then deliver the content. Don’t deliver the content based on what you know, understand the audience, and prepare/tune/customize the content.

4. If you are meeting the executives, you should be ready with the elevator pitch. Every executive is different and you need to understand what they like, what they don’t like, and their priorities. Tune your content to meet the executive personality and needs.

5. When you structure the presentation, opening, messaging, and closing are the 3 phases. When you open the presentation, try and convey to the audience what is in it for them or why is this important to gather their attention. Keep the opening interesting all the time as it is important to grab the attention of the audience very early in the presentation.

6. There are different types of presentations. For all the different presentations you make, you need to have a clear agenda and a clear summary/call for action.

7. Even the greatest speakers get nervous. So, it is fine to be nervous. Channel your nervousness to prepare and just give your best. If you are honest in your presentation and have done your homework to understand the audience to prepare the content, the audience will see your honesty and appreciate your presentation. Accent, little hiccups during the presentation, minor English mistakes etc. does not matter if you are honest in your effort and give the audience what they want during your presentation.  The last sentence is important to understand considering that India is a diverse country and English is not our mother tongue.

8. Give your best and don’t worry about the rest. If you have followed all the basics before a presentation, you will never fail and will almost all the time pass with distinction. There is nothing like get 100% marks in presentation as there will always be something to improve.

9. Great presenters also create an impact by presenting with slides that look great, telling stories that resonate, showing emotions and voice modulation as required, use effectively the tools available for them to present (e.g. pointers, using whiteboards etc.), using metaphors to catch attention, eye contact, using pause, pitch and pace effectively, using the dias properly (physical presentations) are all important. But all these things make presentations better but there is no substitute for having the right content to meet the audience's needs. If you can design the presentation to meet all the audience objectives and if you can deliver it to make it interesting and exciting, you will create a lasting impression as you impact positively both the right and left brains of your audience.

• Interacting with the audience and engaging is important. Ask questions get feedback so that you can tune the presentation as you go.  

• Manage the time and handle questions/distractions effectively. Use “Let us take it offline or I will get back to you” are 2 ways of managing questions that may not be relevant to the presentation objective or that can hinder you from finishing the presentation within the allotted time.

• Set expectations on when you will take/answer questions. Listening actively and paraphrasing the question and then answering is a good technique as it can help when addressing a large audience where the question may not be heard by all. The time you are paraphrasing also gives you some time to internalize and prepare your answer for the question.

• There may/will be disruptions to presentations in the form of questions from some hecklers during your presentation. You need to know how to deal with these disruptions and not allow these distractions to affect your delivery. See the slides for more tips

• Every person is unique. Don’t fake during a presentation or copy someone’s style unless you are comfortable pulling off without losing your personality. If you like some style of a great presenter, customize it for your own style and your personality. For example, just because somebody looks good walking around the dias, don’t copy it if you are not comfortable. You can start moving around little bit or occasionally and if you don’t see it impact your personality or presentation, embrace the change.

Continue to cover the most key aspects in short catchphrases that capture the audience's imagination.

Courtesy: My sessions with senior technologists @HPE.

Difference between Authentication & Authorization

Authentification can be defined as the verification of a claim of identity by a user, a process, or a device, often as a prerequisite to granting it access to resources within a system.  This can be done once or many times during a particular session, workday or other period of activity consisting of multiple steps & tasks.

Authorization is the real-time decision that a system-issued identity claiming to have access rights to that system can be verified to be a (a) System-issued valid identity which is (b) being used or presented by the subject it has been issued to.

Simply put, authentication is the process of verifying who someone is, whereas authorization is the process of verifying what specific applications, files & data a user has access to.

courtesy: http://medium.com





Thursday, May 5, 2022

Difference Between a Data Leak and a Data Breach

 A data breach is the outcome of a planned cyber attack, but a data leak is the accidental exposure of sensitive data by a business. Cybercriminals do not create data leaks, they discover them and then use them to launch data breach attacks. 

Data leaks tend to result from poor security practices. A business can also be impacted if any of its vendors have a data leak. Because these vulnerabilities occur throughout a vast attack landscape they’re difficult to detect and remediate before it’s too late. 

Without a sophisticated data protection solution, businesses will remain vulnerable to data breaches through their third-party network.

Courtesy - www.upgaurd.com 

Wednesday, February 16, 2022

Type or Category or Classification of Design Patterns

 Type or Category or Classification of Design Patterns

Creational  Based on the concept of creating an object.
    Class
      Factory MethodThis makes an instance of several derived classes based on interfaced data or events.
    Object
      Abstract FactoryCreates an instance of several families of classes without detailing concrete classes.
      BuilderSeparates object construction from its representation, always creates the same type of object.
      PrototypeA fully initialized instance used for copying or cloning.
      SingletonA class with only a single instance with global access points.
        
  Structural  Based on the idea of building blocks of objects.
    Class
      AdapterMatch interfaces of different classes therefore classes can work together despite incompatible interfaces.
    Object
      AdapterMatch interfaces of different classes therefore classes can work together despite incompatible interfaces.
      BridgeSeparates an object's interface from its implementation so the two can vary independently.
      CompositeA structure of simple and composite objects which makes the total object more than just the sum of its parts.
      DecoratorDynamically add alternate processing to objects.
      FacadeA single class that hides the complexity of an entire subsystem.
      FlyweightA fine-grained instance used for efficient sharing of information that is contained elsewhere.
      ProxyA place holder object representing the true object.
 
  Behavioral  Based on the way objects play and work together.
    Class
      InterpreterA way to include language elements in an application to match the grammar of the intended language.
      Template
       Method
Creates the shell of an algorithm in a method, then defer the exact steps to a subclass.
    Object
      Chain of
      Responsibility
A way of passing a request between a chain of objects to find the object that can handle the request.
      CommandEncapsulate a command request as an object to enable, logging and/or queuing of requests, and provides error-handling for unhandled requests.
      IteratorSequentially access the elements of a collection without knowing the inner workings of the collection.
      MediatorDefines simplified communication between classes to prevent a group of classes from referring explicitly to each other.
      MementoCapture an object's internal state to be able to restore it later.
      ObserverA way of notifying change to a number of classes to ensure consistency between the classes.
      StateAlter an object's behavior when its state changes.
      StrategyEncapsulates an algorithm inside a class separating the selection from the implementation.
      VisitorAdds a new operation to a class without changing the class.

 

Difference between webstorage, cookie, local storage & session storage

WebStorage

The Window object implements the WindowLocalStorage and WindowSessionStorage objects which has localStorage(window.localStorage) and sessionStorage(window.sessionStorage) properties respectively. These properties create an instance of the Storage object, through which data items can be set, retrieved and removed for a specific domain and storage type (session or local). For example, you can read and write on local storage objects as below

localStorage.setItem('logo', document.getElementById('logo').value);

localStorage.getItem('logo');

What are the differences between cookie, local storage and session storage

Below are some of the differences between cookie, local storage and session storage,

FeatureCookieLocal storageSession storage
Accessed on client or server sideBoth server-side & client-sideclient-side onlyclient-side only
LifetimeAs configured using Expires optionuntil deleteduntil tab is closed
SSL supportSupportedNot supportedNot supported
Maximum data size4KB5 MB5MB

Wednesday, February 2, 2022

Cloud Computing basics

SaaS - Software as a Service

is on-demand access to ready-to-use, cloud-hosted application software.

E.g. Google Docs, Google Form, Google Spreadsheet. 


PaaS - Platform as a Service

is on-demand access to a complete, ready-to-use, cloud-hosted platform for developing, running, maintaining, and managing applications.

E.g. Amazon EC2 T2 Micro instances 1 GB memory & 1 vCPU under free tier, Microsoft Azure


IaaS - Infrastructure as a Service

The service provides all of the infrastructures to the business. It provides on-demand access to cloud-hosted physical and virtual servers, storage, and networking - the backend IT infrastructure for running applications and workloads in the cloud.

E.g. host.com that provides dedicated servers to organizations. VMware offers support for IaaS for carving out a system rack, network storage & computer into an isolated system for customers.


StaaS - Storage as a Service

E.g. Carbonite, Amazon S3

Storage as a service (STaaS) is a data storage business model where a provider rents storage resources to a customer through a subscription. STaaS saves you money through operating expenditure (OpEx) agility—you only pay for the storage you need, when you need it.

Private & Public Cloud

Amazon AWS is the poor man's public cloud due to its inexpensive pricing model & is the biggest provider.

HPE/Microsoft are mostly used by Enterprise companies as they hold their server on their enterprise public cloud data center are more responsive to their requests & allow them to perform service testing & site maintenance with escort service. 

GoDaddy - Cheaper public cloud-based hosting solutions though not as customizable as Amazon AWS. 

Critical custom data & sensitive IP, in-house information are kept in a Private cloud & the public-facing web server & catalog information is stored in the Public cloud (e.g. Akamai).

To offer more resilient services load balancing with VM on multiple cloud providers is a hot research topic.








Popular Posts