Monthly Archives: February 2014

PowerShell – Get Current User of Remote PC

Did you ever need to know who is currently logged on on a Remote PC? Today I wrote a little Script which can answer this question.

function Get-CurrentLoggedOnUser
{
Param([parameter(Mandatory=$true)][alias("Computer")]$ComputerName)

#Get Computer Information from specified Computer
$ComputerInfo = Get-WmiObject Win32_ComputerSystem -Computer $ComputerName
$ComputerInfo.UserName
}

When you run this function it will return a result like this:

intranet\theezitguy

Now you know who is logged on on a Remote PC. Simple and easy. As always you can download my Script from here.

Sources:

http://www.computerperformance.co.uk/powershell/powershell_wmi_file.htm

Advertisements
Tagged

Clone Virtual Machine – Linux (debian) – eth0 missing

Today I found a solution for a problem which was bugging me for a while now.  (I encountered this error when I tried to clone my WanEm virtual machine.)

If you clone a virtual machine (created via Hyper-V, Virtualbox, VMWare, …) which is using Linux as an operating system you will notice that the cloned machine is missing the eth0 network interface. That´s strange because you added a network adapter during it´s creation.

If you run the following command in the terminal:

ifconfig eth0 up

You will receive the following error message:

eth0: ERROR while getting interface flags: No such device

So what could have gone wrong? The answer is quite simple: You added a new network adapter with a different MAC address and Linux was not able to detect this change. What can you do to solve this problem? The solution is also quite simple.

Here it is:

Run the following commands:


sudo rm /etc/udev/rules.d/z25-persistent-net.rules
sudo reboot

After the operating system successfully rebooted your problem will be solved.

If you now run

ifconfig -a

you will see that there is an eth0 interface now.

Sources:

http://fl3x.us/blog/2013/08/30/eth0-error-while-getting-interface-flags-no-such-device/

http://chris.dziemborowicz.com/blog/2010/07/25/fix-missing-eth0-when-cloning-ubuntu-vmware-virtual-machines/

http://lostechies.com/derickbailey/2009/06/20/cloning-or-converting-linux-vm-from-vmware-workstation-to-esx-server-eth0-gone-eth1-available/

Tagged , ,

PowerShell – Get Default Browser from Remote PC

Did you ever need to know what the Default Browser of a remote computer was? I did. Today I´m going to show you how you can do this using PowerShell and the Microsoft Windows Registry. Here is the Script:


Param([parameter(Mandatory=$true)][alias("Computer")]$ComputerName)

$Registry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $ComputerName)
$RegistryKey = $Registry.OpenSubKey("SOFTWARE\\Classes\\http\\shell\\open\\command")
#Get (Default) Value
$Value = $RegistryKey.GetValue("")

$Value

The above Script will return a String like:

C:\Program Files\Internet Explorer\iexplore.exe" %1

As you can see the Default Browser of my computer is Internet Explorer.

Here the above Script packaged as a function ready to use:

function Get-DefaultBrowser
{
Param([parameter(Mandatory=$true)][alias("Computer")]$ComputerName)

$Registry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $ComputerName)
$RegistryKey = $Registry.OpenSubKey("SOFTWARE\\Classes\\http\\shell\\open\\command")
#Get (Default) Value
$Value = $RegistryKey.GetValue("")

return $Value
}

As always you can download my Script here.

Sources:

http://www.ehow.com/how_6325458_configure-browser-using-regedit-xp.html

http://msdn.microsoft.com/en-us/library/ctb3kd86(v=vs.110).aspx

http://serverfault.com/questions/270053/how-to-set-firefox-as-default-browser-using-a-script

http://www.culham.net/2013/powershell/remotely-accessing-the-registry-using-windows-powershell

Tagged