Author Posts

April 25, 2017 at 10:41 am

I am a new learner for powershell , and I run into one problem , I run this command get-process |gm , and I find that in the member list , we have event , method , scriptsproperty ,propertyset ,anyone can help to share with some examples for them ? how to use them ?also how to read the definition .

Disposed Event System.EventHandler Disposed(System.Object, System.EventArgs)
ErrorDataReceived Event System.Diagnostics.DataReceivedEventHandler ErrorDataReceived(System.Objec..
Exited Event System.EventHandler Exited(System.Object, System.EventArgs)
OutputDataReceived Event System.Diagnostics.DataReceivedEventHandler OutputDataReceived(System.Obje..
BeginErrorReadLine Method void BeginErrorReadLine()
BeginOutputReadLine Method void BeginOutputReadLine()
CancelErrorRead Method void CancelErrorRead()
CancelOutputRead Method void CancelOutputRead()
Close Method void Close()
CloseMainWindow Method bool CloseMainWindow()
CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
Dispose Method void Dispose(), void IDisposable.Dispose()
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetType Method type GetType()
InitializeLifetimeService Method System.Object InitializeLifetimeService()
Kill Method void Kill()
Refresh Method void Refresh()
Start Method bool Start()
ToString Method string ToString()
WaitForExit Method bool WaitForExit(int milliseconds), void WaitForExit()

ration PropertySet PSConfiguration {Name, Id, PriorityClass, FileVersion}
es PropertySet PSResources {Name, Id, Handlecount, WorkingSet, NonPagedMemorySize, PagedM...
ScriptProperty System.Object Company {get=$this.Mainmodule.FileVersionInfo.CompanyName;}
ScriptProperty System.Object CPU {get=$this.TotalProcessorTime.TotalSeconds;}
on ScriptProperty System.Object Description {get=$this.Mainmodule.FileVersionInfo.FileDescri...
on ScriptProperty System.Object FileVersion {get=$this.Mainmodule.FileVersionInfo.FileVersion;}
ScriptProperty System.Object Path {get=$this.Mainmodule.FileName;}
ScriptProperty System.Object Product {get=$this.Mainmodule.FileVersionInfo.ProductName;}
rsion ScriptProperty System.Object ProductVersion {get=$this.Mainmodule.FileVersionInfo.Product...

April 25, 2017 at 1:07 pm

Moving to correct forum.

April 25, 2017 at 1:22 pm

Hi April,

I can suggest this free learning video from some great guys. If you are new to Powershell, the can help you to get the basics.

https://mva.microsoft.com/en-US/training-courses/getting-started-with-microsoft-powershell-8276

goodluck,
Albert

April 26, 2017 at 1:47 am

thanks so much ,Albert , indeed ,i was learning powershell from the MS virtual academy ,hence i am confused by 'get-member'.

April 26, 2017 at 1:48 am

Adam , this is not correct forum for powershell question ?

April 26, 2017 at 6:00 am

An couple of short examples:

I am using Get-process as example.
Get-Process | Get-Member

To use the Kill Method

(Get-Process -Name notepad).Kill()
(Get-Process -Name notepad).WaitForExit()

The Kill would have the same effect as the Stop-Process Cmdlet
And the waitForExit the same as Wait-process Cmdlet

To get just one Property or Script property you could use some what the some wat the approach only without the last () with are only for an Method.

(Get-Process).name
(Get-Process).Description

Also the Book 'PowerShell in an month of lunches' is a great book for learning all the basic of PowerShell.

April 27, 2017 at 2:04 am

thanks so much , i just tried other method and property by following yours , it is very useful . i want to learn how to read those definition .

for example , we have event here , how to read this and use it ?

April 27, 2017 at 2:06 am


Disposed                   Event          System.EventHandler Disposed(System.Object, System.EventArgs)
Exited                     Event          System.EventHandler Exited(System.Object, System.EventArgs)