Archive

Archive for the ‘Know your Shell’ Category

Check and terminate process on remote machine using wmi

September 24, 2009 Leave a comment

WMI is a wonderful tool for remote administration!!!

Today in this post, I will demonstrate on how to query and terminate processes in remote machine using wmi command line utility (wmic). Ofcourse, you need have administrator rights on remote machine to run these command(may be a domain admin account is a right choice here).

In all these below examples, “myremote” is my remote machine name against which I am performing these operations.

To query all processes in remote machine use below command..

wmic /node:myremote process

To query a specific process(outlook.exe) in remote machine…

wmic /node:myremote process where name="outlook.exe"

If you are not sure of exact process name but know only few letters of it, then use this…

wmic /node:myremote process where "name like '%outlo%'" get name

To terminate(kill) a process…

wmic /node:myremote process where name="outlook.exe"  call terminate

To query the owner of a process…

wmic /node:myremote process where name="outlook.exe"  call getowner

Enough for today.. :-) I will post more command lines when I get some time…

If you want a command for any specific requirement, please leave a note below in comments section. I will get back to you ASAP.

Happy Learning..,
Sitaram Pamarthi

Categories: Know your Shell, Tips

Find disk space of remote machine with powershell script

August 4, 2009 1 comment

I  wrote a enhanced function to get the disk space. You can find it at http://techibee.com/powershell/check-disk-space-of-remote-machine-using-powershell/430

Subject says it all. This code helps you to findout the disk space of remote machine.

Code(save it into a file with ps1 extension):

$hostname=Read-host "Enter the computer name"
get-wmiobject -computer $hostname win32_logicaldisk -filter "drivetype=3" | ForEach-Object { Write-Host  Device name : $_.deviceid; write-host Total space : ($_.size/1GB).tostring("0.00")GB; write-host Free Spce : ($_.freespace/1GB).tostring("0.00")GB }

Output

PS C:temp> .CheckSpace.ps1
Enter the computer name: MyRemotePCDevice name : C: Total space : 232.75 GBFree Spce : 130.51 GBPS C:temp>

Quick way to find hotfix installation status

I know there are varioud menthods for finding the hotfix installation status, but I felt this as very easy one.

To find the hotfix installation status on local machine:

wmic qfe where hotfixid=”KB958644″ list full

To find on a remote machine:

wmic /node: qfe where hotfixid=”KB958644″ list full

To find on list of machines:

o Place all machines into a text file(machine.txt)
o Run the below batch file

=== File name: get-hotfix-status.bat ===

echo off
for /f “tokens=* delims= ” %a in (test.txt) do wmic/Node:%a qfe where hotfixid=”KB958644″ list full

=== End of file ===

Please comment if you know any better way.

Happy Learning,
Sitaram Pamarthi,

Categories: Know your Shell, Scripting