Showing posts with label WMI. Show all posts
Showing posts with label WMI. Show all posts

Monday, August 13, 2012

WMIX Extensions for Powershell.

 

Twitter, is a great social networking site but for me the main use of it is to follow PowerShell MVPs , that constantly share awesome and cool PowerShell Stuff plus most of the queries get answered spontaneously.
So If you haven't started leveraging Twitter for PowerShell , I would suggest to do the same.
Recently MVP Aleksandar Nikolic tweeted this.

clip_image001

This got me curious as to what is in this extension. Quickly went to the http://wmix.codeplex.com/ and downloaded it.
Note - This project has pre-requisite of PowerShell Proxy Extensions available at http://pspx.codeplex.com/

So One starts by installing the Proxy Extensions and then WMI Extensions.

Then go to your Elevated PowerShell Console and Import the Module. First time you do this it tells you that this is the first time this is being run and it'll generate wmifx module on fly. Choose "Yes" (default) and let it generate the wmifx module …..this takes a bit of time

clip_image002

Now this time If you search for modules starting with wmi….there appears to be a new module wmifx.

clip_image003

Quickly Import this module

clip_image004

And see all the cmdlets associated with this module.

clip_image005

Lets Measure the no of cmdlets generated from the WMI Instances in my System.

clip_image006

This looks cool…..Let's try to check if there is any help associated with these Functions (Cmdlets)

clip_image007

Now what's truly amazing is that this module can be used against a remote-computer too.

clip_image008

I think this is one of the coolest PowerShell module. Have to explore a lot of this module but this looks very promising as Kirk Munro a.k.a Poshoholic has confirmed that more is yet to come…..Fingers Crossed.


Thanks for Reading

Thanks

Deepak Singh Dhami

Deepak Singh

Wednesday, April 4, 2012

IP Address Release, Renew using PowerShell.


Hi,

This is a very common task which is nearly performed by every End-user and IT Admin and Engineers. Normally we use "IPCONFIG /Release" to release the IP-address and "IPconfig / Renew" to renew or getting a new IP Address.

In some powershell script you may need to do this ip config /release and renew task. We can use native "IPconfig" command to achieve this. But there is an another way to do the same. Using WMI.
Download the script from here :

In variable $ethernet we are querying class Win32_NetworkAdapterConfiguration and using where-Object cmdlet we are choosing those adapter which have IP Enabled and have DHCP Enabled selected in there IP Configuration

than on each adapter we are using wmi method ReleaseDHCPLease()  first and then RenewDHCPLease() .

Download the script from here: http://gallery.technet.microsoft.com/scriptcenter/Renew-IP-Adresses-Using-365f6bfa

################################
$ethernet = Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where { $_.IpEnabled -eq $true -and $_.DhcpEnabled -eq $true}  
foreach ($lan in $ethernet) {
       Write-Host "Flushing IP addresses" -ForegroundColor Yellow
       Sleep 2
       $lan.ReleaseDHCPLease() | out-Null
       Write-Host "Renewing IP Addresses" -ForegroundColor Green
       $lan.RenewDHCPLease() | out-Null
       Write-Host "The New Ip Address is "$lan.IPAddress" with Subnet "$lan.IPSubnet"" -ForegroundColor Yellow
       }
#############################################
Download the script from here: http://gallery.technet.microsoft.com/scriptcenter/Renew-IP-Adresses-Using-365f6bfa

30-03-2012 15-41-48

I hope that it may help someone.

Thanks

Aman Dhally

Tuesday, March 6, 2012

Create a hardware Inventory using PowerShell.


Hi,

The basic idea of this script to find the Parts Number and Serial Number of installed hardware. For example serial Number of Hard disk, Memory , Cd drives etc.

In my environment i want that this script should reside on Users Laptop/desktop. and create a batch file to call this powershell script.

The output of this script is in HTML and if you provides the details of your Exchange Server it can also send you the generated html files to the specified email id with attachment.

You can download the script from here: http://gallery.technet.microsoft.com/scriptcenter/Hardware-Inventory-Using-fe6611e0

Screenshot:

ScreenShot 

Thanks
Aman Dhally







Tuesday, February 28, 2012

List of useful WMI classes to use with PowerShell.

 

Hi,

Here is the list of some useful WMI Classes :).

ClassName

Contains

win32_ComputerSystemProduct

Serial Number, Vendor, information

win32_bios

Bios Information , including Version Number of BIOS

win32_battery

Battery Information

win32_Physicalmemory

Serial Number, Capacity, Part Number of Installed Memory Stick.

win32_DiskDrive

Capacity, Serial Number of Drive and other info of the Hard-disk

win32_DesktopMonitor

Monitor Information including Resolutions

win32_cdromdrive

Information Related Cd Drive

win32_networkadapter

Network Adaptor information contains, manufacturer, MAC ID etc

win32_pointingdevice

Mouse related information

win32_operatingsystem

OS Name, OSArchitecture, Version Info

win32_logicalDisk

DeviceID, Free Space, Size of Partition,

Win32_NetworkConnection

Mapped Network Drives

win32_printer

List of Installed Pri ters

win32_PrinterdRIVER

List of Printer Drivers

Win32_NetworkAdapterConfiguration

IP Adress, DHCP , DNS and other information of Network Drivers.

win32_startupCommand

List of Software which are on STARTUP folders

win32_process

All Running Processes

win32_Service

List of All Services

win32_Product

List of Installed Software

 

Thanks

aman dhally

Monday, January 9, 2012

Removing Shares (Remotely, Too) using PowerShell

 

PowerTip of the Day, from PowerShell.com:

 

Removing Shares (Remotely, Too)

In a previous tip you learned how you can create ad-hoc shares using WMI. These shares persist until you remove them again. So if you'd like to clean up behind you, here is a one-liner that removes a share locally or remote:

PS> ([wmi]'\\Storage1\root\cimv2:Win32_Share="Hidden"').Delete()

Just replace "Hidden" with the name of the share you want to delete, and replace "storage1" with the name or IP address of the target system. If you want to delete a share on your local system, remove the server name altogether:

PS> ([wmi]'root\cimv2:Win32_Share="Hidden"').Delete()

 

Thanks

Friday, December 2, 2011

Change Service Start Mode using PowerShell

 

PowerTip of the Day, from PowerShell.com:

 

You can use WMI like this if you want to change a service start mode:

([wmi]'Win32_Service.Name="Spooler"').ChangeStartMode('Automatic').ReturnValue
([wmi]'Win32_Service.Name="Spooler"').ChangeStartMode('Manual').ReturnValue
 
Note that a return value of 0 indicates success. 
You will need Administrator privileges to change the start mode.
Thanks to www.powershell.com

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