PowerShell in the format
1. objects in PowerShell
There is a vivid example--"bulb". The object is obvious, it is a light bulb. The properties of a light bulb may include its color, power and type (fluorescent, incandescent or halogen lamps). For its operation, or as a method, it is the behavior we can perform, such as opening and closing. It's easy to understand!
View properties and methods of Get-service
use the parameters of "Get-member" to view all attribute class objects of "Get-service", or method class objects
Property
PS c:\users\administrator> Get-service | Get-member-membertype Property
TypeName:System.ServiceProcess.ServiceController
Name MemberType Definition
---- ---------- ----------
CanPauseAndContinue Property System.Boolean canpauseandcontinue {get;}
CanShutdown property System.booleancanshutdown {get;}
CanStop property System.Boolean Canstop{get;}
Container Property System.ComponentModel.IContainer Container {g ...
Dependentservices Property System.serviceprocess.servicecontroller[]dep ...
DisplayName property System.stringdisplayname {get;set;}
MachineName Property System.stringmachinename {Get;set;}
Servicehandle Property System.Runtime.InteropServices.SafeHandle Ser ...
ServiceName property System.stringservicename {get;set;}
Servicesdependedon Property system.serviceprocess.servicecontroller[] Ser ...
ServiceType Property System.ServiceProcess.ServiceType servicetype ...
Site Property System.ComponentModel.ISite site {get;set;}
Status Property System.ServiceProcess.ServiceControllerStatus ...
B. Methods
PS c:\users\administrator> Get-service |get-member-membertype method
TypeName:System.ServiceProcess.ServiceController
Name MemberType Definition
---- ---------- ----------
Close Method system.void Close ()
Continue Method system.void Continue ()
Createobjref Method System.Runtime.Remoting.ObjRef createob ...
Dispose Method system.void Dispose ()
equals Method bool Equals (System.Object obj)
ExecuteCommand Method system.void executecommand (int command)
GetHashCode Method int GetHashCode ()
Getlifetimeservice Method System.Object Getlifetimeservice ()
GetType Method type GetType ()
InitializeLifetimeService Method System.Object InitializeLifetimeService ()
Pause Method system.void Pause ()
Refresh Method system.void Refresh ()
Start Method system.void start (), System.Void start (...
Stop Method system.void Stop ()
ToString Method String ToString ()
WaitForStatus Method system.void waitforstatus (System.servic.
2. format in PowerShell
PowerShell formatted output in:
Get-command format-* <enter>
The result is:
650) this.width=650; "title=" 11.png "alt=" wkiol1u7qiyxzdytaagfuwajrwi720.jpg "src=" http://s3.51cto.com/wyfs02/M01/ 6b/f3/wkiol1u7qiyxzdytaagfuwajrwi720.jpg "/>
More examples:
Get-childitem C:\Windows | Format-table<enter>
Get-childitem C:\Windows | Format-table-autosize <enter>
Get-childitem C:\Windows | Format-custom<enter>
Get-childitem C:\Windows | Format-list<enter>
Get-childitem C:\Windows | Format-list-property FullName <enter>
Get-childitem C:\Windows | Format-wide<enter>
Example: (remember pipe character):
Get-childitem C:\Windows-Recurse | Format-list-property fullname,creationtime,lastwritetime<enter>
Get-childitem C: | Format-wide-column 3<enter>
get-process | Group-object company <enter>
Get-eventlog System | Group-objecteventid<enter>
Get-eventlog System | Group-object eventid| Sort-object count-descending<enter>
get-process | Convertto-html<enter>
get-process | convertto-html | Out-file "Processes.html" <enter>
get-process | Export-csv Processes.csv <enter>
As for opening the file, use the following command:
Invoke-item processes.html<enter>
Invoke-item processes.csv<enter>
Check it out (the output is ". CSV " file):
650) this.width=650; "title=" 22.png "alt=" wkiol1u7qxhztu_daakjoh6zx4w701.jpg "src=" http://s3.51cto.com/wyfs02/M02/ 6b/f3/wkiol1u7qxhztu_daakjoh6zx4w701.jpg "/>
Use "Invoke-item" command to open:
Invoke-item Processes.csv <Enter>
650) this.width=650; "title=" 33.png "alt=" wkiom1u7qczyz06qaaaq4syt_-y431.jpg "src=" http://s3.51cto.com/wyfs02/M02/ 6b/f7/wkiom1u7qczyz06qaaaq4syt_-y431.jpg "/>
3. Common parameters in PowerShell
The following list lists "Common parameters" (the names of these parameters are not available for customization):
-confirm in the execution cmdlets before prompting the user.
-debug provides relevant debugging information.
-erroraction Tips cmdlets errors that may occur when you perform an operation. Such as: Continue, stop and so on.
-errorvariable use a specific variable ($error) to save the error message.
-outvariable the variable used to hold the output information.
-outbuffer determines the number of objects that need to be cached before the next pipeline pass.
-verbose Give us more details.
-whatif does not really perform cmdlets , just to tell you what will happen.
-"tab" Key, used to complete the command.
Show Help:
Get-service-<tab>
or use the help command "Get-help" :
Get-help Get-service-full <Enter>
Instance:
Set-executionpolicy unrestricted-whatif<enter>
650) this.width=650; "title=" 44.png "alt=" wkiom1u7qffbq_raaaddhz2tvds134.jpg "src=" http://s3.51cto.com/wyfs02/M02/ 6b/f7/wkiom1u7qffbq_raaaddhz2tvds134.jpg "/>
Set-executionpolicy unrestricted-confirm<enter>
650) this.width=650; "title=" 55.png "alt=" wkiol1u7qcoh2m__aaffrbu5zbg875.jpg "src=" http://s3.51cto.com/wyfs02/M00/ 6b/f3/wkiol1u7qcoh2m__aaffrbu5zbg875.jpg "/>
Yes, it will return a validation operation to obtain further permission from the user. Just "Y","A","N","L" and "?" we can all easily understand, then "S" has the following functions:
650) this.width=650; "title=" 66.png "alt=" wkiom1u7qgyckc3taajuridkd2i277.jpg "src=" http://s3.51cto.com/wyfs02/M00/ 6b/f7/wkiom1u7qgyckc3taajuridkd2i277.jpg "/>
Reference documents:
http://marui.blog.51cto.com/1034148/290535
This article comes from the "Ricky's blog" blog, please be sure to keep this source http://57388.blog.51cto.com/47388/1638388
6.PowerShell--objects, formats and parameters