Showing posts with label WQL Language. Show all posts
Showing posts with label WQL Language. Show all posts

Wednesday, October 23, 2013

PowerShell Script : Find the name of Installed Antivirus on local or remote laptop.

 

Do you ever want to know what antivirus installed on remote laptop, or does remote system has a antivirus or not, knowing this is  always a pain, normally you have to call user and ask them,.

Today i have found a cool namespace named “"root\SecurityCenter2" ”  and this name space has a class “AntiVirusProduct ”, you just need to query that class and it will show you the name { and few more info}  of the antivirus installed.

Download Link : http://gallery.technet.microsoft.com/Get-The-Name-of-Installed-b10fd073 

You can download a little script { if you like } from the above link and when i run it, you can see that it is showing me the name of antivirus installed on my laptop.

23-10-2013 18-14-35

You can run the above script on remote laptop too.

function Get-AntivirusName {

 

[cmdletBinding()]   

param (

[string]$ComputerName = "$env:computername" ,

$Credential

)

 

 

       BEGIN

              {

                     # Setting WMI query in a variable

              $wmiQuery = "SELECT * FROM AntiVirusProduct"

 

              }

 

 

       PROCESS

              {

                     # doing getting wmi

               

                     $AntivirusProduct = Get-WmiObject -Namespace "root\SecurityCenter2" -Query $wmiQuery  @psboundparameters # -ErrorVariable myError -ErrorAction 'SilentlyContinue'         

            Write-host $AntivirusProduct.displayName -ForegroundColor Cyan

 

              }

 

       END {

 

              }

} #end  of the function

 

Thanks for reading.

Aman Dhally

Tested on : Windows7 [64 bit]

 
clip_image001 clip_image002 clip_image003 clip_image005  clip_image007

Tuesday, October 22, 2013

PowerShell Tip : Find Default Printer Installed using Powershell.

 

The job of System Administrators are very adventurous, sometime you have to find a little-little settings and sometime you have to write a big-big,  hundred’s of line’s scripts.

Today, my task was to find a default printer installed on laptops. To solve it , i used the Win32_Printer class.

You can run the below query on your laptop and this will show you the default installed  printer on your system.

To run the below command on the remote system you can –Computer parameter and make sure you are proper admin rights to access the system.

We are using Get-WmiObject cmdlet and then we are running a WQL query to select everything from Win32_Printer class and choose to show that result where default value is true.

Simple

Get-WmiObject -Query " SELECT * FROM Win32_Printer WHERE Default=$true"

21-10-2013 17-53-29

If you want to see all printers installed on your laptop, you can run the below code and this will show you the list of all printers,  with their Port Name and location.

Get-WmiObject -Query " SELECT * FROM Win32_Printer" | Select Name, Default, PortName,Location

21-10-2013 13-53-47

I love WMI .

Happy learning . ;o) .

Tested on : Windows7 [64 bit]

Thanks
Aman Dhally
clip_image001 clip_image002 clip_image003 clip_image005  clip_image007

Thursday, October 20, 2011

Generate System Information Reports using WMI and PowerShell

 

Hi Guys,

Do you ever want to see what going on users machines? or what Settings he have on his system,?

If you have few users in your office then you can go to there desk and check it manually, but –whatif ? you have hundreds on users or you are supporting a remote users.

I just came to same problem when i want to support a remote users and he don’t know how to run “Task manager”, how to open “RUN” dialogue box so that we can run “Msconfig” to view the list of soft wares which are on system startup list , and the internet connection was very low at his end and i can’t be able to do anything remotely.

To overcome from this situation I wrote a little script which get the system info and put everything in a HTML file and when when script done it open the HTML file in Internet Explorer. Then you can ask user to send that HTML file to you by email.

This script is using “WMI” queries to find the information , using get-wmiobject command and the covert everything to HTML using “Convertto-Html” cmdlet and save the output in to a file.

 

Currently the the HTML report contains .

  1. BIOS Information
  2. Physical Disk Drives
  3. List of Network Adapters
  4. Operating System Information
  5. Logical Disk Drives
  6. IP Addresses for each Network Card
  7. List of Startup softwares
  8. Running Processes
  9. List of Services [ Whose “startup” mode is set  “Automatic” but they are currently “Stopped” for some reason]

 

you can also add more “wmi” queries in to the script. like, Battery info, CDROM Drive info, Printer info etc in to it.

I tested the script on “Windows7” and it is working perfectly.

The output of the script will be found at : C:\Users\USERNAME\Computername.html

you can download the whole script from here : http://dl.dropbox.com/u/17858935/SystemInformation.zip

Screenshot:

SystemInfo

Hope you like it

Thanks

aman dhally