Sunday, March 27, 2016

PowerShell v3 PowerShell And Its World

,
Okay, weird title, again, I know. In the past few weeks I have really seen a lot of scripts that go far past the prepackaged notion of a PowerShell instance into the mechanics of the  [PowerShell] object. Im just using the type accelerator here, but, underneath, the full type is  System.Management.Automation.PowerShell. As shown below, the  [PowerShell]  type accelator is the same thing as the full name.
PS>[PowerShell]

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     False    PowerShell                               System.Object

PS>[System.Management.Automation.PowerShell]

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     False    PowerShell                               System.Object
So, when we work with the  [PowerShell] type accelerator, we know what we are hitting against. To get more of an idea of what lives in this namespace:
PS>[powershell].GetMembers() | ft name, membertype -AutoSize

Name                          MemberType
----                          ----------
get_Commands                      Method
set_Commands                      Method
get_Streams                       Method
get_InstanceId                    Method
get_InvocationStateInfo           Method
get_IsNested                      Method
get_HadErrors                     Method
get_Runspace                      Method
set_Runspace                      Method
set_RunspacePool                  Method
get_RunspacePool                  Method
get_HistoryString                 Method
set_HistoryString                 Method
Create                            Method
Create                            Method
Create                            Method
CreateNestedPowerShell            Method
AddCommand                        Method
AddCommand                        Method
AddScript                         Method
AddScript                         Method
AddCommand                        Method
AddParameter                      Method
AddParameter                      Method
AddParameters                     Method
AddParameters                     Method
AddArgument                       Method
AddStatement                      Method
add_InvocationStateChanged        Method
remove_InvocationStateChanged     Method
Connect                           Method
ConnectAsync                      Method
Invoke                            Method
Invoke                            Method
Invoke                            Method
Invoke                            Method
Invoke                            Method
Invoke                            Method
Invoke                            Method
Invoke                            Method
Invoke                            Method
BeginInvoke                       Method
BeginInvoke                       Method
BeginInvoke                       Method
BeginInvoke                       Method
BeginInvoke                       Method
EndInvoke                         Method
Stop                              Method
BeginStop                         Method
EndStop                           Method
Dispose                           Method
AsJobProxy                        Method
ToString                          Method
Equals                            Method
GetHashCode                       Method
GetType                           Method
Commands                        Property
Streams                         Property
InstanceId                      Property
InvocationStateInfo             Property
IsNested                        Property
HadErrors                       Property
Runspace                        Property
RunspacePool                    Property
HistoryString                   Property
InvocationStateChanged             Event
Quite a few things live in here. Eliminating duplicates shows this narrowed down list:
[powershell].GetMembers() | select name, membertype -Unique | ft -AutoSize
Name                          MemberType
----                          ----------
get_Commands                      Method
set_Commands                      Method
get_Streams                       Method
get_InstanceId                    Method
get_InvocationStateInfo           Method
get_IsNested                      Method
get_HadErrors                     Method
get_Runspace                      Method
set_Runspace                      Method
set_RunspacePool                  Method
get_RunspacePool                  Method
get_HistoryString                 Method
set_HistoryString                 Method
Create                            Method
CreateNestedPowerShell            Method
AddCommand                        Method
AddScript                         Method
AddParameter                      Method
AddParameters                     Method
AddArgument                       Method
AddStatement                      Method
add_InvocationStateChanged        Method
remove_InvocationStateChanged     Method
Connect                           Method
ConnectAsync                      Method
Invoke                            Method
BeginInvoke                       Method
EndInvoke                         Method
Stop                              Method
BeginStop                         Method
EndStop                           Method
Dispose                          

0 comments to “PowerShell v3 PowerShell And Its World”

Post a Comment

 

Computer Info Copyright © 2016 -- Powered by Blogger