Datasheet
UNDERSTAND THE COMPONENTS 13
Getting Started with
Windows PowerShell
Basics
PART 1
...
TimerService Property Microsoft.Share...
TraceSessionGuid Property System.Guid Tra...
TypeName Property System.String T...
UpgradeContext Property Microsoft.Share...
UpgradedPersiste... Property System.Collecti...
Version Property System.Int64 Ve...
e
Get-Member
cmdlet takes in any object and outputs information about the
object’s public methods and properties. is means that you have a fully fea-
tured, real-time compiler that allows you to manipulate virtually any object in a
SharePoint Farm, and you have convenient, easy-to-use cmdlets that provide quick
access to those objects!
But what if there’s no cmdlet that provides access to what you need? No problem—you
can still get to any .NET object indirectly by accessing the object via a container (for
example, retrieve an
SPList
object using the
SPWeb
object, which can be retrieved
using the
Get-SPWeb
cmdlet), directly by loading the object’s assembly and creating
a new instance of the object, or by using a static method or property. e following
example demonstrates this by retrieving the
SPFarm
object directly rather than via
the
Get-SPFarm
cmdlet:
PS C:\> [System.Reflection.Assembly]::i
LoadWithPartialName(“Microsoft.SharePoint”)
GAC Version Location
--- ------- --------
True v2.0.50727 C:\Windows\assembly\GAC_MSIL\Mic...
PS C:\> $farm = i
[Microsoft.SharePoint.Administration.SPFarm]::Local
is code performs a one-time, in-memory load of the
Microsoft.SharePoint
assembly using the static
LoadWithPartialName
method of the
System
.Reflection.Assembly
class. It then calls the
SPFarm
’s static
Local
property to
retrieve an instance of the
SPFarm
object. e SharePoint assembly is automatically
loaded when the snap-in is registered, but you can load just this one assembly indi-
vidually rather than with the snap-in, if desired. Typically, you won’t do this with
SharePoint 2010, but if you’re still working with SharePoint 2007, this approach is
your only option.
c01.indd 13c01.indd 13 5/16/2011 11:12:31 AM5/16/2011 11:12:31 AM