Tuesday, March 23, 2010

Powershell: Find Process User name without using WMI

function get-ProcUser ([System.String] $procname)
    if (!$procname) {return "Provide some process name"}
    $proclist=get-process $procname.trim() -ErrorAction silentlycontinue
    if(!$proclist -and ($procname.contains("."))){
        $proclist=get-process $procname.split(".")[0].trim() -ErrorAction silentlycontinue
    if(!$proclist) {return "Provide some proper process name"}

    foreach($proc in $proclist)
        $procprop=tasklist /V /FO List /FI ("PID eq "+$proc.id)
        foreach ($field in $procprop)
               if ($field -match "user name")

I have tried to handle the minimal errors here. You can add more if you wish.

Parameter can be made to pass id also, but that won’t be too useful.

Error handling is in small fonts.

Checked only on Windows 7 RTM x64. ErrorAction may not be valid on V1.

Tried hard on C#, but could not find any options.

Versions of Installed applications

gwmi -query "Select name,version from Win32_Product" | format-table name,version


PS is running as administrator.

Monday, March 8, 2010

UPS Assisted home network settings

UPS assisted home net setupFacts

  • Power goes down frequently. It is India.
  • In a 3 BHK flat, network cable from DSL company, Airtel, is coming into a corner room.
  • I own a PC which needs UPS backup, but my flatmates own laptop and need to share this connection.
  • Airtel wireless router is not so cheap.


Create above configuration using the following

  • Two 10 meters network Ethernet cables.
  • A UPS that can support network load for extended period. In this case, it is Back-UPS ES 650Y-IN from APC, which gives me enough backup to keep router+modem running for around 2 hours at least.
  • A simple electrical wire of 10 meters with a male and a female sockets on either side.
  • A Power-strip.
  • A DSL modem & and a wi-fi enabled router. Wi-Fi enabled router in this case is from Linksys and Modem is provided by Airtel.


  • Connect Modem to UPS through Power strip.
  • Keep Wi-Fi router in drawing room where from every part of flat can receive good signal.
  • Attach Wi-Fi power plug to female part of electrical wire and extend that wire to power strip kept near UPS.
  • Now take out Ethernet output of Modem using one of 10 meter NW cables to Wi-Fi router’s input.
  • Use one 10 meter NW cable from Router’s output to bring network to PC which is attached to UPS directly.
  • Use steps in the post, Linksys wireless router setup with Airtel broadband, to setup Router.
  • Above Green connectors are NW cables and red ones shows power lines to UPS.


  • Avoid running PC during power outage as this draws power fast and irritates due to warning sound.