[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualBasic")
$myComputer = new-object Microsoft.VisualBasic.Devices.computer
this give you acces to the following :
Audio : Microsoft.VisualBasic.Devices.Audio
Clipboard : Microsoft.VisualBasic.MyServices.ClipboardProxy
Ports : Microsoft.VisualBasic.Devices.Ports
Mouse : Microsoft.VisualBasic.Devices.Mouse
Keyboard : Microsoft.VisualBasic.Devices.Keyboard
Screen : Screen[Bounds={X=0,Y=0,Width=1280,Height=1024} WorkingArea={X=0,Y=
0,Width=1280,Height=960} Primary=True DeviceName=\\.\DISPLAY2 ?
O?????? ??☺ ?
Clock : Microsoft.VisualBasic.Devices.Clock
FileSystem : Microsoft.VisualBasic.MyServices.FileSystemProxy
Info : Microsoft.VisualBasic.Devices.ComputerInfo
Network : Microsoft.VisualBasic.Devices.Network
Name : computername
Registry : Microsoft.VisualBasic.MyServices.RegistryProxy
so now you can do !
$mycomputer.audio.play("C:\WINDOWS\Media\tada.wav")
$mycomputer.info
MSH C:\> $mycomputer.info
TotalPhysicalMemory : 2145816576
AvailablePhysicalMemory : 1505857536
TotalVirtualMemory : 2147352576
AvailableVirtualMemory : 1913438208
InstalledUICulture : en-US
OSFullName : Microsoft Windows XP Professional
OSPlatform : Win32NT
OSVersion : 5.1.2600.131072
MSH C:\> $mycomputer.network.isAvailable
True
$MyComputer.network.ping("localhost")
True
not so nice :
MSH C:\> $MyComputer.network.ping("foo")
Exception calling "Ping" with "1" argument(s): "An exception occurred during a
Ping request.".
At line:1 char:25
MSH C:\> $mycomputer.clock
LocalTime GmtTime TickCount
--------- ------- ---------
10/22/2005 8:04:33 PM 10/22/2005 6:04:33 PM 423435437
also .NET has another path as MSH !!!
MSH C:\> $mycomputer.filesystem.CurrentDirectory
C:\Documents and Settings\mow
MSH C:\> $mycomputer.filesystem.SpecialDirectories
MSH C:\> $mycomputer.mouse
ButtonsSwapped WheelExists WheelScrollLines
-------------- ----------- ----------------
False True 3
you can also get the user object but that does not seem to work.
$me = new-object Microsoft.VisualBasic.ApplicationServices.user
MSH C:\> $me.InitializeWithWindowsUser()
MSH C:\> $me
Name CurrentPrincipal IsAuthenticated
---- ---------------- ---------------
System.Security.Princip... False
MSH C:\> [system.threading.thread]::currentPrincipal
realy not so nice :
MSH C:\> $mycomputer.clipboard.setText("hello Clip")
Exception calling "SetText" with "1" argument(s): "Current thread must set to s
ingle thread apartment (STA) mode before OLE calls can be made. Ensure that you
r Main function has STAThreadAttribute marked on it.".
At line:1 char:30
+ $mycomputer.clipboard.setText( <<<< "hello Clip")
Identity
--------
System.Security.Principal.GenericIdentity
looks like we have no indentity in MSH
but there is alot to play again ;-)
October 2005 November 2005 December 2005 January 2006 February 2006 March 2006 April 2006 May 2006 June 2006 July 2006 August 2006 September 2006 October 2006 November 2006 December 2006