powershell reference


NAME
ForEach-Object

SYNOPSIS
Performs an operation against each of a set of input objects.


SYNTAX
ForEach-Object [-Process] <ScriptBlock[]> [-Begin <scriptblock>] [-End <scr
iptblock>] [-InputObject <psobject>] [<CommonParameters>]


DESCRIPTION
The ForEach-Object cmdlet performs an operation on each of a set of input o
bjects. The input objects can be piped to the cmdlet or specified by using
the InputObject parameter.

The operation to perform is described within a script block that is provide
d to the cmdlet as the value of the Process parameter. The script block can
contain any Windows PowerShell script.

Within the script block, the current input object is represented by the $_
variable.
In addition to using the script block that describes the operations to be c
arried out on each input object, you can provide two additional script bloc
ks. One, specified as the value of the Begin parameter, runs before the fir
st input object is processed. The other, specified as the value of the End
parameter, runs after the last input object is processed.

The results of the evaluation of all the script blocks, including the ones
specified with Begin and End, are passed down the pipeline.

PARAMETERS
-Begin <scriptblock>
Specifies a script block to run before processing any input objects.

-End <scriptblock>
Specifies a script block to run after processing all input objects.

-InputObject <psobject>
Accepts an object that the script block specified in the process parame
ter will act upon. Enter a variable that contains the objects, or type
a command or expression that gets the objects.

-Process <ScriptBlock[]>
Specifies the script block that is applied to each incoming object.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>30000,56798,12432 | foreach-object -process {$_/1024}

Description
-----------
This command accepts an array of integers, divides each one of them by 1024
, and displays the results.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-childitem C:\ | foreach-object -process { $_.length / 1024 }

Description
-----------
This command retrieves the files and directories in the root of the C: driv
e, and it returns and displays the size of each of them. The zeros represen
t directories in which no file size was available.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$events = get-eventlog -logname system -newest 1000

C:\PS> $events | foreach-object -begin {get-date} -process {out-file -filep
ath events.txt -append -inputobject $_.message} -end {get-date}

Description
-----------
This command retrieves the 1000 most recent events from the system log and
stores them in the $events variable. It then pipes the events to the ForEac
h-Object cmdlet. The Begin parameter displays the current date and time. Ne
xt, the Process parameter uses the Out-File cmdlet to create a text file na
med events.txt and stores the message property of each of the events in tha
t file. Last, the End parameter is used to display the date and time after
all of the processing has completed.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-itemproperty -path hkcu:\Network\* | foreach-object {set-itemprop
erty -path $_.pspath -name RemotePath -value $_.RemotePath.ToUpper();}

Description
-----------
This command changes the value of the RemotePath registry entry in all of t
he subkeys under the HKCU:\Network key to uppercase text. You can use this
format to change the form or content of a registry entry value.

Each subkey in the Network key represents a mapped network drive that will
reconnect at logon. The RemotePath entry contains the UNC path of the conne
cted drive. For example, if you map the E: drive to \\Server\Share, there w
ill be an E subkey of HKCU:\Network and the value of the RemotePath registr
y entry in the E subkey will be \\Server\Share.

The command uses the Get-ItemProperty cmdlet to get all of the subkeys of t
he Network key and the Set-ItemProperty cmdlet to change the value of the R
emotePath registry entry in each key. In the Set-ItemProperty command, the
path is the value of the PSPath property of the registry key. (This is a pr
operty of the Microsoft .NET Framework object that represents the registry
key; it is not a registry entry.) The command uses the ToUpper() method of
the RemotePath value, which is a string (REG_SZ).

Because Set-ItemProperty is changing the property of each key, the ForEach-
Object cmdlet is required to access the property.




REMARKS
To see the examples, type: "get-help ForEach-Object -examples".
For more information, type: "get-help ForEach-Object -detailed".
For technical information, type: "get-help ForEach-Object -full".

Name : %
Category : Alias
Synopsis : ForEach-Object
Component :
Role :
Functionality :

Name : ?
Category : Alias
Synopsis : Where-Object
Component :
Role :
Functionality :

Name : h
Category : Alias
Synopsis : Get-History
Component :
Role :
Functionality :

Name : r
Category : Alias
Synopsis : Invoke-History
Component :
Role :
Functionality :

A:

NAME
Add-Content

SYNOPSIS
Adds content to the specified items, such as adding words to a file.


SYNTAX
Add-Content [-LiteralPath] <string[]> [-Value] <Object[]> [-Credential <PSC
redential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <st
ring[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParamet
ers>]

Add-Content [-Path] <string[]> [-Value] <Object[]> [-Credential <PSCredenti
al>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>
] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Add-Content cmdlet appends content to a specified item or file. You can
specify the content by typing the content in the command or by specifying
an object that contains the content.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Overrides the read-only attribute, allowing you to add content to a rea
d-only file.

-Include <string[]>
Adds only the specified items. The value of this parameter qualifies th
e Path parameter. Enter a path element or pattern, such as "*.txt". Wil
dcards are permitted.

-LiteralPath <string[]>
Specifies the path to the items that receive the additional content. Un
like Path, the value of LiteralPath is used exactly as it is typed. No
characters are interpreted as wildcards. If the path includes escape ch
aracters, enclose it in single quotation marks. Single quotation marks
tell Windows PowerShell not to interpret any characters as escape seque
nces.

-PassThru [<SwitchParameter>]
Returns an object representing the added content. By default, this cmdl
et does not generate any output.

-Path <string[]>
Specifies the path to the items that receive the additional content. Wi
ldcards are permitted. If you specify multiple paths, use commas to sep
arate the paths.

-Value <Object[]>
Specifies the content to be added. Type a quoted string, such as "This
data is for internal use only", or specify an object that contains cont
ent, such as the DateTime object that Get-Date generates.

You cannot specify the contents of a file by typing its path, because t
he path is just a string, but you can use a Get-Content command to get
the content and pass it to the Value parameter.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>add-content -path *.txt -exclude help* -value "END"

Description
-----------
This command adds "END" to all text files in the current directory, except
for those with file names that begin with "help".




-------------------------- EXAMPLE 2 --------------------------

C:\PS>add-content -Path file1.log, file2.log -Value (get-date) -passthru

Description
-----------
This command adds the date to the end of the File1.log and File2.log files
and then displays the date at the command line. The command uses the Get-Da
te cmdlet to get the date, and it uses the Value parameter to pass the date
to Add-Content. The PassThru parameter passes an object representing the a
dded content through the pipeline. Because there is no other cmdlet to rece
ive the passed object, it is displayed at the command line.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>add-content -path monthly.txt -value (get-content c:\rec1\weekly.txt)

Description
-----------
This command adds the contents of the Weekly.txt file to the end of the Mon
thly.txt file. It uses the Get-Content cmdlet to get the contents of the We
ekly.txt file, and it uses the Value parameter to pass the content of weekl
y.txt to Add-Content. The parentheses ensure that the Get-Content command i
s complete before the Add-Content command begins.

You can also copy the content of Weekly.txt to a variable, such as $w, and
then use the Value parameter to pass the variable to Add-Content. In that c
ase, the command would be "add-content -path monthly.txt -value $w".




-------------------------- EXAMPLE 4 --------------------------

C:\PS>add-content -value (get-content test.log) -path C:\tests\test134\logs
\test134.log

Description
-----------
This command creates a new directory and file and copies the content of an
existing file to the newly created file.

This command uses the Add-Content cmdlet to add the content. The value of t
he Value parameter is a Get-Content command that gets content from an exist
ing file, Test.log.

The value of the path parameter is a path that does not exist when the comm
and runs. In this example, only the C:\Tests directories exist. The command
creates the remaining directories and the Test134.log file.

The Force parameter is not required for this command. Add-Content creates d
irectories to complete a path even without the Force parameter.




REMARKS
To see the examples, type: "get-help Add-Content -examples".
For more information, type: "get-help Add-Content -detailed".
For technical information, type: "get-help Add-Content -full".

NAME
Add-Computer

SYNOPSIS
Add the local computer to a domain or workgroup.


SYNTAX
Add-Computer [-DomainName] <string> [-Credential <PSCredential>] [-OUPath <
string>] [-Server <string>] [-Unsecure] [-PassThru] [-Confirm] [-WhatIf] [<
CommonParameters>]

Add-Computer [-WorkGroupName] <string> [-Credential <PSCredential>] [-PassT
hru] [-Confirm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Add-Computer cmdlet adds the local computer to a domain or workgroup, o
r moves it from one domain to another. It also creates a domain account if
the computer is added to the domain without an account.

You can use the parameters of this cmdlet to specify an organizational unit
(OU) and domain controller or to perform an unsecure join.

To get the results of the command, use the Verbose and PassThru parameters.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

-DomainName <string>
Specifies a domain for the computer account. This parameter is required
.

-OUPath <string>
Specifies an organizational unit (OU) for the domain account. Enter the
full distinguished name of the OU. The default value is the default O
U for machine objects in the domain.

-PassThru [<SwitchParameter>]
Returns the results of the command. By default, this cmdlet does not ge
nerate any output.

-Server <string>
Specifies the name of a domain controller that adds the computer to the
domain. Enter the name in DomainName\ComputerName format. The default
is the local computer.

-Unsecure [<SwitchParameter>]
Performs an unsecure join.

-WorkGroupName <string>
Specifies the name of a work group for the computer. If you omit this p
arameter, the computer is joined to a domain.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>add-computer -domainname Domain01; restart-computer

Description
-----------
These commands add the local computer to the Domain01 domain using the cred
entials of the current user.

The first command adds the computer to the domain. The second command uses
the Restart-Computer cmdlet to restart the computer, which completes the jo
in operation. The semi-colon (;) separates the two commands.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>add-computer -workgroupname WORKGROUP-A

Description
-----------
This command adds the local computer to the Workgroup-A workgroup.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>add-computer -DomainName Domain01 -Server Domain01\DC01 -passthru -ve
rbose

Description
-----------
This command adds the local computer to the Domain01 domain by using the Do
main01\DC01 domain controller.

The command uses the PassThru and Verbose parameters to get detailed inform
ation about the results of the command.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>Add-Computer -domainname Domain02 -OUPath OU=testOU,DC=domain,DC=Doma
in,DC=com

Description
-----------
This command adds the Server01 and Server02 computers to the Domain02 domai
n. It uses the OUPath command to specify the organization unit for the new
accounts.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>Add-Computer -domainname Domain02 -cred Domain02\Admin02 -passthru

Description
-----------
This command adds the local computer to the Domain02 domain by using the cr
edentials of a domain administrator. The command uses the PassThru paramete
r to generate a brief report about the results of the command.




REMARKS
To see the examples, type: "get-help Add-Computer -examples".
For more information, type: "get-help Add-Computer -detailed".
For technical information, type: "get-help Add-Computer -full".

NAME
Add-Content

SYNOPSIS
Adds content to the specified items, such as adding words to a file.


SYNTAX
Add-Content [-LiteralPath] <string[]> [-Value] <Object[]> [-Credential <PSC
redential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <st
ring[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParamet
ers>]

Add-Content [-Path] <string[]> [-Value] <Object[]> [-Credential <PSCredenti
al>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>
] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Add-Content cmdlet appends content to a specified item or file. You can
specify the content by typing the content in the command or by specifying
an object that contains the content.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Overrides the read-only attribute, allowing you to add content to a rea
d-only file.

-Include <string[]>
Adds only the specified items. The value of this parameter qualifies th
e Path parameter. Enter a path element or pattern, such as "*.txt". Wil
dcards are permitted.

-LiteralPath <string[]>
Specifies the path to the items that receive the additional content. Un
like Path, the value of LiteralPath is used exactly as it is typed. No
characters are interpreted as wildcards. If the path includes escape ch
aracters, enclose it in single quotation marks. Single quotation marks
tell Windows PowerShell not to interpret any characters as escape seque
nces.

-PassThru [<SwitchParameter>]
Returns an object representing the added content. By default, this cmdl
et does not generate any output.

-Path <string[]>
Specifies the path to the items that receive the additional content. Wi
ldcards are permitted. If you specify multiple paths, use commas to sep
arate the paths.

-Value <Object[]>
Specifies the content to be added. Type a quoted string, such as "This
data is for internal use only", or specify an object that contains cont
ent, such as the DateTime object that Get-Date generates.

You cannot specify the contents of a file by typing its path, because t
he path is just a string, but you can use a Get-Content command to get
the content and pass it to the Value parameter.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>add-content -path *.txt -exclude help* -value "END"

Description
-----------
This command adds "END" to all text files in the current directory, except
for those with file names that begin with "help".




-------------------------- EXAMPLE 2 --------------------------

C:\PS>add-content -Path file1.log, file2.log -Value (get-date) -passthru

Description
-----------
This command adds the date to the end of the File1.log and File2.log files
and then displays the date at the command line. The command uses the Get-Da
te cmdlet to get the date, and it uses the Value parameter to pass the date
to Add-Content. The PassThru parameter passes an object representing the a
dded content through the pipeline. Because there is no other cmdlet to rece
ive the passed object, it is displayed at the command line.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>add-content -path monthly.txt -value (get-content c:\rec1\weekly.txt)

Description
-----------
This command adds the contents of the Weekly.txt file to the end of the Mon
thly.txt file. It uses the Get-Content cmdlet to get the contents of the We
ekly.txt file, and it uses the Value parameter to pass the content of weekl
y.txt to Add-Content. The parentheses ensure that the Get-Content command i
s complete before the Add-Content command begins.

You can also copy the content of Weekly.txt to a variable, such as $w, and
then use the Value parameter to pass the variable to Add-Content. In that c
ase, the command would be "add-content -path monthly.txt -value $w".




-------------------------- EXAMPLE 4 --------------------------

C:\PS>add-content -value (get-content test.log) -path C:\tests\test134\logs
\test134.log

Description
-----------
This command creates a new directory and file and copies the content of an
existing file to the newly created file.

This command uses the Add-Content cmdlet to add the content. The value of t
he Value parameter is a Get-Content command that gets content from an exist
ing file, Test.log.

The value of the path parameter is a path that does not exist when the comm
and runs. In this example, only the C:\Tests directories exist. The command
creates the remaining directories and the Test134.log file.

The Force parameter is not required for this command. Add-Content creates d
irectories to complete a path even without the Force parameter.




REMARKS
To see the examples, type: "get-help Add-Content -examples".
For more information, type: "get-help Add-Content -detailed".
For technical information, type: "get-help Add-Content -full".

NAME
Add-History

SYNOPSIS
Appends entries to the session history.


SYNTAX
Add-History [[-InputObject] <PSObject[]>] [-PassThru] [<CommonParameters>]


DESCRIPTION
The Add-History cmdlet adds entries to the end of the session history, that
is, the list of commands entered during the current session.

You can use the Get-History cmdlet to get the commands and pass them to Add
-History, or you can export the commands to a CSV or XML file, then import
the commands, and pass the imported file to Add-History. You can use this c
mdlet to add specific commands to the history or to create a single history
file that includes commands from more than one session.

PARAMETERS
-InputObject <PSObject[]>
Adds the specified HistoryInfo object to the session history. You can u
se this parameter to submit a HistoryInfo object from Get-History, Impo
rt-Clixml, or Import-Csv to Add-History.

-PassThru [<SwitchParameter>]
Returns a history object for each history entry. By default, this cmdle
t does not generate any output.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-history | export-csv c:\testing\history.csv

C:\PS>import-csv history.csv | add-history

Description
-----------
These commands add the commands typed in one Windows PowerShell session to
the history of a different Windows PowerShell session. The first command ge
ts objects representing the commands in the history and exports them to the
History.csv file. The second command is typed at the command line of a dif
ferent session. It uses the Import-Csv cmdlet to import the objects in the
History.csv file. The pipeline operator passes the objects to the Add-Histo
ry cmdlet, which adds the objects representing the commands in the History.
csv file to the current session history.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>import-clixml c:\temp\history.xml | add-history -passthru | foreach-o
bject {invoke-history}

Description
-----------
This command imports commands from the History.xml file, adds them to the c
urrent session history, and then executes the commands in the combined hist
ory.

The first command uses the Import-Clixml command to import a command histor
y that was exported to the History.xml file. The pipeline operator (|) pass
es the commands to the Add-History parameter, which adds the commands to th
e current session history. The PassThru parameter passes the objects repres
enting the added commands down the pipeline.

The command then uses the ForEach-Object cmdlet to apply the Invoke-History
command to each of the commands in the combined history. The Invoke-Histor
y command is formatted as a script block, which is enclosed in braces ({})
because ForEach-Object requires a script block even when there is only one
command to apply.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-history -id 5 -count 5 | add-history

Description
-----------
This command adds the first five commands in the history to the end of the
history list. It uses the Get-History cmdlet to get the five commands endin
g in command 5. The pipeline operator (|) passes them to the Add-History cm
dlet, which appends them to the current history. The Add-History command do
es not include any parameters, but Windows PowerShell associates the object
s passed through the pipeline with the InputObject parameter.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$a = import-csv c:\testing\history.csv

C:\PS>add-history -inputobject $a -passthru

Description
-----------
These commands add the commands in the History.csv file to the current sess
ion history. The first command uses the Import-Csv cmdlet to import the com
mands in the History.csv file and store its contents in the variable $a. Th
e second command uses the Add-History cmdlet to add the commands from Histo
ry.csv to the current session history. It uses the InputObject parameter to
specify the $a variable and the PassThru parameter to generate an object t
o display at the command line. Without the PassThru parameter, Add-History
does not generate any output to display.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>add-history -inputobject (import-clixml c:\temp\history01.xml)

Description
-----------
This command adds the commands in the History01.xml file to the current ses
sion history. It uses the InputObject parameter to pass the results of the
command in parentheses to Add-History. The command in parentheses, which is
executed first, imports the History01.xml file into Windows PowerShell. Ad
d-History then adds the commands in the file to the session history.




REMARKS
To see the examples, type: "get-help Add-History -examples".
For more information, type: "get-help Add-History -detailed".
For technical information, type: "get-help Add-History -full".

NAME
Add-Member

SYNOPSIS
Adds a user-defined custom member to an instance of a Windows PowerShell ob
ject.


SYNTAX
Add-Member [-MemberType] {AliasProperty | CodeProperty | Property | NotePro
perty | ScriptProperty | Properties | PropertySet | Method | CodeMethod | S
criptMethod | Methods | ParameterizedProperty | MemberSet | Event | All} [-
Name] <string> -InputObject <psobject> [[-Value] <Object>] [[-SecondValue]
<Object>] [-Force] [-PassThru] [<CommonParameters>]


DESCRIPTION
The Add-Member cmdlet adds a user-defined custom member to an instance of a
Windows PowerShell object. It lets you add the following types of members:
AliasProperty, CodeProperty, NoteProperty, ScriptProperty, PropertySet, Co
deMethod, MemberSet, and ScriptMethod. You set the initial value of the mem
ber by using the Value parameter. In the case of AliasProperty, ScriptPrope
rty, CodeProperty, and CodeMethod, you can supply additional information by
using the SecondValue parameter.

The additional members are added to the particular instance of the object t
hat you pipe to Add-Member or specify using the InputObject parameter. The
additional member is available only while that instance exists. You can use
the Export-Clixml cmdlet to save the instance, including the additional me
mbers, to a file. The information stored in that file can be used by the Im
port-Clixml cmdlet to re-create the instance of the object.

PARAMETERS
-Force [<SwitchParameter>]
Adds a new member even if one with the same name already exists. Does n
ot work for core members of a type.

-InputObject <psobject>
Specifies the object to which the new member is added. Enter a variable
that contains the objects, or type a command or expression that gets t
he objects.

-MemberType <PSMemberTypes>
Specifies the type of the member to add. This parameter is mandatory.

The valid values for this parameter are:
-- AliasProperty: A property that defines a new name for an existing pr
operty.
-- CodeMethod: A method that references a static method of a Microsoft
.NET Framework class.
-- CodeProperty: A property that references a static property of a .NET
Framework class.
-- MemberSet: A predefined collection of properties and methods, such a
s PSBase, PSObject, and PSTypeNames.
-- Method: A method of the underlying .NET Framework object.
-- NoteProperty: A property with a static value.
-- ParameterizedProperty: A property that takes parameters and paramete
r values.
-- Property: A property of the underlying .NET Framework object.
-- PropertySet: A predefined collection of object properties.
-- ScriptMethod: A method whose value is the output of a script.
-- ScriptProperty: A property whose value is the output of a script.

-- All: Gets all member types.
-- Methods: Gets all types of methods of the object (e.g. method, codem
ethod, scriptmethod)
-- Properties: Gets all types of properties of the object (e.g. propert
y, codeproperty, aliasproperty, scriptproperty).

Not all objects have every type of member. If you specify a member type
that the object does not have, Windows PowerShell returns an error.

The Event member type is not valid for Add-Member.

-Name <string>
Specifies the name of the member to be added.

If you omit the "Name" parameter name, the value of the -Name parameter
must be the second unnamed parameter value in the command. If you incl
ude the parameter name, the parameters can appear in any order.

-PassThru [<SwitchParameter>]
Passes the newly extended object to the pipeline. By default, this cmdl
et does not generate any output.

-SecondValue <Object>
Specifies optional additional information about AliasProperty, ScriptPr
operty, CodeProperty, or CodeMethod members. If used when adding an Ali
asProperty, this parameter must be a data type. A conversion (cast) to
the specified data type is added to the value of the AliasProperty. For
example, if you add an AliasProperty that provides an alternate name f
or a string property, you can also specify a SecondValue parameter of S
ystem.Int32 to indicate that the value of that string property should b
e converted to an integer when accessed by using the corresponding Alia
sProperty.

You can use the SecondValue parameter to specify an additional ScriptBl
ock when adding a ScriptProperty member. In that case, the first Script
Block, specified in the Value parameter, is used to get the value of a
variable. The second ScriptBlock, specified in the SecondValue paramete
r, is used to set the value of a variable.

-Value <Object>
Specifies the initial value of the added member. If you add an AliasPro
perty, CodeProperty, or CodeMethod member, you can supply optional, add
itional information by using the SecondValue parameter.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$a = (get-childitem)[0]

C:\PS> $a | add-member -membertype noteproperty -name Status -value done

C:\PS> $a | get-member -type noteproperty

TypeName: System.IO.DirectoryInfo

Name MemberType Definition
---- ---------- ----------
PSChildName NoteProperty System.String PSChildName=Co
PSDrive NoteProperty System.Management.Automation
PSIsContainer NoteProperty System.Boolean PSIsContainer
PSParentPath NoteProperty System.String PSParentPath=M
PSPath NoteProperty System.String PSPath=Microso
PSProvider NoteProperty System.Management.Automation
Status NoteProperty System.String Status=done

Description
-----------
These commands add the Status note property to a DirectoryInfo object retur
ned by Get-ChildItem and assigns it a value of "done".

The first command gets the first object that Get-Childitem returns (index 0
).

The second command adds the note property.

The third command uses a pipeline operator (|) to send the updated object t
o the Get-Member cmdlet. The output shows that the property has been added.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$a = (get-childitem)[0]

C:\PS> $a | add-member -membertype aliasproperty -name FileLength -value Le
ngth

C:\PS> $a.filelength

Description
-----------
These commands add the FileLength alias property to a DirectoryInfo object
returned by Get-ChildItem. The new property is an alias for the Length prop
erty.

The first command gets the first object that Get-Childitem returns (index 0
).

The second command adds the alias property.

The third command returns the value of the new FileLength property.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$a = "a string"

C:\PS> $a = $a | add-member -membertype noteproperty -name StringUse -value
Display -passthru

C:\PS> $a.StringUse

Description
-----------
These commands add the StringUse a property to a string. Because the string
is not a PSObject object, you must include the PassThru parameter in the c
ommand to save the extended string in the variable. The last command in the
example displays the new property.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$a = "this is a string"

C:\PS> $a = add-member -inputobject $a -membertype scriptmethod -name words
`
-value {$this.split()} -passthru

C:\PS> $a.words()

Description
-----------
These commands add a script method to a string object. The script method ex
poses the Split() method of the System.String .NET Framework Class Library
class to make it convenient to return the individual words in a string by c
alling a method named "Words" on the string object. Note that the PassThru
parameter is specified to force Add-Member to return the extended string ob
ject as output to be stored in the $a variable.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>$event = get-eventlog -logname system -newest 1

C:\PS> $event.TimeWritten | get-member

C:\PS> add-member -inputobject $event -membertype aliasproperty -name When
`
-value TimeWritten -secondvalue System.String

C:\PS> $event.When | get-member

Description
-----------
These commands add an AliasProperty to an EventLogEntry object returned by
the Get-EventLog cmdlets. The AliasProperty is named "When" and is an alias
for the TimeWritten property of the object. The SecondValue parameter is u
sed to specify that the property value should be converted to type System.S
tring when accessed by using the AliasProperty; the TimeWritten property is
a DateTime object.

The first command uses the Get-EventLog cmdlet to retrieve the most recent
event from the System event log and stores it in the $event variable.

The second command accesses the TimeWritten property of that event and pipe
s it to the Get-Member cmdlet to demonstrate that the property is a DateTim
e type. Add-Member is then used to add an AliasProperty member to the insta
nce of the EventLogEntry object stored in the $event variable. The Name par
ameter is used to set the name of the new member to "When" and the Value pa
rameter is used to specify that it is an alias for the TimeWritten property
. The SecondValue parameter is used to indicate that, when this new member
is used, the value it returns should be cast from its original System.DateT
ime type to a System.String type.

The third command accesses the new member and pipes it to the Get-Member cm
dlet to confirm that it is of type System.String.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>function Copy-Property ($From, $To)

{
foreach ($p in Get-Member -InputObject $From -MemberType Property)
{
Add-Member -InputObject $To -MemberType NoteProperty -Name $p.Name
-Value $From.$($p.Name) -Force

$To.$($p.Name) = $From.$($p.Name)
}
}

Description
-----------
This function copies all of the properties of one object to another object.

The first command in the function declares the function name and lists its
parameters.

The Foreach loop uses the Get-Member cmdlet to get each of the properties o
f the From object. The commands within the Foreach loop are performed in se
ries on each of the properties.

The Add-Member command adds the property of the From object to the To objec
t as a NoteProperty. It uses the Force parameter to let the command add mem
bers with the same member name.

The last command in the function gives the new property the same name as th
e original property.




REMARKS
To see the examples, type: "get-help Add-Member -examples".
For more information, type: "get-help Add-Member -detailed".
For technical information, type: "get-help Add-Member -full".

NAME
Add-PSSnapin

SYNOPSIS
Adds one or more Windows PowerShell snap-ins to the current session.


SYNTAX
Add-PSSnapin [-Name] <string[]> [-PassThru] [<CommonParameters>]


DESCRIPTION
The Add-PSSnapin cmdlet adds registered Windows PowerShell snap-ins to the
current session. After the snap-ins are added, you can use the cmdlets and
providers that the snap-ins support in the current session.

To add the snap-in to all future Windows PowerShell sessions, add an Add-PS
Snapin command to your Windows PowerShell profile. For more information, se
e about_Profiles.

PARAMETERS
-Name <string[]>
Specifies the name of the snap-in. (This is the Name, not the AssemblyN
ame or ModuleName.)

To find the names of the registered snap-ins on your system, type: "get
-pssnapin -registered".

-PassThru [<SwitchParameter>]
Returns an object representing each added snap-in. By default, this cmd
let does not generate any output.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>add-PSSnapIn Microsoft.Exchange, Microsoft.Windows.AD

Description
-----------
This command adds the Microsoft Exchange and Active Directory snap-ins to t
he current session.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-pssnapin -registered | add-pssnapin -passthru

Description
-----------
This command adds all of the registered Windows PowerShell snap-ins to the
session. It uses the Get-PSSnapin cmdlet with the Registered parameter to g
et objects representing each of the registered snap-ins. The pipeline opera
tor (|) passes the result to Add-PSSnapin, which adds them to the session.
The PassThru parameter returns objects that represent each of the added sna
p-ins.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-pssnapin

Description
-----------
This example demonstrates the process of registering a snap-in on your syst
em and then adding it to your session. It uses ManagementFeatures, a fictit
ious snap-in implemented in a file called ManagementCmdlets.dll.

The first command gets snap-ins that have been added to the current session
, including the snap-ins that are installed with Windows PowerShell. In thi
s example, ManagementFeatures is not returned. This indicates that it has n
ot been added to the session.

get-pssnapin


The second command gets snap-ins that have been registered on your system (
including those that have already been added to the session). It does not i
nclude the snap-ins that are installed with Windows PowerShell.

get-pssnapin -registered


In this case, the command does not return any snap-ins. This indicates that
the ManagementFeatures snapin has not been registered on the system.

The third command creates an alias, "installutil", for the path to the Inst
allUtil tool in the .NET Framework.

set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\in
stallutil.exe


The fourth command uses the InstallUtil tool to register the snap-in. The c
ommand specifies the path to ManagementCmdlets.dll, the file name or "modul
e name" of the snap-in.

installutil C:\Dev\Management\ManagementCmdlets.dll


The fifth command is the same as the second command. This time, you use it
to verify that the ManagementCmdlets snap-in is registered.

get-pssnapin -registered

The sixth command uses the Add-PSSnapin cmdlet to add the ManagementFeature
s snap-in to the session. It specifies the name of the snap-in, ManagementF
eatures, not the file name.

add-pssnapin ManagementFeatures

To verify that the snap-in is added to the session, the seventh command use
s the Module parameter of the Get-Command cmdlet. It displays the items tha
t were added to the session by a snap-in or module.

get-command -module ManagementFeatures

You can also use the PSSnapin property of the object that Get-Command retur
ns to find the snap-in or module in which a cmdlet originated. The eighth c
ommand uses dot notation to find the value of the PSSnapin property of the
Set-Alias command.

(get-command set-alias).pssnapin




REMARKS
To see the examples, type: "get-help Add-PSSnapin -examples".
For more information, type: "get-help Add-PSSnapin -detailed".
For technical information, type: "get-help Add-PSSnapin -full".

NAME
Add-Type

SYNOPSIS
Adds a Microsoft .NET Framework type (a class) to a Windows PowerShell sess
ion.


SYNTAX
Add-Type -AssemblyName <string[]> [-IgnoreWarnings] [-PassThru] [<CommonPar
ameters>]

Add-Type [-Name] <string> [-MemberDefinition] <string[]> [-CodeDomProvider
<CodeDomProvider>] [-CompilerParameters <CompilerParameters>] [-Language {C
Sharp | CSharpVersion3 | VisualBasic | JScript}] [-Namespace <string>] [-Ou
tputAssembly <string>] [-OutputType <OutputAssemblyType>] [-ReferencedAssem
blies <string[]>] [-UsingNamespace <string[]>] [-IgnoreWarnings] [-PassThru
] [<CommonParameters>]

Add-Type [-Path] <string[]> [-CompilerParameters <CompilerParameters>] [-Ou
tputAssembly <string>] [-OutputType <OutputAssemblyType>] [-ReferencedAssem
blies <string[]>] [-IgnoreWarnings] [-PassThru] [<CommonParameters>]

Add-Type [-TypeDefinition] <string> [-CodeDomProvider <CodeDomProvider>] [-
CompilerParameters <CompilerParameters>] [-Language {CSharp | CSharpVersion
3 | VisualBasic | JScript}] [-OutputAssembly <string>] [-OutputType <Output
AssemblyType>] [-ReferencedAssemblies <string[]>] [-IgnoreWarnings] [-PassT
hru] [<CommonParameters>]


DESCRIPTION
The Add-Type cmdlet lets you define a .NET Framework class in your Windows
PowerShell session. You can then instantiate objects (by using the New-Obje
ct cmdlet) and use the objects, just as you would use any .NET Framework ob
ject. If you add an Add-Type command to your Windows PowerShell profile, t
he class will be available in all Windows PowerShell sessions.

You can specify the type by specifying an existing assembly or source code
files, or you can specify the source code inline or saved in a variable. Yo
u can even specify only a method and Add-Type will define and generate the
class. You can use this feature to make Platform Invoke (P/Invoke) calls to
unmanaged functions in Windows PowerShell. If you specify source code, Add
-Type compiles the specified source code and generates an in-memory assembl
y that contains the new .NET Framework types.

You can use the parameters of Add-Type to specify an alternate language and
compiler (CSharp is the default), compiler options, assembly dependencies,
the class namespace, the names of the type, and the resulting assembly.

PARAMETERS
-AssemblyName <string[]>
Specifies the name of an assembly that includes the types. Add-Type tak
es the types from the specified assembly. This parameter is required wh
en you are creating types based on an assembly name.

Enter the full or simple name (also known as the "partial name") of an
assembly. Wildcard characters are permitted in the assembly name. If yo
u enter a simple or partial name, Add-Type resolves it to the full name
, and then uses the full name to load the assembly.

This parameter does not accept a path or file name. To enter the path t
o the assembly dynamic-link library (DLL) file, use the Path parameter.

-CodeDomProvider <CodeDomProvider>
Specifies a code generator or compiler. Add-Type uses the specified com
piler to compile the source code. The default is the CSharp compiler.
Use this parameter if you are using a language that cannot be specified
by using the Language parameter. The CodeDomProvider that you specify
must be able to generate assemblies from source code.

-CompilerParameters <CompilerParameters>
Specifies the options for the source code compiler. These options are s
ent to the compiler without revision.

This parameter allows you to direct the compiler to generate an executa
ble file, embed resources, or set command-line options, such as the "/u
nsafe" option. This parameter implements the CompilerParameters class (
System.CodeDom.Compiler.CompilerParameters).

-IgnoreWarnings [<SwitchParameter>]
Ignores compiler warnings. Use this parameter to prevent Add-Type from
handling compiler warnings as errors.

-Language <Language>
Specifies the language used in the source code. Add-Type uses the lang
uage to select the correct code compiler.

Valid values are "CSharp", "CSharpVersion3", "VisualBasic", and "JScrip
t". "CSharp" is the default.

-MemberDefinition <string[]>
Specifies new properties or methods for the class. Add-Type generates t
he template code that is required to support the properties or methods.

You can use this feature to make Platform Invoke (P/Invoke) calls to un
managed functions in Windows PowerShell. For more information, see the
examples.

-Name <string>
Specifies the name of the class to create. This parameter is required w
hen generating a type from a member definition.

The type name and namespace must be unique within a session. You cannot
unload a type or change it. If you need to change the code for a type,
you must change the name or start a new Windows PowerShell session. Ot
herwise, the command fails.

-Namespace <string>
Specifies a namespace for the type.

If this parameter is not included in the command, the type is created i
n the Microsoft.PowerShell.Commands.AddType.AutoGeneratedTypes namespac
e. If the parameter is included in the command with an empty string val
ue or a value of $null, the type is generated in the global namespace.

-OutputAssembly <string>
Generates a DLL file for the assembly with the specified name in the lo
cation. Enter a path (optional) and file name. Wildcard characters are
permitted. By default, Add-Type generates the assembly only in memory.

-OutputType <OutputAssemblyType>
Specifies the output type of the output assembly. Valid values are Lib
rary, ConsoleApplication, and WindowsApplication.
By default, no output type is specified.

This parameter is valid only when an output assembly is specified in th
e command.

-PassThru [<SwitchParameter>]
Returns a System.Runtime object that represents the types that were add
ed. By default, this cmdlet does not generate any output.

-Path <string[]>
Specifies the path to source code files or assembly DLL files that cont
ain the types.

If you submit source code files, Add-Type compiles the code in the file
s and creates an in-memory assembly of the types. The file name extensi
on specified in the value of Path determines the compiler that Add-Type
uses.

If you submit an assembly file, Add-Type takes the types from the assem
bly. To specify an in-memory assembly or the global assembly cache, use
the AssemblyName parameter.

-ReferencedAssemblies <string[]>
Specifies the assemblies upon which the type depends. By default, Add-T
ype references System.dll and System.Management.Automation.dll. The ass
emblies that you specify by using this parameter are referenced in addi
tion to the default assemblies.

-TypeDefinition <string>
Specifies the source code that contains the type definitions. Enter the
source code in a string or here-string, or enter a variable that conta
ins the source code. For more information about here-strings, see about
_Quoting_Rules.

Include a namespace declaration in your type definition. If you omit th
e namespace declaration, your type might have the same name as another
type or the shortcut for another type, causing an unintentional overwri
te. For example, if you define a type called "Exception", scripts that
use "Exception" as the shortcut for System.Exception will fail.

-UsingNamespace <string[]>
Specifies other namespaces that are required for the class. This is muc
h like the Using keyword in C#.

By default, Add-Type references the System namespace. When the MemberDe
finition parameter is used, Add-Type also references the System.Runtime
.InteropServices namespace by default. The namespaces that you add by u
sing the UsingNamespace parameter are referenced in addition to the def
ault namespaces.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$source = @"
public class BasicTest
{
public static int Add(int a, int b)
{
return (a + b);
}

public int Multiply(int a, int b)
{
return (a * b);
}
}
"@

C:\PS> Add-Type -TypeDefinition $source

C:\PS> [BasicTest]::Add(4, 3)

C:\PS> $basicTestObject = New-Object BasicTest
C:\PS> $basicTestObject.Multiply(5, 2)

Description
-----------
These commands add the BasicTest class to the session by specifying source
code that is stored in a variable. The type has a static method called Add
and a non-static method called Multiply.

The first command stores the source code for the class in the $source varia
ble.

The second command uses the Add-Type cmdlet to add the class to the session
. Because it is using inline source code, the command uses the TypeDefiniti
on parameter to specify the code in the $source variable.

The remaining commands use the new class.

The third command calls the Add static method of the BasicTest class. It us
es the double-colon characters (::) to specify a static member of the class
.

The fourth command uses the New-Object cmdlet to instantiate an instance of
the BasicTest class. It saves the new object in the $basicTestObject varia
ble.

The fifth command uses the Multiply method of $basicTestObject.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>[BasicTest] | get-member

C:\PS> [BasicTest] | get-member -static

C:\PS> $basicTestObject | get-member

C:\PS> [BasicTest] | get-member


TypeName: System.RuntimeType

Name MemberType Definition
---- ---------- ----------
Clone Method System.Object Clone()
Equals Method System.Boolean Equals
FindInterfaces Method System.Type[] FindInt
...


C:\PS> [BasicTest] | get-member -static

TypeName: BasicTest

Name MemberType Definition
---- ---------- ----------
Add Method static System.Int32 Add(Int32 a, Int32 b)
Equals Method static System.Boolean Equals(Object objA,
ReferenceEquals Method static System.Boolean ReferenceEquals(Obj


C:\PS> $basicTestObject | get-member

TypeName: BasicTest

Name MemberType Definition
---- ---------- ----------
Equals Method System.Boolean Equals(Object obj)
GetHashCode Method System.Int32 GetHashCode()
GetType Method System.Type GetType()
Multiply Method System.Int32 Multiply(Int32 a, Int32 b)
ToString Method System.String ToString()

Description
-----------
These commands use the Get-Member cmdlet to examine the objects that the Ad
d-Type and New-Object cmdlets created in the previous example.

The first command uses the Get-Member cmdlet to get the type and members of
the BasicTest class that Add-Type added to the session. The Get-Member com
mand reveals that it is a System.RuntimeType object, which is derived from
the System.Object class.

The second command uses the Static parameter of Get-Member to get the stati
c properties and methods of the BasicTest class. The output shows that the
Add method is included.

The third command uses Get-Member to get the members of the object stored i
n the $BasicTestObject variable. This was the object instance that was crea
ted by using the New-Object cmdlet with the $BasicType class.

The output reveals that the value of the $basicTestObject variable is an in
stance of the BasicTest class and that it includes a member called Multiply
.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$accType = add-type -assemblyname accessib* -passthru

Description
-----------
This command adds the classes from the Accessibility assembly to the curren
t session. The command uses the AssemblyName parameter to specify the name
of the assembly. The wildcard character allows you to get the correct assem
bly even when you are not sure of the name or its spelling.

The command uses the PassThru parameter to generate objects that represent
the classes that are added to the session, and it saves the objects in the
$accType variable.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>add-type -path c:\ps-test\Hello.vb

[VBFromFile]::SayHello(", World")

# From Hello.vb
Public Class VBFromFile

Public Shared Function SayHello(sourceName As String) As String
Dim myValue As String = "Hello"

return myValue + sourceName
End Function
End Class

C:\PS> [VBFromFile]::SayHello(", World")
Hello, World

Description
-----------
This example uses the Add-Type cmdlet to add the VBFromFile class that is d
efined in the Hello.vb file to the current session. The text of the Hello.v
b file is shown in the command output.

The first command uses the Add-Type cmdlet to add the type defined in the H
ello.vb file to the current session. The command uses the path parameter to
specify the source file.

The second command calls the SayHello function as a static method of the VB
FromFile class.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>$signature = @"
[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
"@

$showWindowAsync = Add-Type -memberDefinition $signature -name "Win32ShowWi
ndowAsync" -namespace Win32Functions -passThru

# Minimize the Windows PowerShell console
$showWindowAsync::ShowWindowAsync((Get-Process -id $pid).MainWindowHandle,
2)

# Restore it
$showWindowAsync::ShowWindowAsync((Get-Process -id $pid).MainWindowHandle,
4)

Description
-----------
The commands in this example demonstrate how to call native Windows APIs in
Windows PowerShell. Add-Type uses the Platform Invoke (P/Invoke) mechanism
to call a function in User32.dll from Windows PowerShell.

The first command stores the C# signature of the ShowWindowAsync function i
n the $signature variable. (For more information, see "ShowWindowAsync Func
tion" in the MSDN library at http://go.microsoft.com/fwlink/?LinkId=143643.
) To ensure that the resulting method will be visible in a Windows PowerShe
ll session, the "public" keyword has been added to the standard signature.

The second command uses the Add-Type cmdlet to add the ShowWindowAsync func
tion to the Windows PowerShell session as a static method of a class that A
dd-Type creates. The command uses the MemberDefinition parameter to specify
the method definition saved in the $signature variable.

The command uses the Name and Namespace parameters to specify a name and na
mespace for the class. It uses the PassThru parameter to generate an object
that represents the types, and it saves the object in the $showWindowAsync
variable.

The third and fourth commands use the new ShowWindowAsync static method. Th
e method takes two parameters, the window handle, and an integer specifies
how the window is to be shown.

The third command calls ShowWindowAsync. It uses the Get-Process cmdlet wit
h the $pid automatic variable to get the process that is hosting the curren
t Windows PowerShell session. Then it uses the MainWindowHandle property of
the current process and a value of "2", which represents the SW_MINIMIZE v
alue.

To restore the window, the fourth command use a value of "4" for the window
position, which represents the SW_RESTORE value. (SW_MAXIMIZE is 3.)




-------------------------- EXAMPLE 6 --------------------------

C:\PS>Add-Type -MemberDefinition $jsMethod -Name "PrintInfo" -Language JScr
ipt

Description
-----------
This command uses the Add-Type cmdlet to add a method from inline JScript c
ode to the Windows PowerShell session. It uses the MemberDefinition paramet
er to submit source code stored in the $jsMethod variable. It uses the Name
variable to specify a name for the class that Add-Type creates for the met
hod and the Language parameter to specify the JScript language.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>Add-Type -Path FSharp.Compiler.CodeDom.dll


C:\PS> Add-Type -Path FSharp.Compiler.CodeDom.dll
C:\PS> $provider = New-Object Microsoft.FSharp.Compiler.CodeDom.FSharpCodeP
rovider

C:\PS> $fSharpCode = @"
let rec loop n =
if n <= 0 then () else begin
print_endline (string_of_int n);
loop (n-1)
end
"@

C:\PS> $fsharpType = Add-Type -TypeDefinition $fSharpCode -CodeDomProvider
$provider -PassThru | where { $_.IsPublic }
C:\PS> $fsharpType::loop(4)
4
3
2
1

Description
-----------
This example shows how to use the Add-Type cmdlet to add an FSharp code com
piler to your Windows PowerShell session. To run this example in Windows Po
werShell, you must have the FSharp.Compiler.CodeDom.dll that is installed w
ith the FSharp language.

The first command in the example uses the Add-Type cmdlet with the Path par
ameter to specify an assembly. Add-Type gets the types in the assembly.

The second command uses the New-Object cmdlet to create an instance of the
FSharp code provider and saves the result in the $provider variable.

The third command saves the FSharp code that defines the Loop method in the
$FSharpCode variable.

The fourth command uses the Add-Type cmdlet to save the public types define
d in $fSharpCode in the $fSharpType variable. The TypeDefinition parameter
specifies the source code that defines the types. The CodeDomProvider param
eter specifies the source code compiler.

The PassThru parameter directs Add-Type to return a Runtime object that rep
resents the types and a pipeline operator (|) sends the Runtime object to t
he Where-Object cmdlet, which returns only the public types. The Where-Obje
ct filter is used because the FSharp provider generates non-public types to
support the resulting public type.

The fifth command calls the Loop method as a static method of the type stor
ed in the $fSharpType variable.




REMARKS
To see the examples, type: "get-help Add-Type -examples".
For more information, type: "get-help Add-Type -detailed".
For technical information, type: "get-help Add-Type -full".

NAME
Add-PSSnapin

SYNOPSIS
Adds one or more Windows PowerShell snap-ins to the current session.


SYNTAX
Add-PSSnapin [-Name] <string[]> [-PassThru] [<CommonParameters>]


DESCRIPTION
The Add-PSSnapin cmdlet adds registered Windows PowerShell snap-ins to the
current session. After the snap-ins are added, you can use the cmdlets and
providers that the snap-ins support in the current session.

To add the snap-in to all future Windows PowerShell sessions, add an Add-PS
Snapin command to your Windows PowerShell profile. For more information, se
e about_Profiles.

PARAMETERS
-Name <string[]>
Specifies the name of the snap-in. (This is the Name, not the AssemblyN
ame or ModuleName.)

To find the names of the registered snap-ins on your system, type: "get
-pssnapin -registered".

-PassThru [<SwitchParameter>]
Returns an object representing each added snap-in. By default, this cmd
let does not generate any output.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>add-PSSnapIn Microsoft.Exchange, Microsoft.Windows.AD

Description
-----------
This command adds the Microsoft Exchange and Active Directory snap-ins to t
he current session.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-pssnapin -registered | add-pssnapin -passthru

Description
-----------
This command adds all of the registered Windows PowerShell snap-ins to the
session. It uses the Get-PSSnapin cmdlet with the Registered parameter to g
et objects representing each of the registered snap-ins. The pipeline opera
tor (|) passes the result to Add-PSSnapin, which adds them to the session.
The PassThru parameter returns objects that represent each of the added sna
p-ins.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-pssnapin

Description
-----------
This example demonstrates the process of registering a snap-in on your syst
em and then adding it to your session. It uses ManagementFeatures, a fictit
ious snap-in implemented in a file called ManagementCmdlets.dll.

The first command gets snap-ins that have been added to the current session
, including the snap-ins that are installed with Windows PowerShell. In thi
s example, ManagementFeatures is not returned. This indicates that it has n
ot been added to the session.

get-pssnapin


The second command gets snap-ins that have been registered on your system (
including those that have already been added to the session). It does not i
nclude the snap-ins that are installed with Windows PowerShell.

get-pssnapin -registered


In this case, the command does not return any snap-ins. This indicates that
the ManagementFeatures snapin has not been registered on the system.

The third command creates an alias, "installutil", for the path to the Inst
allUtil tool in the .NET Framework.

set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\in
stallutil.exe


The fourth command uses the InstallUtil tool to register the snap-in. The c
ommand specifies the path to ManagementCmdlets.dll, the file name or "modul
e name" of the snap-in.

installutil C:\Dev\Management\ManagementCmdlets.dll


The fifth command is the same as the second command. This time, you use it
to verify that the ManagementCmdlets snap-in is registered.

get-pssnapin -registered

The sixth command uses the Add-PSSnapin cmdlet to add the ManagementFeature
s snap-in to the session. It specifies the name of the snap-in, ManagementF
eatures, not the file name.

add-pssnapin ManagementFeatures

To verify that the snap-in is added to the session, the seventh command use
s the Module parameter of the Get-Command cmdlet. It displays the items tha
t were added to the session by a snap-in or module.

get-command -module ManagementFeatures

You can also use the PSSnapin property of the object that Get-Command retur
ns to find the snap-in or module in which a cmdlet originated. The eighth c
ommand uses dot notation to find the value of the PSSnapin property of the
Set-Alias command.

(get-command set-alias).pssnapin




REMARKS
To see the examples, type: "get-help Add-PSSnapin -examples".
For more information, type: "get-help Add-PSSnapin -detailed".
For technical information, type: "get-help Add-PSSnapin -full".

B:

C:

NAME
Get-Content

SYNOPSIS
Gets the content of the item at the specified location.


SYNTAX
Get-Content [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Exclud
e <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-ReadCount
<Int64>] [-TotalCount <Int64>] [-UseTransaction] [<CommonParameters>]

Get-Content [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <stri
ng[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-ReadCount <Int64
>] [-TotalCount <Int64>] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Get-Content cmdlet gets the content of the item at the location specifi
ed by the path, such as the text in a file. It reads the content one line a
t a time and returns an object for each line.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers that are installed wit
h Windows PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Overrides restrictions that prevent the command from succeeding, just s
o the changes do not compromise security. For example, Force will overr
ide the read-only attribute or create directories to complete a file pa
th, but it will not attempt to change file permissions.

-Include <string[]>
Retrieves only the specified items. The value of this parameter qualifi
es the Path parameter. Enter a path element or pattern, such as "*.txt"
. Wildcards are permitted.

-LiteralPath <string[]>
Specifies the path to an item. Unlike Path, the value of LiteralPath is
used exactly as it is typed. No characters are interpreted as wildcard
s. If the path includes escape characters, enclose it in single quotati
on marks. Single quotation marks tell Windows PowerShell not to interpr
et any characters as escape sequences.

-Path <string[]>
Specifies the path to an item. Get-Content retrieves the content of the
item. Wildcards are permitted. The parameter name ("Path" or "FilePath
") is optional.

-ReadCount <Int64>
Specifies how many lines of content are sent through the pipeline at a
time. The default value is 1. A value of 0 (zero) sends all of the cont
ent at one time.

This parameter does not change the content displayed, but it does affec
t the time it takes to display the content. As the value of ReadCount i
ncreases, the time it takes to return the first line increases, but the
total time for the operation decreases. This can make a perceptible di
fference in very large items.

-TotalCount <Int64>
Specifies how many lines of content are retrieved. The default is -1 (a
ll lines).

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-content -Path C:\Chapters\chapter1.txt

Description
-----------
This command displays the content of the Chapter1.txt file on the console.
It uses the Path parameter to specify the name of the item. Get-Content act
ually passes the content down the pipeline, but because there are no other
pipeline elements, the content is formatted and displayed on the console.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-content c:\Logs\Log060912.txt -totalcount 50 | set-content sample
.txt

Description
-----------
This command gets the first 50 lines of the Log060912.txt file and stores t
hem in the sample.txt file. The command uses the Get-Content cmdlet to get
the text in the file. (The name of Path parameter, which is optional, is om
itted.) The TotalCount parameter limits the retrieval to the first 50 lines
. The pipeline operator (|) sends the result to Set-Content, which places i
t in the sample.txt file.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>(get-content cmdlets.txt -totalcount 5)[-1]

Description
-----------
This command gets the fifth line of the Cmdlets.txt text file. It uses the
TotalCount parameter to get the first five lines and then uses array notati
on to get the last line (indicated by "-1") of the resulting set.




REMARKS
To see the examples, type: "get-help Get-Content -examples".
For more information, type: "get-help Get-Content -detailed".
For technical information, type: "get-help Get-Content -full".

NAME
Set-Location

SYNOPSIS
Sets the current working location to a specified location.


SYNTAX
Set-Location [-LiteralPath] <string> [-PassThru] [-UseTransaction] [<Common
Parameters>]

Set-Location [[-Path] <string>] [-PassThru] [-UseTransaction] [<CommonParam
eters>]

Set-Location [-StackName <string>] [-PassThru] [-UseTransaction] [<CommonPa
rameters>]


DESCRIPTION
The Set-Location cmdlet sets the working location to a specified location.
That location could be a directory, a sub-directory, a registry location, o
r another location stack.

PARAMETERS
-LiteralPath <string>
Specifies a path to the location. The value of the LiteralPath paramete
r is used exactly as it is typed. No characters are interpreted as wild
cards. If the path includes escape characters, enclose it in single quo
tation marks. Single quotation marks tell Windows PowerShell not to int
erpret any characters as escape sequences.

-PassThru [<SwitchParameter>]
Passes an object representing the location to the pipeline. By default,
this cmdlet does not generate any output.

-Path <string>
This parameter is used to specify the path to a new working location.

-StackName <string>
The name of the stack to which the location is being set.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>set-location HKLM:

Description
-----------
This will set the current location to the one specified; in this case, it i
s the HKLM provider.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>set-location env: -passthru

Path
----
Env:\

Description
-----------
This will set the current location to the one specified; in this case, it i
s the environment variable provider.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>set-location C:

Description
-----------
This will set the current location to the one specified; in this case, it i
s the C: drive in the file system provider.




REMARKS
To see the examples, type: "get-help Set-Location -examples".
For more information, type: "get-help Set-Location -detailed".
For technical information, type: "get-help Set-Location -full".

cd..

cd\

NAME
Set-Location

SYNOPSIS
Sets the current working location to a specified location.


SYNTAX
Set-Location [-LiteralPath] <string> [-PassThru] [-UseTransaction] [<Common
Parameters>]

Set-Location [[-Path] <string>] [-PassThru] [-UseTransaction] [<CommonParam
eters>]

Set-Location [-StackName <string>] [-PassThru] [-UseTransaction] [<CommonPa
rameters>]


DESCRIPTION
The Set-Location cmdlet sets the working location to a specified location.
That location could be a directory, a sub-directory, a registry location, o
r another location stack.

PARAMETERS
-LiteralPath <string>
Specifies a path to the location. The value of the LiteralPath paramete
r is used exactly as it is typed. No characters are interpreted as wild
cards. If the path includes escape characters, enclose it in single quo
tation marks. Single quotation marks tell Windows PowerShell not to int
erpret any characters as escape sequences.

-PassThru [<SwitchParameter>]
Passes an object representing the location to the pipeline. By default,
this cmdlet does not generate any output.

-Path <string>
This parameter is used to specify the path to a new working location.

-StackName <string>
The name of the stack to which the location is being set.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>set-location HKLM:

Description
-----------
This will set the current location to the one specified; in this case, it i
s the HKLM provider.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>set-location env: -passthru

Path
----
Env:\

Description
-----------
This will set the current location to the one specified; in this case, it i
s the environment variable provider.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>set-location C:

Description
-----------
This will set the current location to the one specified; in this case, it i
s the C: drive in the file system provider.




REMARKS
To see the examples, type: "get-help Set-Location -examples".
For more information, type: "get-help Set-Location -detailed".
For technical information, type: "get-help Set-Location -full".

NAME
Checkpoint-Computer

SYNOPSIS
Creates a system restore point on the local computer.


SYNTAX
Checkpoint-Computer [-Description] <string> [[-RestorePointType] <string>]
[<CommonParameters>]


DESCRIPTION
The Checkpoint-Computer cmdlet creates a system restore point on the local
computer. This cmdlet runs only on Windows Vista and Windows XP.

PARAMETERS
-Description <string>
Specifies a descriptive name for the restore point. This parameter is r
equired.

-RestorePointType <string>
Specifies the type of restore point. The default is APPLICATION_INSTALL
.

Valid values are APPLICATION_INSTALL, APPLICATION_UNINSTALL, DEVICE_DRI
VER_INSTALL, MODIFY_SETTINGS, and CANCELLED_OPERATION.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>checkpoint-computer -description "Install MyApp"

Description
-----------
This command creates a system restore point called "Install MyApp". It uses
the default APPLICATION_INSTALL restore point type.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>checkpoint-computer -description "ChangeNetSettings" -RestorePointTyp
e MODIFY_SETTINGS

Description
-----------
This command creates a MODIFY_SETTINGS system restore point called "ChangeN
etSettings".




REMARKS
To see the examples, type: "get-help Checkpoint-Computer -examples".
For more information, type: "get-help Checkpoint-Computer -detailed".
For technical information, type: "get-help Checkpoint-Computer -full".

NAME
Clear-Content

SYNOPSIS
Deletes the contents of an item, such as deleting the text from a file, but
does not delete the item.


SYNTAX
Clear-Content [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Excl
ude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Confirm
] [-WhatIf] [-UseTransaction] [<CommonParameters>]

Clear-Content [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <st
ring[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Confirm] [-Wha
tIf] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Clear-Content cmdlet deletes the contents of an item, such as deleting
the text from a file, but it does not delete the item. As a result, the ite
m exists, but it is empty. Clear-Content is similar to Clear-Item, but it w
orks on files instead of on aliases and variables.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to clear the file contents even if the file is read-o
nly. Implementation varies from provider to provider. For more informat
ion, see about_Providers. Even using the Force parameter, the cmdlet ca
nnot override security restrictions.

-Include <string[]>
Clears only the specified items. The value of this parameter qualifies
the Path parameter. Enter a path element or pattern, such as "*.txt". W
ildcards are permitted.

-LiteralPath <string[]>
Specifies the paths to the items from which content is deleted. Unlike
Path, the value of LiteralPath is used exactly as it is typed. No chara
cters are interpreted as wildcards. If the path includes escape charact
ers, enclose it in single quotation marks. Single quotation marks tell
Windows PowerShell not to interpret any characters as escape sequences.

-Path <string[]>
Specifies the paths to the items from which content is deleted. Wildcar
ds are permitted. The paths must be paths to items, not to containers.
For example, you must specify a path to one or more files, not a path t
o a directory. Wildcards are permitted. This parameter is required, but
the parameter name ("Path") is optional.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>clear-content ..\SmpUsers\*\init.txt

Description
-----------
This command deletes all of the content from the "init.txt" files in all su
bdirectories of the SmpUsers directory. The files are not deleted, but they
are empty.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>clear-content -path * -filter *.log -force

Description
-----------
This command deletes the contents of all files in the current directory wit
h the ".log" file name extension, including files with the read-only attrib
ute. The asterisk (*) in the path represents all items in the current direc
tory. The Force parameter makes the command effective on read-only files. U
sing a filter to restrict the command to files with the ".log" file name ex
tension instead of specifying "*.log" in the path makes the operation faste
r.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>clear-content c:\Temp\* -Include Smp* -Exclude *2* -whatif

Description
-----------
This command requests a prediction of what would happen if you submitted th
e command: "clear-content c:\temp\* -include smp* -exclude *2*". The result
lists the files that would be cleared; in this case, files in the Temp dir
ectory whose names begin with "Smp", unless the file names include a "2". T
o execute the command, run it again without the Whatif parameter.




REMARKS
To see the examples, type: "get-help Clear-Content -examples".
For more information, type: "get-help Clear-Content -detailed".
For technical information, type: "get-help Clear-Content -full".

Clear-Host

NAME
Clear-Content

SYNOPSIS
Deletes the contents of an item, such as deleting the text from a file, but
does not delete the item.


SYNTAX
Clear-Content [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Excl
ude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Confirm
] [-WhatIf] [-UseTransaction] [<CommonParameters>]

Clear-Content [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <st
ring[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Confirm] [-Wha
tIf] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Clear-Content cmdlet deletes the contents of an item, such as deleting
the text from a file, but it does not delete the item. As a result, the ite
m exists, but it is empty. Clear-Content is similar to Clear-Item, but it w
orks on files instead of on aliases and variables.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to clear the file contents even if the file is read-o
nly. Implementation varies from provider to provider. For more informat
ion, see about_Providers. Even using the Force parameter, the cmdlet ca
nnot override security restrictions.

-Include <string[]>
Clears only the specified items. The value of this parameter qualifies
the Path parameter. Enter a path element or pattern, such as "*.txt". W
ildcards are permitted.

-LiteralPath <string[]>
Specifies the paths to the items from which content is deleted. Unlike
Path, the value of LiteralPath is used exactly as it is typed. No chara
cters are interpreted as wildcards. If the path includes escape charact
ers, enclose it in single quotation marks. Single quotation marks tell
Windows PowerShell not to interpret any characters as escape sequences.

-Path <string[]>
Specifies the paths to the items from which content is deleted. Wildcar
ds are permitted. The paths must be paths to items, not to containers.
For example, you must specify a path to one or more files, not a path t
o a directory. Wildcards are permitted. This parameter is required, but
the parameter name ("Path") is optional.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>clear-content ..\SmpUsers\*\init.txt

Description
-----------
This command deletes all of the content from the "init.txt" files in all su
bdirectories of the SmpUsers directory. The files are not deleted, but they
are empty.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>clear-content -path * -filter *.log -force

Description
-----------
This command deletes the contents of all files in the current directory wit
h the ".log" file name extension, including files with the read-only attrib
ute. The asterisk (*) in the path represents all items in the current direc
tory. The Force parameter makes the command effective on read-only files. U
sing a filter to restrict the command to files with the ".log" file name ex
tension instead of specifying "*.log" in the path makes the operation faste
r.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>clear-content c:\Temp\* -Include Smp* -Exclude *2* -whatif

Description
-----------
This command requests a prediction of what would happen if you submitted th
e command: "clear-content c:\temp\* -include smp* -exclude *2*". The result
lists the files that would be cleared; in this case, files in the Temp dir
ectory whose names begin with "Smp", unless the file names include a "2". T
o execute the command, run it again without the Whatif parameter.




REMARKS
To see the examples, type: "get-help Clear-Content -examples".
For more information, type: "get-help Clear-Content -detailed".
For technical information, type: "get-help Clear-Content -full".

NAME
Clear-EventLog

SYNOPSIS
Deletes all entries from specified event logs on the local or remote comput
ers.


SYNTAX
Clear-EventLog [-LogName] <string[]> [[-ComputerName] <string[]>] [-Confirm
] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Clear-EventLog cmdlet deletes all of the entries from the specified eve
nt logs on the local computer or on remote computers. To use Clear-EventLog
, you must be a member of the Administrators group on the affected computer
.

The cmdlets that contain the EventLog noun (the EventLog cmdlets) work only
on classic event logs. To get events from logs that use the Windows Event
Log technology in Windows Vista and later versions of Windows, use Get-WinE
vent.

PARAMETERS
-ComputerName <string[]>
Specifies a remote computer. The default is the local computer.

Type the NetBIOS name, an Internet Protocol (IP) address, or a fully qu
alified domain name of a remote computer. To specify the local computer
, type the computer name, a dot (.), or "localhost".

This parameter does not rely on Windows PowerShell remoting. You can us
e the ComputerName parameter of Get-EventLog even if your computer is n
ot configured to run remote commands.

-LogName <string[]>
Specifies the event logs. Enter the log name (the value of the Log prop
erty; not the LogDisplayName) of one or more event logs, separated by c
ommas. Wildcard characters are not permitted. This parameter is requir
ed.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>clear-eventlog "Windows PowerShell"

Description
-----------
This command deletes the entries from the "Windows PowerShell" event log on
the local computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>clear-eventlog -logname ODiag, OSession -computername localhost, Serv
er02

Description
-----------
This command deletes all of the entries in the Microsoft Office Diagnostics
(ODiag) and Microsoft Office Sessions (OSession) logs on the local compute
r and the Server02 remote computer.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>clear-eventlog -log application, system -confirm

Description
-----------
This command prompts you for confirmation before deleting the entries in th
e specified event logs.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>function clear-all-event-logs ($computerName="localhost")
{
$logs = get-eventlog -computername $computername -list | foreach {$_.Lo
g}
$logs | foreach {clear-eventlog -comp $computername -log $_ }
get-eventlog -computername $computername -list
}

C:\PS> clear-all-event-logs -comp Server01

Max(K) Retain OverflowAction Entries Log


------ ------ -------------- ------- ---


15,168 0 OverwriteAsNeeded 0 Application


15,168 0 OverwriteAsNeeded 0 DFS Replication


512 7 OverwriteOlder 0 DxStudio


20,480 0 OverwriteAsNeeded 0 Hardware Events


512 7 OverwriteOlder 0 Internet Explorer


20,480 0 OverwriteAsNeeded 0 Key Management Service


16,384 0 OverwriteAsNeeded 0 Microsoft Office Diagnostics


16,384 0 OverwriteAsNeeded 0 Microsoft Office Sessions


30,016 0 OverwriteAsNeeded 1 Security


15,168 0 OverwriteAsNeeded 2 System


15,360 0 OverwriteAsNeeded 0 Windows PowerShell

Description
-----------
This function clears all event logs on the specified computers and then dis
plays the resulting event log list.

Notice that a few entries were added to the System and Security logs after
the logs were cleared but before they were displayed.




REMARKS
To see the examples, type: "get-help Clear-EventLog -examples".
For more information, type: "get-help Clear-EventLog -detailed".
For technical information, type: "get-help Clear-EventLog -full".

NAME
Clear-History

SYNOPSIS
Deletes entries from the command history.


SYNTAX
Clear-History [[-Id] <Int32[]>] [[-Count] <int>] [-Newest] [-Confirm] [-Wha
tIf] [<CommonParameters>]

Clear-History [[-Count] <int>] [-CommandLine <string[]>] [-Newest] [-Confir
m] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Clear-History cmdlet deletes commands from the command history, that is
, the list of commands entered during the current session.

Without parameters, Clear-History deletes all commands from the session his
tory, but you can use the parameters of Clear-History to delete selected co
mmands.

PARAMETERS
-CommandLine <string[]>
Deletes commands with the specified text strings. If you enter more tha
n one string, Clear-History deletes commands with any of the strings.

-Count <int>
Clears the specified number of history entries, beginning with the old
est entry in the history.

If you use the Count and Id parameters in the same command, the cmdlet
clears the number of entries specified by the Count parameter, beginnin
g with the entry specified by the Id parameter. For example, if Count
is 10 and Id is 30, Clear-History clears items 21 through 30 inclusive.

If you use the Count and CommandLine parameters in the same command, Cl
ear-History clears the number of entries specified by the Count paramet
er, beginning with the entry specified by the CommandLine parameter.

-Id <Int32[]>
Deletes commands with the specified history IDs.

To find the history ID of a command, use Get-History.

-Newest [<SwitchParameter>]
Deletes the newest entries in the history. By default, Clear-History de
letes the oldest entries in the history.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>clear-history

Description
-----------
Deletes all commands from the session history.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>clear-history -id 23, 25

Description
-----------
Deletes the commands with history IDs 23 and 25.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>clear-history -command *help*, *command

Description
-----------
Deletes commands that include "help" or end in "command".




-------------------------- EXAMPLE 4 --------------------------

C:\PS>clear-history -count 10 -newest

Description
-----------
Deletes the 10 newest commands from the history.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>clear-history -id 10 -count 3

Description
-----------
Deletes the three oldest commands, beginning with the entry with ID 10.




REMARKS
To see the examples, type: "get-help Clear-History -examples".
For more information, type: "get-help Clear-History -detailed".
For technical information, type: "get-help Clear-History -full".

Clear-Host

NAME
Clear-Item

SYNOPSIS
Deletes the contents of an item, but does not delete the item.


SYNTAX
Clear-Item [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Exclude
<string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Confirm] [
-WhatIf] [-UseTransaction] [<CommonParameters>]

Clear-Item [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <strin
g[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Confirm] [-WhatIf
] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Clear-Item cmdlet deletes the value of an item, but it does not delete
the item. For example, Clear-Item can delete the value of a variable, but i
t does not delete the variable. The value that used to represent a cleared
item is defined by each Windows PowerShell provider. Clear-Item is similar
to Clear-Content, but it works on aliases and variables, instead of files.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to clear items that cannot otherwise be changed, such
as read- only aliases. The cmdlet cannot clear constants. Implementati
on varies from provider to provider. For more information, see about_Pr
oviders. Even using the Force parameter, the cmdlet cannot override sec
urity restrictions.

-Include <string[]>
Clears only the specified items. The value of this parameter qualifies
the Path parameter. Enter a path element or pattern, such as "*.txt". W
ildcards are permitted.

-LiteralPath <string[]>
Specifies the path to the items being cleared. Unlike Path, the value o
f LiteralPath is used exactly as it is typed. No characters are interpr
eted as wildcards. If the path includes escape characters, enclose it i
n single quotation marks. Single quotation marks tell Windows PowerShel
l not to interpret any characters as escape sequences.

-Path <string[]>
Specifies the path to the items being cleared. Wildcards are permitted.
This parameter is required, but the parameter name ("Path") is optiona
l.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>clear-item Variable:TestVar1

Description
-----------
This command deletes the value of the variable, Testvar1. The variable rema
ins and is valid, but its value is set to null.

The variable name is prefixed with "Variable:" to indicate the Windows Powe
rShell Variable provider. To get the same result, you can switch to the Win
dows PowerShell Variable provider namespace first and then perform the Clea
r-Item command.

PS C:> Set-location Variable:
PS Variable:\> clear-item Testvar1




-------------------------- EXAMPLE 2 --------------------------

C:\PS>clear-item Alias:log* -include *1* -exclude *3* -whatif

What if: Performing operation "Clear Item" on Target "Item: log1".

Description
-----------
This command asks Windows PowerShell what would happen if you executed the
command, "clear-item alias:log* -include *1* -exclude *3". In response, Win
dows PowerShell explains that it would delete the value of the log1 alias.

This command would not have any effect on the log, log2, or log13 aliases.
Because the Alias provider does not permit an alias without a value, when y
ou clear an alias, you also delete the alias.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>clear-item registry::HKLM\Software\MyCompany\MyKey -confirm

Description
-----------
This command deletes all registry entries in the MyKey subkey, but only aft
er prompting you to confirm your intent. It does not delete the MyKey subke
y or affect any other registry keys or entries. You can use the Include and
Exclude parameters to identify particular registry keys, but you cannot us
e them to identify registry entries. To delete particular registry entries,
use Remove-ItemProperty. To delete the value of a registry entry, use Clea
r-ItemProperty.




REMARKS
To see the examples, type: "get-help Clear-Item -examples".
For more information, type: "get-help Clear-Item -detailed".
For technical information, type: "get-help Clear-Item -full".

NAME
Clear-ItemProperty

SYNOPSIS
Deletes the value of a property but does not delete the property.


SYNTAX
Clear-ItemProperty [-LiteralPath] <string[]> [-Name] <string> [-Credential
<PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include
<string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonPar
ameters>]

Clear-ItemProperty [-Path] <string[]> [-Name] <string> [-Credential <PSCred
ential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <strin
g[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters
>]


DESCRIPTION
The Clear-ItemProperty cmdlet deletes the value of a property, but it does
not delete the property. You can use this cmdlet to delete the data from a
registry value.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt" or "s*".
Wildcards are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to delete properties from items that cannot otherwis
e be accessed by the user. Implementation varies from provider to provi
der. For more information, see about_Providers.

-Include <string[]>
Clears only the specified items. The value of this parameter qualifies
the Path parameter. Enter a path element or pattern, such as "*.txt". W
ildcards are permitted.

-LiteralPath <string[]>
Specifies the path to the property being cleared. Unlike Path, the valu
e of LiteralPath is used exactly as it is typed. No characters are inte
rpreted as wildcards. If the path includes escape characters, enclose i
t in single quotation marks. Single quotation marks tell Windows PowerS
hell not to interpret any characters as escape sequences.

-Name <string>
Specifies the name of the property to be cleared, such as the name of a
registry value. Wildcards are not permitted.

-PassThru [<SwitchParameter>]
Returns an object representing the cleared item's property. By default,
this cmdlet does not generate any output.

-Path <string[]>
Specifies the path to the property being cleared. Wildcards are permitt
ed.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>clear-itemproperty -path HKLM:\Software\MyCompany\MyApp -name Options

Description
-----------
This command deletes the data in the Options registry value in the MyApp su
bkey of HKEY_LOCAL_MACHINE\Software\MyCompany.

Because the command is being issued from a file system drive (C:), it uses
the fully qualified path to the HKLM: drive and the Software\MyCompany\MyAp
p subkey. It uses the Name parameter to specify the Options value.




REMARKS
To see the examples, type: "get-help Clear-ItemProperty -examples".
For more information, type: "get-help Clear-ItemProperty -detailed".
For technical information, type: "get-help Clear-ItemProperty -full".

NAME
Clear-Variable

SYNOPSIS
Deletes the value of a variable.


SYNTAX
Clear-Variable [-Name] <string[]> [-Exclude <string[]>] [-Force] [-Include
<string[]>] [-PassThru] [-Scope <string>] [-Confirm] [-WhatIf] [<CommonPara
meters>]


DESCRIPTION
The Clear-Variable cmdlet deletes the data stored in a variable, but it doe
s not delete the variable. As a result, the value of the variable is NULL (
empty). If the variable has a specified data or object type, Clear-Variable
preserves the type of the object stored in the variable.

PARAMETERS
-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Na
me parameter. Enter a name element or pattern, such as "s*". Wildcards
are permitted.

-Force [<SwitchParameter>]
Allows the cmdlet to clear a variable even if it is read-only. Even usi
ng the Force parameter, the cmdlet cannot clear constants.

-Include <string[]>
Clears only the specified items. The value of this parameter qualifies
the Name parameter. Enter a name element or pattern, such as "s*". Wild
cards are permitted.

-Name <string[]>
Specifies the name of the variable to be cleared. Wildcards are permitt
ed. This parameter is required, but the parameter name ("Name") is opti
onal.

-PassThru [<SwitchParameter>]
Returns an object representing the cleared variable. By default, this c
mdlet does not generate any output.

-Scope <string>
Specifies the scope in which this alias is valid. Valid values are "Glo
bal", "Local", or "Script", or a number relative to the current scope (
0 through the number of scopes, where 0 is the current scope and 1 is i
ts parent). "Local" is the default. For more information, see about_Sco
pes.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>clear-variable my* -global

Description
-----------
This command deletes the value of the global variables that begin with "my"
.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$a=3

C:\PS>&{ clear-variable a }

C:\PS>$a
3

Description
-----------
These commands demonstrate that clearing a variable in a child scope does n
ot clear the value in the parent scope. The first command sets the value of
the variable $a to "3". The second command uses the invoke operator (&) to
run a Clear-Variable command in a new scope. The variable is cleared in th
e child scope (although it did not exist), but it is not cleared in the loc
al scope. The third command, which gets the value of $a, shows that the val
ue "3" is unaffected.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>clear-variable -name processes

Description
-----------
This command deletes the value of the $processes variable. The $processes v
ariable still exists, but the value is null.




REMARKS
To see the examples, type: "get-help Clear-Variable -examples".
For more information, type: "get-help Clear-Variable -detailed".
For technical information, type: "get-help Clear-Variable -full".

NAME
Clear-History

SYNOPSIS
Deletes entries from the command history.


SYNTAX
Clear-History [[-Id] <Int32[]>] [[-Count] <int>] [-Newest] [-Confirm] [-Wha
tIf] [<CommonParameters>]

Clear-History [[-Count] <int>] [-CommandLine <string[]>] [-Newest] [-Confir
m] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Clear-History cmdlet deletes commands from the command history, that is
, the list of commands entered during the current session.

Without parameters, Clear-History deletes all commands from the session his
tory, but you can use the parameters of Clear-History to delete selected co
mmands.

PARAMETERS
-CommandLine <string[]>
Deletes commands with the specified text strings. If you enter more tha
n one string, Clear-History deletes commands with any of the strings.

-Count <int>
Clears the specified number of history entries, beginning with the old
est entry in the history.

If you use the Count and Id parameters in the same command, the cmdlet
clears the number of entries specified by the Count parameter, beginnin
g with the entry specified by the Id parameter. For example, if Count
is 10 and Id is 30, Clear-History clears items 21 through 30 inclusive.

If you use the Count and CommandLine parameters in the same command, Cl
ear-History clears the number of entries specified by the Count paramet
er, beginning with the entry specified by the CommandLine parameter.

-Id <Int32[]>
Deletes commands with the specified history IDs.

To find the history ID of a command, use Get-History.

-Newest [<SwitchParameter>]
Deletes the newest entries in the history. By default, Clear-History de
letes the oldest entries in the history.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>clear-history

Description
-----------
Deletes all commands from the session history.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>clear-history -id 23, 25

Description
-----------
Deletes the commands with history IDs 23 and 25.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>clear-history -command *help*, *command

Description
-----------
Deletes commands that include "help" or end in "command".




-------------------------- EXAMPLE 4 --------------------------

C:\PS>clear-history -count 10 -newest

Description
-----------
Deletes the 10 newest commands from the history.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>clear-history -id 10 -count 3

Description
-----------
Deletes the three oldest commands, beginning with the entry with ID 10.




REMARKS
To see the examples, type: "get-help Clear-History -examples".
For more information, type: "get-help Clear-History -detailed".
For technical information, type: "get-help Clear-History -full".

NAME
Clear-Item

SYNOPSIS
Deletes the contents of an item, but does not delete the item.


SYNTAX
Clear-Item [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Exclude
<string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Confirm] [
-WhatIf] [-UseTransaction] [<CommonParameters>]

Clear-Item [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <strin
g[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Confirm] [-WhatIf
] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Clear-Item cmdlet deletes the value of an item, but it does not delete
the item. For example, Clear-Item can delete the value of a variable, but i
t does not delete the variable. The value that used to represent a cleared
item is defined by each Windows PowerShell provider. Clear-Item is similar
to Clear-Content, but it works on aliases and variables, instead of files.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to clear items that cannot otherwise be changed, such
as read- only aliases. The cmdlet cannot clear constants. Implementati
on varies from provider to provider. For more information, see about_Pr
oviders. Even using the Force parameter, the cmdlet cannot override sec
urity restrictions.

-Include <string[]>
Clears only the specified items. The value of this parameter qualifies
the Path parameter. Enter a path element or pattern, such as "*.txt". W
ildcards are permitted.

-LiteralPath <string[]>
Specifies the path to the items being cleared. Unlike Path, the value o
f LiteralPath is used exactly as it is typed. No characters are interpr
eted as wildcards. If the path includes escape characters, enclose it i
n single quotation marks. Single quotation marks tell Windows PowerShel
l not to interpret any characters as escape sequences.

-Path <string[]>
Specifies the path to the items being cleared. Wildcards are permitted.
This parameter is required, but the parameter name ("Path") is optiona
l.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>clear-item Variable:TestVar1

Description
-----------
This command deletes the value of the variable, Testvar1. The variable rema
ins and is valid, but its value is set to null.

The variable name is prefixed with "Variable:" to indicate the Windows Powe
rShell Variable provider. To get the same result, you can switch to the Win
dows PowerShell Variable provider namespace first and then perform the Clea
r-Item command.

PS C:> Set-location Variable:
PS Variable:\> clear-item Testvar1




-------------------------- EXAMPLE 2 --------------------------

C:\PS>clear-item Alias:log* -include *1* -exclude *3* -whatif

What if: Performing operation "Clear Item" on Target "Item: log1".

Description
-----------
This command asks Windows PowerShell what would happen if you executed the
command, "clear-item alias:log* -include *1* -exclude *3". In response, Win
dows PowerShell explains that it would delete the value of the log1 alias.

This command would not have any effect on the log, log2, or log13 aliases.
Because the Alias provider does not permit an alias without a value, when y
ou clear an alias, you also delete the alias.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>clear-item registry::HKLM\Software\MyCompany\MyKey -confirm

Description
-----------
This command deletes all registry entries in the MyKey subkey, but only aft
er prompting you to confirm your intent. It does not delete the MyKey subke
y or affect any other registry keys or entries. You can use the Include and
Exclude parameters to identify particular registry keys, but you cannot us
e them to identify registry entries. To delete particular registry entries,
use Remove-ItemProperty. To delete the value of a registry entry, use Clea
r-ItemProperty.




REMARKS
To see the examples, type: "get-help Clear-Item -examples".
For more information, type: "get-help Clear-Item -detailed".
For technical information, type: "get-help Clear-Item -full".

NAME
Clear-ItemProperty

SYNOPSIS
Deletes the value of a property but does not delete the property.


SYNTAX
Clear-ItemProperty [-LiteralPath] <string[]> [-Name] <string> [-Credential
<PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include
<string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonPar
ameters>]

Clear-ItemProperty [-Path] <string[]> [-Name] <string> [-Credential <PSCred
ential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <strin
g[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters
>]


DESCRIPTION
The Clear-ItemProperty cmdlet deletes the value of a property, but it does
not delete the property. You can use this cmdlet to delete the data from a
registry value.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt" or "s*".
Wildcards are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to delete properties from items that cannot otherwis
e be accessed by the user. Implementation varies from provider to provi
der. For more information, see about_Providers.

-Include <string[]>
Clears only the specified items. The value of this parameter qualifies
the Path parameter. Enter a path element or pattern, such as "*.txt". W
ildcards are permitted.

-LiteralPath <string[]>
Specifies the path to the property being cleared. Unlike Path, the valu
e of LiteralPath is used exactly as it is typed. No characters are inte
rpreted as wildcards. If the path includes escape characters, enclose i
t in single quotation marks. Single quotation marks tell Windows PowerS
hell not to interpret any characters as escape sequences.

-Name <string>
Specifies the name of the property to be cleared, such as the name of a
registry value. Wildcards are not permitted.

-PassThru [<SwitchParameter>]
Returns an object representing the cleared item's property. By default,
this cmdlet does not generate any output.

-Path <string[]>
Specifies the path to the property being cleared. Wildcards are permitt
ed.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>clear-itemproperty -path HKLM:\Software\MyCompany\MyApp -name Options

Description
-----------
This command deletes the data in the Options registry value in the MyApp su
bkey of HKEY_LOCAL_MACHINE\Software\MyCompany.

Because the command is being issued from a file system drive (C:), it uses
the fully qualified path to the HKLM: drive and the Software\MyCompany\MyAp
p subkey. It uses the Name parameter to specify the Options value.




REMARKS
To see the examples, type: "get-help Clear-ItemProperty -examples".
For more information, type: "get-help Clear-ItemProperty -detailed".
For technical information, type: "get-help Clear-ItemProperty -full".

Clear-Host

NAME
Clear-Variable

SYNOPSIS
Deletes the value of a variable.


SYNTAX
Clear-Variable [-Name] <string[]> [-Exclude <string[]>] [-Force] [-Include
<string[]>] [-PassThru] [-Scope <string>] [-Confirm] [-WhatIf] [<CommonPara
meters>]


DESCRIPTION
The Clear-Variable cmdlet deletes the data stored in a variable, but it doe
s not delete the variable. As a result, the value of the variable is NULL (
empty). If the variable has a specified data or object type, Clear-Variable
preserves the type of the object stored in the variable.

PARAMETERS
-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Na
me parameter. Enter a name element or pattern, such as "s*". Wildcards
are permitted.

-Force [<SwitchParameter>]
Allows the cmdlet to clear a variable even if it is read-only. Even usi
ng the Force parameter, the cmdlet cannot clear constants.

-Include <string[]>
Clears only the specified items. The value of this parameter qualifies
the Name parameter. Enter a name element or pattern, such as "s*". Wild
cards are permitted.

-Name <string[]>
Specifies the name of the variable to be cleared. Wildcards are permitt
ed. This parameter is required, but the parameter name ("Name") is opti
onal.

-PassThru [<SwitchParameter>]
Returns an object representing the cleared variable. By default, this c
mdlet does not generate any output.

-Scope <string>
Specifies the scope in which this alias is valid. Valid values are "Glo
bal", "Local", or "Script", or a number relative to the current scope (
0 through the number of scopes, where 0 is the current scope and 1 is i
ts parent). "Local" is the default. For more information, see about_Sco
pes.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>clear-variable my* -global

Description
-----------
This command deletes the value of the global variables that begin with "my"
.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$a=3

C:\PS>&{ clear-variable a }

C:\PS>$a
3

Description
-----------
These commands demonstrate that clearing a variable in a child scope does n
ot clear the value in the parent scope. The first command sets the value of
the variable $a to "3". The second command uses the invoke operator (&) to
run a Clear-Variable command in a new scope. The variable is cleared in th
e child scope (although it did not exist), but it is not cleared in the loc
al scope. The third command, which gets the value of $a, shows that the val
ue "3" is unaffected.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>clear-variable -name processes

Description
-----------
This command deletes the value of the $processes variable. The $processes v
ariable still exists, but the value is null.




REMARKS
To see the examples, type: "get-help Clear-Variable -examples".
For more information, type: "get-help Clear-Variable -detailed".
For technical information, type: "get-help Clear-Variable -full".

NAME
Compare-Object

SYNOPSIS
Compares two sets of objects.


SYNTAX
Compare-Object [-ReferenceObject] <PSObject[]> [-DifferenceObject] <PSObjec
t[]> [-CaseSensitive] [-Culture <string>] [-ExcludeDifferent] [-IncludeEqua
l] [-PassThru] [-Property <Object[]>] [-SyncWindow <int>] [<CommonParameter
s>]


DESCRIPTION
The Compare-Object cmdlet compares two sets of objects. One set of objects
is the Reference set, and the other set is the Difference set.

The result of the comparison indicates whether a property value appeared on
ly in the object from the Reference set (indicated by the <= symbol), only
in the object from the Difference set (indicated by the => symbol) or, if t
he IncludeEqual parameter is specified, in both objects (indicated by the =
= symbol).

PARAMETERS
-CaseSensitive [<SwitchParameter>]
Indicates that comparisons should be case-sensitive.

-Culture <string>
Specifies the culture to use for comparisons.

-DifferenceObject <PSObject[]>
Specifies the objects that are compared to the reference objects.

-ExcludeDifferent [<SwitchParameter>]
Displays only the characteristics of compared objects that are equal.

-IncludeEqual [<SwitchParameter>]
Displays characteristics of compared objects that are equal. By default
, only characteristics that differ between the reference and difference
objects are displayed.

-PassThru [<SwitchParameter>]
Passes the objects that differed to the pipeline. By default, this cmdl
et does not generate any output.

-Property <Object[]>
Specifies the properties of the reference and difference objects to com
pare.

-ReferenceObject <PSObject[]>
Objects used as a reference for comparison.

-SyncWindow <int>
Defines a search region in which an attempt is made to re-synchronize t
he order if there is no match. The default value is [Int32]::MaxValue.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>compare-object -referenceobject $(get-content C:\test\testfile1.txt)
-differenceobject $(get-content C:\test\testfile2.txt)

Description
-----------
This command compares the contents of two text files. It displays only the
lines that appear in one file or in the other file, not lines that appear i
n both files.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>compare-object -referenceobject $(get-content C:\Test\testfile1.txt)
-differenceobject $(get-content C:\Test\testfile2.txt) -includeequal

Description
-----------
This command compares each line of content in two text files. It displays a
ll lines of content from both files, indicating whether each line appears i
n only Textfile1.txt or Textfile2.txt or whether each line appears in both
files.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$processes_before = get-process

C:\PS> notepad

C:\PS> $processes_after = get-process

C:\PS> compare-object -referenceobject $processes_before -differenceobject
$processes_after

Description
-----------
These commands compare two sets of process objects.

The first command uses the Get-Process cmdlet to get the processes on the c
omputer. It stores them in the $processes_before variable.

The second command starts Notepad.

The third command uses the Get-Process cmdlet again and stores the resultin
g processes in the $processes_after variable.

The fourth command uses the Compare-Object cmdlet to compare the two sets o
f process objects. It displaysthe differences between them, which include t
he new instance of Notepad.




REMARKS
To see the examples, type: "get-help Compare-Object -examples".
For more information, type: "get-help Compare-Object -detailed".
For technical information, type: "get-help Compare-Object -full".

NAME
Compare-Object

SYNOPSIS
Compares two sets of objects.


SYNTAX
Compare-Object [-ReferenceObject] <PSObject[]> [-DifferenceObject] <PSObjec
t[]> [-CaseSensitive] [-Culture <string>] [-ExcludeDifferent] [-IncludeEqua
l] [-PassThru] [-Property <Object[]>] [-SyncWindow <int>] [<CommonParameter
s>]


DESCRIPTION
The Compare-Object cmdlet compares two sets of objects. One set of objects
is the Reference set, and the other set is the Difference set.

The result of the comparison indicates whether a property value appeared on
ly in the object from the Reference set (indicated by the <= symbol), only
in the object from the Difference set (indicated by the => symbol) or, if t
he IncludeEqual parameter is specified, in both objects (indicated by the =
= symbol).

PARAMETERS
-CaseSensitive [<SwitchParameter>]
Indicates that comparisons should be case-sensitive.

-Culture <string>
Specifies the culture to use for comparisons.

-DifferenceObject <PSObject[]>
Specifies the objects that are compared to the reference objects.

-ExcludeDifferent [<SwitchParameter>]
Displays only the characteristics of compared objects that are equal.

-IncludeEqual [<SwitchParameter>]
Displays characteristics of compared objects that are equal. By default
, only characteristics that differ between the reference and difference
objects are displayed.

-PassThru [<SwitchParameter>]
Passes the objects that differed to the pipeline. By default, this cmdl
et does not generate any output.

-Property <Object[]>
Specifies the properties of the reference and difference objects to com
pare.

-ReferenceObject <PSObject[]>
Objects used as a reference for comparison.

-SyncWindow <int>
Defines a search region in which an attempt is made to re-synchronize t
he order if there is no match. The default value is [Int32]::MaxValue.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>compare-object -referenceobject $(get-content C:\test\testfile1.txt)
-differenceobject $(get-content C:\test\testfile2.txt)

Description
-----------
This command compares the contents of two text files. It displays only the
lines that appear in one file or in the other file, not lines that appear i
n both files.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>compare-object -referenceobject $(get-content C:\Test\testfile1.txt)
-differenceobject $(get-content C:\Test\testfile2.txt) -includeequal

Description
-----------
This command compares each line of content in two text files. It displays a
ll lines of content from both files, indicating whether each line appears i
n only Textfile1.txt or Textfile2.txt or whether each line appears in both
files.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$processes_before = get-process

C:\PS> notepad

C:\PS> $processes_after = get-process

C:\PS> compare-object -referenceobject $processes_before -differenceobject
$processes_after

Description
-----------
These commands compare two sets of process objects.

The first command uses the Get-Process cmdlet to get the processes on the c
omputer. It stores them in the $processes_before variable.

The second command starts Notepad.

The third command uses the Get-Process cmdlet again and stores the resultin
g processes in the $processes_after variable.

The fourth command uses the Compare-Object cmdlet to compare the two sets o
f process objects. It displaysthe differences between them, which include t
he new instance of Notepad.




REMARKS
To see the examples, type: "get-help Compare-Object -examples".
For more information, type: "get-help Compare-Object -detailed".
For technical information, type: "get-help Compare-Object -full".

NAME
Complete-Transaction

SYNOPSIS
Commits the active transaction.


SYNTAX
Complete-Transaction [-Confirm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Complete-Transaction cmdlet commits an active transaction. When you com
mit a transaction, the commands in the transaction are finalized and the da
ta affected by the commands is changed.

If the transaction includes multiple subscribers, to commit the transaction
, you must enter one Complete-Transaction command for every Start-Transacti
on command.

The Complete-Transaction cmdlet is one of a set of cmdlets that support the
transactions feature in Windows PowerShell. For more information, see abou
t_Transactions.

PARAMETERS
-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>cd hkcu:\software

PS HKCU:\software> start-transaction

PS HKCU:\software> new-item MyCompany -UseTransaction
PS HKCU:\software> dir m*

Hive: HKEY_CURRENT_USER\software

SKC VC Name Property
--- -- ---- --------
82 1 Microsoft {(default)}

PS HKCU:\software> complete-transaction
PS HKCU:\software> dir m*

Hive: HKEY_CURRENT_USER\Software

SKC VC Name Property
--- -- ---- --------
82 1 Microsoft {(default)}
0 0 MyCompany {}

Description
-----------
This example shows the effect of using the Complete-Transaction cmdlet to c
ommit a transaction.

The Start-Transaction command starts the transaction. The New-Item command
uses the UseTransaction parameter to include the command in the transaction
.

The first "dir" (Get-ChildItem) command shows that the new item has not yet
been added to the registry.

The Complete-Transaction command commits the transaction, which makes the r
egistry change effective. As a result, the second "dir" command shows that
the registry is changed.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>cd hkcu:\software

PS HKCU:\software> start-transaction
PS HKCU:\software> new-item MyCompany -UseTransaction

Hive: HKEY_CURRENT_USER\Software

SKC VC Name Property
--- -- ---- --------
0 0 MyCompany {}

PS HKCU:\software> start-transaction
PS HKCU:\Software> Get-Transaction

RollbackPreference SubscriberCount Status
------------------ --------------- ------
Error 2 Active

PS HKCU:\software> new-itemproperty -path MyCompany -name MyKey -value -Use
Transaction

MyKey
-----
123

PS HKCU:\software> complete-transaction
PS HKCU:\software> get-transaction

RollbackPreference SubscriberCount Status
------------------ --------------- ------
Error 1 Active

PS HKCU:\software> dir m*

Hive: HKEY_CURRENT_USER\Software

SKC VC Name Property
--- -- ---- --------
82 1 Microsoft {(default)}

PS HKCU:\software> complete-transaction
PS HKCU:\software> dir m*

Hive: HKEY_CURRENT_USER\Software

SKC VC Name Property
--- -- ---- --------
82 1 Microsoft {(default)}
0 1 MyCompany {MyKey}

Description
-----------
This example shows how to use Complete-Transaction to commit a transaction
that has more than one subscriber.

To commit a multi-subscriber transaction, you must enter one Complete-Trans
action command for every Start-Transaction command. The data is changed onl
y when the final Complete-Transaction command is submitted.

For demonstration purposes, this example shows a series of commands entered
at the command line. In practice, transactions are likely to be run in scr
ipts, with the secondary transaction being run by a function or helper scri
pt that is called by the main script.

In this example, a Start-Transaction command starts the transaction. A New-
Item command with the UseTransaction parameter adds the MyCompany key to th
e Software key. Although the New-Item command returns a key object, the dat
a in the registry is not yet changed.

A second Start-Transaction command adds a second subscriber to the existing
transaction. The Get-Transaction command confirms that the subscriber coun
t is 2. A New-ItemProperty command with the UseTransaction parameter adds a
registry entry to the new MyCompany key. Again, the command returns a valu
e, but the registry is not changed.

The first Complete-Transaction command reduces the subscriber count by 1. T
his is confirmed by a Get-Transaction command. However, no data is changed,
as evidenced by a "dir m*" (Get-ChildItem) command.

The second Complete-Transaction command commits the entire transaction and
changes the data in the registry. This is confirmed by a second "dir m*" co
mmand, which shows the changes.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>cd hkcu:\software

PS HKCU:\software> start-transaction

PS HKCU:\software> new-item MyCompany -UseTransaction

PS HKCU:\software> dir m*

Hive: HKEY_CURRENT_USER\Software

SKC VC Name Property
--- -- ---- --------
82 1 Microsoft {(default)}


PS HKCU:\software> dir m* -UseTransaction

Hive: HKEY_CURRENT_USER\Software

SKC VC Name Property
--- -- ---- --------
82 1 Microsoft {(default)}
0 0 MyCompany {}

PS HKCU:\software> complete-transaction

Description
-----------
This example shows the value of using Get-* commands, and other commands th
at do not change data, in a transaction. When a Get-* command is used in a
transaction, it gets the objects that are part of the transaction. This all
ows you to preview the changes in the transaction before the changes are co
mmitted.

In this example, a transaction is started. A New-Item command with the UseT
ransaction parameter adds a new key to the registry as part of the transact
ion.

Because the new registry key is not added to the registry until the Complet
e-Transaction command is run, a simple "dir" (Get-ChildItem) command shows
the registry without the new key.

However, when you add the UseTransaction parameter to the "dir" command, th
e command becomes part of the transaction, and it gets the items in the tra
nsaction even if they are not yet added to the data.




REMARKS
To see the examples, type: "get-help Complete-Transaction -examples".
For more information, type: "get-help Complete-Transaction -detailed".
For technical information, type: "get-help Complete-Transaction -full".

NAME
Connect-WSMan

SYNOPSIS
Connects to the WinRM service on a remote computer.


SYNTAX
Connect-WSMan [-ApplicationName <string>] [-ComputerName <string>] [-Port <
int>] [-UseSSL] [-Authentication <Authentication>] [-ComputerName <string>]
[-Credential <PSCredential>] [-Port <int>] [-SessionOption <hashtable>] [<
CommonParameters>]

Connect-WSMan [-ConnectionURI <Uri>] [-Authentication <Authentication>] [-C
omputerName <string>] [-Credential <PSCredential>] [-Port <int>] [-SessionO
ption <hashtable>] [<CommonParameters>]


DESCRIPTION
The Connect-WSMan cmdlet connects to the WinRM service on a remote computer
, and it establishes a persistent connection to the remote computer. You ca
n use this cmdlet within the context of the WS-Management provider to conne
ct to the WinRM service on a remote computer. However, you can also use thi
s cmdlet to connect to the WinRM service on a remote computer before you ch
ange to the WS-Management provider. The remote computer will appear in the
root directory of the WS-Management provider.

For more information about how to disconnect from the WinRM service on a re
mote computer, see Disconnect-WSMan.

PARAMETERS
-ApplicationName <string>
Specifies the application name in the connection. The default value of
the ApplicationName parameter is "WSMAN". The complete identifier for t
he remote endpoint is in the following format:
<transport>://<server>:<port>/<ApplicationName>
For example:
http://server01:8080/WSMAN

Internet Information Services (IIS), which hosts the session, forwards
requests with this endpoint to the specified application. This default
setting of "WSMAN" is appropriate for most uses. This parameter is desi
gned to be used when numerous computers establish remote connections to
one computer that is running Windows PowerShell. In this case, IIS hos
ts Web Services for Management (WS-Management) for efficiency.

-Authentication <Authentication>
Specifies the authentication mechanism to be used at the server. Possib
le values are:

- Basic: Basic is a scheme in which the user name and password are sent
in clear text to the server or proxy.
- Default : Use the authentication method implemented by the WS-Managem
ent protocol. This is the default.
- Digest: Digest is a challenge-response scheme that uses a server-spec
ified data string for the challenge.
- Kerberos: The client computer and the server mutually authenticate by
using Kerberos certificates.
- Negotiate: Negotiate is a challenge-response scheme that negotiates w
ith the server or proxy to determine the scheme to use for authenticati
on. For example, this parameter value allows negotiation to determine w
hether the Kerberos protocol or NTLM is used.
- CredSSP: Use Credential Security Service Provider (CredSSP) authentic
ation, which allows the user to delegate credentials. This option is de
signed for commands that run on one remote computer but collect data fr
om or run additional commands on other remote computers.

Caution: CredSSP delegates the user's credentials from the local comput
er to a remote computer. This practice increases the security risk of t
he remote operation. If the remote computer is compromised, when creden
tials are passed to it, the credentials can be used to control the netw
ork session.

-ComputerName <string>
Specifies the computer against which you want to run the management ope
ration. The value can be a fully qualified domain name, a NetBIOS name,
or an IP address. Use the local computer name, use localhost, or use a
dot (.) to specify the local computer. The local computer is the defau
lt. When the remote computer is in a different domain from the user, yo
u must use a fully qualified domain name must be used. You can pipe a v
alue for this parameter to the cmdlet.

-ConnectionURI <Uri>
Specifies the connection endpoint. The format of this string is:

<Transport>://<Server>:<Port>/<ApplicationName>.

The following string is a properly formatted value for this parameter:

http://Server01:8080/WSMAN. The URI must be fully qualified .

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user. Type a user name, such as "User01", "Dom
ain01\User01", or "User@Domain.com". Or, enter a PSCredential object, s
uch as one returned by the Get-Credential cmdlet. When you type a user
name, you will be prompted for a password.

-OptionSet <hashtable>
Passes a set of switches to the service to modify or refine the nature
of the request. These are similar to switches used in command-line she
lls in that they are service specific. Any number of options can be spe
cified.

The following example demonstrates the syntax that passes the values 1,
2, and 3 for the a, b, and c parameters:

-OptionSet @{a=1;b=2;c=3}

-Port <int>
Specifies the port to use when the client connects to the WinRM service
. When the transport is HTTP, the default port is 80. When the transpor
t is HTTPS, the default port is 443. When you use HTTPS as the transpor
t, the value of the ComputerName parameter must match the server's cert
ificate common name (CN). However, if the SkipCNCheck parameter is spec
ified as part of the SessionOption parameter, then the certificate comm
on name of the server does not have to match the host name of the serve
r. The SkipCNCheck parameter should be used only for trusted computers.

-SessionOption <hashtable>
Defines a set of extended options for the WS-Management session. Enter
a SessionOption object that you create by using the New-WSManSessionOpt
ion cmdlet. For more information about the options that are available,
see New-WSManSessionOption.

-UseSSL [<SwitchParameter>]
Specifies that the Secure Sockets Layer (SSL) protocol should be used t
o establish a connection to the remote computer. By default, SSL is not
used.

WS-Management encrypts all the Windows PowerShell content that is tran
smitted over the network. The UseSSL parameter lets you specify the add
itional protection of HTTPS instead of HTTP. If SSL is not available on
the port that is used for the connection and you specify this paramete
r, the command fails.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>Connect-WSMan -computer server01

PS C:\Users\testuser> cd wsman:
PS WSMan:\>
PS WSMan:\> dir


WSManConfig: Microsoft.WSMan.Management\WSMan::WSMan

ComputerName Type
------------ ----
localhost Container
server01 Container

Description
-----------
This command creates a connection to the remote server01 computer.

The Connect-WSMan cmdlet is generally used within the context of the WS-Man
agement provider to connect to a remote computer, in this case the server01
computer. However, you can use the cmdlet to establish connections to remo
te computers before you change to the WS-Management provider. Those connect
ions will appear in the ComputerName list.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$cred = Get-Credential Administrator
Connect-WSMan -computer server01 -credential $cred

PS C:\Users\testuser> cd wsman:
PS WSMan:\>
PS WSMan:\> dir


WSManConfig: Microsoft.WSMan.Management\WSMan::WSMan

ComputerName Type
------------ ----
localhost Container
server01 Container

Description
-----------
This command creates a connection to the remote system server01 using the A
dministrator account credentials.

The first command uses the Get-Credential cmdlet to get the Administrator c
redentials and then stores them in the $cred variable. The Get-Credential
cmdlet prompts the user for a password of username and password. Users are
prompted throught a dialog box
or at the command line, depending on system registry settings.

The second command uses the Credential parameter to pass the credentials st
ored in $cred to Connect-WSMan. Connect-WSMan then connects to the remote s
ystem server01 using the Administrator credentials.

The Connect-WSMan cmdlet is generally used within the context of the WS-Man
agement provider to connect to a remote computer, in this case server01. Ho
wever, the cmdlet can be used establish connections to remote computers bef
ore changing to the WS-Management provider and those connections will show
up in the ComputerName list.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>Connect-WSMan -computer server01 -port 80

PS C:\Users\testuser> cd wsman:
PS WSMan:\>
PS WSMan:\> dir


WSManConfig: Microsoft.WSMan.Management\WSMan::WSMan

ComputerName Type
------------ ----
localhost Container
server01 Container

Description
-----------
This command creates a connection to the remote server01 computer over port
80.

The Connect-WSMan cmdlet is generally used within the context of the WS-Man
agement provider to connect to a remote computer, in this case the server01
computer. However, you can use the cmdlet to establish connections to remo
te computers before you change to the WS-Management provider. Those connect
ions will appear in the ComputerName list.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$a = New-WSManSessionOption -operationtimeout 30000
Connect-WSMan -computer server01 -sessionoption $a

PS C:\Users\testuser> cd wsman:
PS WSMan:\>
PS WSMan:\> dir


WSManConfig: Microsoft.WSMan.Management\WSMan::WSMan

ComputerName Type
------------ ----
localhost Container
server01 Container

Description
-----------
This command creates a connection to the remote server01 computer by using
the connection options that are defined in the New-WSManSessionOption comma
nd.

The first command uses the New-WSManSessionOption cmdlet to store a set of
connection setting options in the $a variable. In this case, the session op
tions set a connection time out of 30 seconds (30,000 milliseconds).

The second command uses the SessionOption parameter to pass the credentials
that are stored in the $a variable to Connect-WSMan. Then, Connect-WSMan c
onnects to the remote server01 computer by using the specified session opti
ons.

The Connect-WSMan cmdlet is generally used within the context of the WS-Man
agement provider to connect to a remote computer, in this case the server01
computer. However, you can use the cmdlet to establish connections to remo
te computers before you change to the WS-Management provider. Those connect
ions will appear in the ComputerName list.




REMARKS
To see the examples, type: "get-help Connect-WSMan -examples".
For more information, type: "get-help Connect-WSMan -detailed".
For technical information, type: "get-help Connect-WSMan -full".

NAME
ConvertFrom-CSV

SYNOPSIS
Converts object properties in comma-separated value (CSV) format into CSV v
ersions of the original objects.


SYNTAX
ConvertFrom-CSV [[-Delimiter] <char>] [-InputObject] <PSObject[]> [-Header
<string[]>] [<CommonParameters>]

ConvertFrom-CSV -UseCulture [-InputObject] <PSObject[]> [-Header <string[]>
] [<CommonParameters>]


DESCRIPTION
The ConvertFrom-CSV cmdlet creates objects from CSV variable-length strings
that are generated by the ConvertTo-CSV cmdlet.

You can use the parameters of the ConvertFrom-CSV cmdlet to specify the col
umn header row, which determines the property names of the resulting object
s, to specify the item delimiter, or to direct ConvertFrom-CSV to use the l
ist separator for the current culture as the delimiter.

The objects that ConvertFrom-CSV creates are CSV versions of the original o
bjects. The property values of the CSV objects are string versions of the p
roperty values of the original objects. The CSV versions of the objects do
not have any methods.

You can also use the Export-CSV and Import-CSV cmdlets to convert objects t
o CSV strings in a file (and back). These cmdlets are the same as the Conve
rtTo-CSV and ConvertFrom-CSV cmdlets, except that they save the CSV strings
in a file.

PARAMETERS
-Delimiter <char>
Specifies the delimiter that separates the property values in the CSV s
trings. The default is a comma (,). Enter a character, such as a colon
(:). To specify a semicolon (;), enclose it in quotation marks.

If you specify a character other than the delimiter used in the CSV str
ings, ConvertFrom-CSV cannot create objects from the CSV strings. Inste
ad, it returns the strings.

-Header <string[]>
Specifies an alternate column header row for the imported string. The c
olumn header determines the names of the properties of the object that
ConvertFrom-CSV creates.

Enter a comma-separated list of the column headers. Enclose each item i
n quotation marks (single or double). Do not enclose the header string
in quotation marks. If you enter fewer column headers than there are co
lumns, the remaining columns will have no headers. If you enter more he
aders than there are columns, the extra headers are ignored.

When using the Header parameter, omit the column header string from the
CSV strings. Otherwise, ConvertFrom-CSV creates an extra object from t
he items in the header row.

-InputObject <PSObject[]>
Specifies the CSV strings to be converted to objects. Enter a variable
that contains the CSV strings or type a command or expression that gets
the CSV strings. You can also pipe the CSV strings to ConvertFrom-CSV.

-UseCulture [<SwitchParameter>]
Use the list separator for the current culture as the string delimiter.
The default is a comma (,).

To find the list separator for a culture, use the following command: (G
et-Culture).TextInfo.ListSeparator. If you specify a character other th
an the delimiter used in the CSV strings, ConvertFrom-CSV cannot create
objects from the CSV strings. Instead, it returns the strings.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$p = get-process | convertto-csv

C:\PS> $p | convertfrom-csv

Description
-----------
These commands convert the processes on the local computer into CSV format
and then restore them to object form.

The first command uses the Get-Process cmdlet to get the processes on the l
ocal computer. A pipeline operator (|) sends them to the ConvertTo-CSV cmdl
et, which converts the process object to CSV format. The CSV strings are sa
ved in the $p variable.

The second command uses a pipeline operator to send the CSV strings in the
$p variable to the ConvertFrom-CSV cmdlet. The cmdlet converts the CSV stri
ngs into CSV versions of the original process objects.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$date = get-date | convertto-csv -delimiter ";"

C:\PS> convertfrom-csv -inputobject $date -delimiter ";"

Description
-----------
These commands convert a data object to CSV format and then to CSV object f
ormat.

The first command uses the Get-Date cmdlet to get the current date and time
. A pipeline object (|) sends the date to the ConvertTo-CSV cmdlets, which
converts the date object to a series of CSV strings. The command uses the D
elimiter parameter to specify a semicolon delimiter. The strings are saved
in the $date variable.

The second command uses the ConvertFrom-CSV cmdlet to convert the CSV strin
gs in the $date variable back to object format. The command uses the InputO
bject parameter to specify the CSV strings and the Delimiter parameter to s
pecify the semicolon delimiter.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$j = start-job -scriptblock { get-process } | convertto-csv

C:\PS> $header = "MoreData","StatusMessage","Location","Command","State","F
inished","InstanceId","SessionId","Name","ChildJobs","Output","Error","Prog
ress","Verbose","Debug","Warning","StateChanged"

# Delete header from $j
C:\PS> $j = $j[0], $j[2..($j.count - 1)]

$j | convertfrom-csv -header $header

MoreData : True
StatusMessage :
Location : localhost
Command : get-process
State : Running
Finished : System.Threading.ManualResetEvent
InstanceId : 6fcb6578-7f42-4d93-9f23-9937f6aac1a2
SessionId : 1
Name : Job1
ChildJobs : System.Collections.Generic.List`1[System.Management.Automat
ion.Job]
Output : System.Management.Automation.PSDataCollection`1[System.Mana
gement.Automation.PSObject]
Error : System.Management.Automation.PSDataCollection`1[System.Mana
gement.Automation.ErrorRecord]
Progress : System.Management.Automation.PSDataCollection`1[System.Mana
gement.Automation.ProgressRecord]
Verbose : System.Management.Automation.PSDataCollection`1[System.Stri
ng]
Debug : System.Management.Automation.PSDataCollection`1[System.Stri
ng]
Warning : System.Management.Automation.PSDataCollection`1[System.Stri
ng]
StateChanged :

Description
-----------
This example shows how to use the Header parameter of ConvertFrom-Csv to ch
ange the names of properties in the resulting imported object.

The first command uses the Start-Job cmdlet to start a background job that
runs a Get-Process command on the local computer. A pipeline operator (|) s
ends the resulting job object to the ConvertTo-CSV cmdlet, which converts t
he job object to CSV format. An assignment operator (=) saves the resulting
CSV in the $j variable.

The second command saves a header in the $header variable. Unlike the defau
lt header, this header uses "MoreData" instead of "HasMoreData" and "State"
instead of "JobStateInfo".

The third command deletes the original header (the second line) from the CS
V strings and returns it to the $j variable.

The fourth command uses the ConvertFrom-CSV cmdlet to convert the CSV strin
gs to a CSV version of the job object. The command uses a pipeline operator
to send the content in $j to ConvertFrom-CSV. The resulting object has "Mo
reData" and "State" properties, as specified by the header.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>(get-culture).textinfo.listseparator

C:\PS> ConvertFrom-Csv -inputobject $services -UseCulture

Description
-----------
The command uses the ConvertFrom-CSV cmdlet to convert CSV strings of servi
ce objects that had been converted by the ConvertTo-CSV cmdlet. The command
uses the UseCulture parameter to direct ConvertFrom-CSV to use the delimit
er (list separator) of the current culture.

When using the UseCulture parameter, be sure that the list separator of the
current culture matches the delimiter used in the CSV strings. Otherwise,
ConvertFrom-CSV cannot generate objects from the CSV strings.

In this example, a Get-Culture command was used to verify the list separato
r, before the ConvertFrom-CSV command was used.




REMARKS
To see the examples, type: "get-help ConvertFrom-CSV -examples".
For more information, type: "get-help ConvertFrom-CSV -detailed".
For technical information, type: "get-help ConvertFrom-CSV -full".

NAME
ConvertFrom-SecureString

SYNOPSIS
Converts a secure string into an encrypted standard string.


SYNTAX
ConvertFrom-SecureString [-Key <Byte[]>] [-SecureString] <SecureString> [<C
ommonParameters>]

ConvertFrom-SecureString [[-SecureKey] <SecureString>] [-SecureString] <Sec
ureString> [<CommonParameters>]


DESCRIPTION
The ConvertFrom-SecureString cmdlet converts a secure string (System.Securi
ty.SecureString) into an encrypted standard string (System.String). Unlike
a secure string, an encrypted standard string can be saved in a file for la
ter use. The encrypted standard string can be converted back to its secure
string format by using the ConvertTo-SecureString cmdlet. If an encryption
key is specified by using the Key or SecureKey parameters, the Rijndael enc
ryption algorithm is used. The specified key must have a length of 128, 192
, or 256 bits because those are the key lengths supported by the Rijndael e
ncryption algorithm. If no key is specified, the Windows Data Protection AP
I (DPAPI) is used to encrypt the standard string representation.

PARAMETERS
-Key <Byte[]>
Specifies the encryption key as a byte array.

-SecureKey <SecureString>
Specifies the encryption key as a secure string. The secure string valu
e is converted to a byte array before being used as the key.

-SecureString <SecureString>
Specifies the secure string to convert to an encrypted standard string.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$securestring = read-host -assecurestring

Description
-----------
This command creates a secure string from characters that you type at the c
ommand prompt. After entering the command, type the string you want to stor
e as a secure string. An asterisk (*) will be displayed to represent each c
haracter that you type.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$standardstring = convertfrom-securestring $securestring

Description
-----------
This command converts the secure string in the $securestring variable to an
encrypted standard string. The resulting encrypted standard string is stor
ed in the $standardstring variable.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$key = (3,4,2,3,56,34,254,222,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,4
3)

C:\PS> $standardstring = convertfrom-securestring $securestring -key $key

Description
-----------
These commands use the Rijndael algorithm to convert the secure string stor
ed in the $securestring variable to an encrypted standard string with a 192
-bit key. The resulting encrypted standard string is stored in the $standar
dstring variable.

The first command stores a key in the $key variable. The key is an array of
24 digits, all of which are less than 256.

Because each digit represents a byte (8 bits), the key has 24 digits for a
total of 192 bits (8 x 24). This is a valid key length for the Rijndael alg
orithm. Each individual value is less than 256, which is the maximum value
that can be stored in an unsigned byte.

The second command uses the key in the $key variable to convert the secure
string to an encrypted standard string.




REMARKS
To see the examples, type: "get-help ConvertFrom-SecureString -examples".
For more information, type: "get-help ConvertFrom-SecureString -detailed".
For technical information, type: "get-help ConvertFrom-SecureString -full".

NAME
ConvertFrom-StringData

SYNOPSIS
Converts a string containing one or more key/value pairs to a hash table.


SYNTAX
ConvertFrom-StringData [-StringData] <string> [<CommonParameters>]


DESCRIPTION
The ConvertFrom-StringData cmdlet converts a string that contains one or mo
re key/value pairs into a hash table. Because each key/value pair must be
on a separate line, here-strings are often used as the input format.

The ConvertFrom-StringData cmdlet is considered to be a safe cmdlet that ca
n be used in the DATA section of a script or function. When used in a DATA
section, the contents of the string must conform to the rules for a DATA se
ction. For more information, see about_Data_Sections.

PARAMETERS
-StringData <string>
Specifies the string to be converted. You can use this parameter or pip
e a string to ConvertFrom-StringData. The parameter name is optional.

The value of this parameter must be a string that is enclosed in single
quotation marks (a single-quoted string) or a string that is enclosed
in double quotation marks (a double-quoted string) or a here-string con
taining one or more key/value pairs. Each key/value pair must be on a s
eparate line, or each pair must be separated by newline characters (`n)
.

You can include comments in the string, but the comments cannot be on t
he same line as a key/value pair. The comments are not included in the
hash table.

A here-string is a string consisting of one or more lines within which
quotation marks are interpreted literally. For more information, see ab
out_Quoting_Rules.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$here = @'
Msg1 = The string parameter is required.
Msg2 = Credentials are required for this command.
Msg3 = The specified variable does not exist.
'@

C:\PS> convertfrom-stringdata -stringdata $here

Name Value
---- -----
Msg3 The specified variable does not exist.
Msg2 Credentials are required for this command.
Msg1 The string parameter is required.

Description
-----------
These commands convert a single-quoted here-string of user messages into a
hash table. In a single-quoted string, values are not substituted for varia
bles and expressions are not evaluated.

The first command creates a here-string and saves it in the $here variable.


The second command uses the ConvertFrom-StringData cmdlet to convert the he
re-string in the $here variable to a hash table.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$p = @"
ISE = Windows PowerShell Integrated Scripting Environment
"@

C:\PS> $p | get-member

TypeName: System.String

Name MemberType Definition
---- ---------- ----------
Clone Method System.Object Clone()
...


C:\PS> $hash = convertfrom-stringdata -stringdata $p

C:\PS> $hash | get-member

TypeName: System.Collections.Hashtable

Name MemberType Definition
---- ---------- ----------
Add Method System.Void Add(Object key, Object
...

Description
-----------
These commands demonstrate that ConvertFrom-StringData actually converts a
here-string to a hash table.

The first command creates a double-quoted here-string that includes one key
/value" pair and saves it in the $p variable.

The second command uses a pipeline operator (|) to send the $p variable to
the Get-Member cmdlet. The result shows that $p is a string (System.String)
.

The third command uses the ConvertFrom-StringData cmdlet to convert the her
e-string in $p to a hash table. The command stores the result in the $hash
variable.

The final command uses a pipeline operator (|) to send the $hash variable t
o the Get-Member cmdlet. The result shows that the content of the $hash var
iable is a hash table (System.Collections.Hashtable).




-------------------------- EXAMPLE 3 --------------------------

C:\PS>convertfrom-stringdata -stringdata @'
Name = Disks.ps1
# Category is optional.
Category = Storage
Cost = Free
'@

Name Value
---- -----
Cost Free
Category Storage
Name Disks.ps1

Description
-----------
This command converts a single-quoted here-string that contains multiple ke
y/value pairs into a hash table.

In this command, the value of the StringData parameter is a here-string, in
stead of a variable that contains a here-string. Either format is valid.

The here-string includes a comment about one of the strings. Comments are v
alid in strings, provided that the comment is on a different line than a ke
y/value pair.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$a = convertfrom-stringdata -stringdata "Top = Red `n Bottom = Blue"

C:\PS> "Top = " + $a.Top
Top = Red

C:\PS> "Bottom = " + $a.Bottom
Bottom = Blue

Description
-----------
This example converts a regular double-quoted string (not a here-string) in
to a hash table and saves it in the $a variable.

To satisfy the condition that each key/value pair must be on a separate lin
e, it uses the Windows PowerShell newline character (`n) to separate the pa
irs.

The result is a hash table of the input. The remaining commands display the
output.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>$TextMsgs = DATA {
ConvertFrom-StringData @'
Text001 = The $Notebook variable contains the name of the user's sy
stem notebook.
Text002 = The $MyNotebook variable contains the name of the user's
private notebook.
'@
}

C:\PS> $TextMsgs.Text001
The $Notebook variable contains the name of the user's system notebook.


C:\PS> $TextMsgs.Text002
The $MyNotebook variable contains the name of the user's private notebook.

Description
-----------
This example shows a ConvertFrom-StringData command used in the DATA sectio
n of a script. The statements below the DATA section display the text to th
e user.

Because the text includes variable names, it must be enclosed in a single-q
uoted string so that the variables are interpreted literally and not expand
ed. Variables are not permitted in the DATA section.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>$here = @'
Msg1 = The string parameter is required.
Msg2 = Credentials are required for this command.
Msg3 = The specified variable does not exist.
'@

C:\PS> $hash = $here | convertfrom-stringdata

C:\PS> $hash

Name Value
---- -----
Msg3 The specified variable does not exist.
Msg2 Credentials are required for this command.
Msg1 The string parameter is required.

Description
-----------
This example shows that you can use a pipeline operator (|) to send a strin
g to ConvertFrom-StringData.

The first command saves a here-string in the $here variable. The second com
mand uses a pipeline operator (|) to send the $here variable to ConvertFrom
-StringData. The command saves the result in the $hash variable.

The final command displays the contents of the $hash variable.




REMARKS
To see the examples, type: "get-help ConvertFrom-StringData -examples".
For more information, type: "get-help ConvertFrom-StringData -detailed".
For technical information, type: "get-help ConvertFrom-StringData -full".

NAME
Convert-Path

SYNOPSIS
Converts a path from a Windows PowerShell path to a Windows PowerShell prov
ider path.


SYNTAX
Convert-Path [-LiteralPath] <string[]> [-UseTransaction] [<CommonParameters
>]

Convert-Path [-Path] <string[]> [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Convert-Path cmdlet converts a path from a Windows PowerShell path to a
Windows PowerShell provider path.

PARAMETERS
-LiteralPath <string[]>
Specifies the path to be converted. The value of the LiteralPath parame
ter is used exactly as it is typed. No characters are interpreted as wi
ldcards. If the path includes escape characters, enclose it in single q
uotation marks. Single quotation marks tell Windows PowerShell not to i
nterpret any characters as escape sequences.

-Path <string[]>
Specifies the Windows PowerShell path to be converted.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>convert-path ~

Description
-----------
This command expands the current working directory.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>convert-path HKLM:\software\microsoft

Description
-----------
This command converts the Windows PowerShell provider path to a standard re
gistry path.




REMARKS
To see the examples, type: "get-help Convert-Path -examples".
For more information, type: "get-help Convert-Path -detailed".
For technical information, type: "get-help Convert-Path -full".

NAME
ConvertTo-CSV

SYNOPSIS
Converts Microsoft .NET Framework objects into a series of comma-separated
value (CSV) variable-length strings.


SYNTAX
ConvertTo-CSV [[-Delimiter] <char>] [-InputObject] <psobject> [-NoTypeInfor
mation] [<CommonParameters>]

ConvertTo-CSV [-UseCulture] [-InputObject] <psobject> [-NoTypeInformation]
[<CommonParameters>]


DESCRIPTION
The ConvertTo-CSV cmdlet returns a series of comma-separated, variable-leng
th (CSV) strings that represents the objects that you submit. You can then
use the ConvertFrom-CSV cmdlet to re-create objects from the CSV strings. T
he resulting objects are CSV versions of the original objects that consist
of string representations of the property values and no methods.

You can also use the Export-CSV and Import-CSV cmdlets to convert .NET Fram
ework objects to CSV strings (and back). Export-CSV is the same as ConvertT
o-CSV, except that it saves the CSV strings in a file.

You can use the parameters of the ConvertTo-CSV cmdlet to specify a delimit
er other than a comma or to direct ConvertTo-CSV to use the default delimit
er for the current culture.

For more information, see Export-CSV, and see the Notes section.

PARAMETERS
-Delimiter <char>
Specifies a delimiter to separate the property values. The default is a
comma (,). Enter a character, such as a colon (:).

To specify a semicolon (;), enclose it in quotation marks. Otherwise, i
t will be interpreted as the command delimiter.

-InputObject <psobject>
Specifies the objects to export as CSV strings. Enter a variable that c
ontains the objects or type a command or expression that gets the objec
ts. You can also pipe objects to ConvertTo-CSV.

-NoTypeInformation [<SwitchParameter>]
Omits the type information header from the output. By default, the stri
ng in the output contains "#TYPE " followed by the fully-qualified name
of the type of the .NET Framework object.

-UseCulture [<SwitchParameter>]
Uses the list separator for the current culture as the data delimiter.
The default is a comma (,).

This parameter is very useful in scripts that are being distributed to
users worldwide. To find the list separator for a culture, use the foll
owing command: (Get-Culture).TextInfo.ListSeparator.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-process powershell | convertto-csv

#TYPE System.Diagnostics.Process
"__NounName","Name","Handles","VM","WS","PM","NPM","Path","Company","CPU","
FileVersion","ProductVersion","Description",
"Product","BasePriority","ExitCode","HasExited","ExitTime","Handle","Handle
Count","Id","MachineName","MainWindowHandle"
,"MainWindowTitle","MainModule","MaxWorkingSet","MinWorkingSet","Modules","
NonpagedSystemMemorySize","NonpagedSystemMem
orySize64","PagedMemorySize","PagedMemorySize64","PagedSystemMemorySize","P
agedSystemMemorySize64","PeakPagedMemorySize
","PeakPagedMemorySize64","PeakWorkingSet","PeakWorkingSet64","PeakVirtualM
emorySize","PeakVirtualMemorySize64","Priori
tyBoostEnabled","PriorityClass","PrivateMemorySize","PrivateMemorySize64","
PrivilegedProcessorTime","ProcessName","Proc
essorAffinity","Responding","SessionId","StartInfo","StartTime","Synchroniz
ingObject","Threads","TotalProcessorTime","U
serProcessorTime","VirtualMemorySize","VirtualMemorySize64","EnableRaisingE
vents","StandardInput","StandardOutput","Sta
ndardError","WorkingSet","WorkingSet64","Site","Container"
"Process","powershell","216","597544960","60399616","63197184","21692","C:\
WINDOWS\system32\WindowsPowerShell\v1.0\powe
rshell.exe","Microsoft Corporation","3.4788223","6.1.6587.1 (fbl_srv_powers
hell(nigels).070711-0102)","6.1.6587.1","Win
dows PowerShell","Microsoft® Windows® Operating System","8",,"False",,"860"
,"216","5132",".","5636936","Windows PowerSh
ell 2.0 (04/17/2008 00:10:40)","System.Diagnostics.ProcessModule (powershel
l.exe)","1413120","204800","System.Diagnosti
cs.ProcessModuleCollection","21692","21692","63197184","63197184","320080",
"320080","63868928","63868928","60715008","6
0715008","598642688","598642688","True","Normal","63197184","63197184","00:
00:00.2028013","powershell","15","True","1",
"System.Diagnostics.ProcessStartInfo","4/21/2008 3:49:19 PM",,"System.Diagn
ostics.ProcessThreadCollection","00:00:03.51
00225","00:00:03.3072212","597544960","597544960","False",,,,"60399616","60
399616",,

Description
-----------
This command converts a single process object to CSV format. The command us
es the Get-Process cmdlet to get the PowerShell process on the local comput
er. It uses a pipeline operator (|) to send the command to the ConvertTo-CS
V cmdlet, which converts it to a series of comma-separated strings.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$date = get-date

C:\PS> convertto-csv -inputobject $date -delimiter ";" -notypeinformation

Description
-----------
This example converts a date object to CSV format.

The first command uses the Get-Date cmdlet to get the current date. It save
s it in the $date variable.

The second command uses the ConvertTo-CSV cmdlet to convert the DateTime ob
ject in the $date variable to CSV format. The command uses the InputObject
parameter to specify the object to be converted. It uses the Delimiter para
meter to specify the delimiter that separates the object properties. It use
s the NoTypeInformation parameter to suppress the #TYPE string.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-eventlog -log "windows powershell" | convertto-csv -useculture

Description
-----------
This command converts the Windows PowerShell event log on the local compute
r to a series of CSV strings.

The command uses the Get-EventLog cmdlet to get the events in the Windows P
owerShell log. A pipeline operator (|) sends the events to the ConvertTo-CS
V cmdlet, which converts the events to CSV format. The command uses the Use
Culture parameter, which uses the list separator for the current culture as
the delimiter.




REMARKS
To see the examples, type: "get-help ConvertTo-CSV -examples".
For more information, type: "get-help ConvertTo-CSV -detailed".
For technical information, type: "get-help ConvertTo-CSV -full".

NAME
ConvertTo-Html

SYNOPSIS
Converts Microsoft .NET Framework objects into HTML that can be displayed i
n a Web browser.


SYNTAX
ConvertTo-Html [[-Head] <string[]>] [[-Title] <string>] [[-Body] <string[]>
] [-CssUri <Uri>] [[-Property] <Object[]>] [-As <string>] [-InputObject <ps
object>] [-PostContent <string[]>] [-PreContent <string[]>] [<CommonParamet
ers>]

ConvertTo-Html [-Fragment] [[-Property] <Object[]>] [-As <string>] [-InputO
bject <psobject>] [-PostContent <string[]>] [-PreContent <string[]>] [<Comm
onParameters>]


DESCRIPTION
The ConvertTo-Html cmdlet converts .NET Framework objects into HTML that ca
n be displayed in a Web browser. You can use this cmdlet to display the out
put of a command in a Web page.

You can use the parameters of ConvertTo-Html to select object properties, t
o specify a table or list format, to specify the HTML page title, to add te
xt before and after the object, and to return only the table or list fragme
nt, instead of a strict DTD page.

When you submit multiple objects to ConvertTo-Html, Windows PowerShell crea
tes the table (or list) based on the properties of the first object that yo
u submit. If the remaining objects do not have one of the specified propert
ies, the property value of that object is an empty cell. If the remaining o
bjects have additional properties, those property values are not included i
n the file.

PARAMETERS
-As <string>
Determines whether the object is formatted as a table or a list. Valid
values are TABLE and LIST. The default value is TABLE.

The TABLE value generates an HTML table that resembles the Windows Powe
rShell table format. The header row displays the property names. Each t
able row represents an object and displays the object's values for each
property.

The LIST value generates a two-column HTML table for each object that r
esembles the Windows PowerShell list format. The first column displays
the property name; the second column displays the property value.

-Body <string[]>
Specifies the text to add after the opening <BODY> tag. By default, the
re is no text in that position.

-CssUri <Uri>
Specifies the Uniform Resource Identifier (URI) of the cascading style
sheet (CSS) that is applied to the HTML file. The URI is included in a
style sheet link in the output.

-Fragment [<SwitchParameter>]
Generates only an HTML table. The HTML, HEAD, TITLE, and BODY tags are
omitted.

-Head <string[]>
Specifies the content of the <HEAD> tag. The default is "<title>HTML TA
BLE</title>". If you use the Head parameter, the Title parameter is ig
nored.

-InputObject <psobject>
Specifies the objects to be represented in HTML. Enter a variable that
contains the objects or type a command or expression that gets the obje
cts.

If you use this parameter to submit multiple objects, such as all of th
e services on a computer, ConvertTo-Html creates a table that displays
the properties of a collection or of an array of objects (System.Object
[]). To create a table of the individual objects, use the pipeline oper
ator to pipe the objects to ConvertTo-Html.

-PostContent <string[]>
Specifies text to add after the closing </TABLE> tag. By default, there
is no text in that position.

-PreContent <string[]>
Specifies text to add before the opening <TABLE> tag. By default, there
is no text in that position.

-Property <Object[]>
Includes the specified properties of the objects in the HTML.

-Title <string>
Specifies a title for the HTML file, that is, the text that appears bet
ween the <TITLE> tags.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>convertto-html -inputobject (get-date)

Description
-----------
This command creates an HTML page that displays the properties of the curre
nt date. It uses the InputObject parameter to submit the results of a Get-D
ate command to the ConvertTo-Html cmdlet.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-alias | convertto-html > aliases.htm

C:\PS> invoke-item aliases.htm

Description
-----------
This command creates an HTML page that lists the Windows PowerShell aliases
in the current console.

The command uses the Get-Alias cmdlet to get the aliases. It uses the pipel
ine operator (|) to send the aliases to the ConvertTo-Html cmdlet, which cr
eates the HTML page.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-eventlog -logname "Windows PowerShell | convertto-html > pslog.ht
m

Description
-----------
This command creates an HTML page called pslog.htm that displays the events
in the Windows PowerShell event log on the local computer.

It uses the Get-EventLog cmdlet to get the events in the Windows PowerShell
log and then uses the pipeline operator (|) to send the events to the Conv
ertTo-Html cmdlet.

The command also uses the redirection operator (>) to send the HTML code to
the pslog.htm file.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-process | convertto-html -property Name, Path, Company -title "Pr
ocess Information" > proc.htm; ii proc.htm

Description
-----------
These commands create and open an HTML page that lists the name, path, and
company of the processes on the local computer.

The first command uses the Get-Process cmdlet to get objects that represent
the processes running on the computer. The command uses the pipeline opera
tor (|) to send the process objects to the ConvertTo-Html cmdlet.

The command uses the Property parameter to select three properties of the p
rocess objects to be included in the table. The command uses the Title para
meter to specify a title for the HTML page. The command also uses the redir
ection operator (>) to send the resulting HTML to a file named Proc.htm.

The second command uses the Invoke-Item cmdlet (alias = ii) to open the Pro
c.htm in the default browser. The two commands are separated by a semicolon
(;).




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-service | convertto-html -CssUri "test.css"

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.
w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>HTML TABLE</title>
<link rel="stylesheet" type="text/css" href="test.css" />
...

Description
-----------
This command creates an HTML page of the service objects that the Get-Servi
ce cmdlet returns. The command uses the CssUri parameter to specify a casca
ding style sheet for the HTML page.

The CssUri parameter adds an additional "<link rel="stylesheet" type="text/
css" tag to the resulting HTML. The HREF attribute in the tag contains the
name of the style sheet.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-service | convertto-html -as LIST > services.htm

Description
-----------
This command creates an HTML page of the service objects that the Get-Servi
ce cmdlet returns. The command uses the As parameter to specify a list form
at. The redirection operator (>) sends the resulting HTML to the Services.h
tm file.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-date | cth -fragment

<table>
<colgroup>...</colgroup>
<tr><th>DisplayHint</th><th>DateTime</th><th>Date</th><th>Day</th><th>DayOf
Week</th><th>DayOfYear</th><th>Hour</th><th>
Kind</th><th>Millisecond</th><th>Minute</th><th>Month</th><th>Second</th><t
h>Ticks</th><th>TimeOfDay</th><th>Year</th><
/tr>
<tr><td>DateTime</td><td>Monday, May 05, 2008 10:40:04 AM</td><td>5/5/2008
12:00:00 AM</td><td>5</td><td>Monday</td><td
>126</td><td>10</td><td>Local</td><td>123</td><td>40</td><td>5</td><td>4</t
d><td>633455808041237213</td><td>10:40:04.12
37213</td><td>2008</td></tr>
</table>

Description
-----------
This command uses ConvertTo-Html to generate an HTML table of the current d
ate. The command uses the Get-Date cmdlet to get the current date. It uses
a pipeline operator (|) to send the results to the ConvertTo-Html cmdlet (a
liased as "cth").

The ConvertTo-Html command includes the Fragment parameter, which limits th
e output to an HTML table. As a result, the other elements of an HTML page,
such as the <HEAD> and <BODY> tags, are omitted.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>get-eventlog -log "Windows PowerShell" | convertto-html -property id,
level, task

Description
-----------
This command uses the Get-EventLog cmdlet to get events from the "Windows P
owerShell" event log.

It uses a pipeline operator (|) to send the events to the ConvertTo-Html cm
dlet, which converts the events to HTML format.

The ConvertTo-Html command uses the Property parameter to select only the I
D, Level, and Task properties of the event.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>get-service A* | ConvertTo-Html -title "Windows Services: Server01" -
body (get-date) -pre "<P>Generated by Corporate IT</P
>" -post "For details, contact Corporate IT." > services.htm; ii services.h
tm

Description
-----------
This command creates and opens a Web page that displays the services on the
computer that begin with "A". It uses the Title, Body, PreContent, and Pos
tContent parameters of ConvertTo-Html to customize the output.

The first part of the command uses the Get-Service cmdlet to get the servic
es on the computer that begin with "A". The command uses a pipeline operato
r (|) to send the results to the ConvertTo-Html cmdlet. The command uses a
redirection operator (>) to send the output to the Services.htm file.

A semicolon (;) ends the first command and starts a second command, which u
ses the Invoke-Item cmdlet (alias = "ii") to open the Services.htm file in
the default browser.




REMARKS
To see the examples, type: "get-help ConvertTo-Html -examples".
For more information, type: "get-help ConvertTo-Html -detailed".
For technical information, type: "get-help ConvertTo-Html -full".

NAME
ConvertTo-SecureString

SYNOPSIS
Converts encrypted standard strings to secure strings. It can also convert
plain text to secure strings. It is used with ConvertFrom-SecureString and
Read-Host.


SYNTAX
ConvertTo-SecureString [-Key <Byte[]>] [-String] <string> [<CommonParameter
s>]

ConvertTo-SecureString [[-AsPlainText]] [[-Force]] [-String] <string> [<Com
monParameters>]

ConvertTo-SecureString [[-SecureKey] <SecureString>] [-String] <string> [<C
ommonParameters>]


DESCRIPTION
The ConvertTo-SecureString cmdlet converts encrypted standard strings into
secure strings. It can also convert plain text to secure strings. It is use
d with ConvertFrom-SecureString and Read-Host. The secure string created by
the cmdlet can be used with cmdlets or functions that require a parameter
of type SecureString. The secure string can be converted back to an encrypt
ed, standard string using the ConvertFrom-SecureString cmdlet. This enables
it to be stored in a file for later use.

If the standard string being converted was encrypted with ConvertFrom-Secur
eString using a specified key, that same key must be provided as the value
of the Key or SecureKey parameter of the ConvertTo-SecureString cmdlet.

PARAMETERS
-AsPlainText [<SwitchParameter>]
Specifies a plain text string to convert to a secure string. The secure
string cmdlets help protect confidential text. The text is encrypted
for privacy and is deleted from computer memory after it is used. If yo
u use this parameter to provide plain text as input, the system cannot
protect that input in this manner. To use this parameter, you must al
so specify the Force parameter.

-Force [<SwitchParameter>]
Confirms that you understand the implications of using the AsPlainText
parameter and still want to use it.

-Key <Byte[]>
Specifies the encryption key to use when converting a secure string int
o an encrypted standard string. Valid key lengths are 16, 24, and 32 by
tes.

-SecureKey <SecureString>
Specifies the encryption key to use when converting a secure string int
o an encrypted standard string. The key must be provided in the format
of a secure string. The secure string is converted to a byte array befo
re being used as the key. Valid key lengths are 16, 24, and 32 bytes.

-String <string>
Specifies the string to convert to a secure string.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$secure = read-host -assecurestring

C:\PS> $secure
System.Security.SecureString

C:\PS> $encrypted = convertfrom-securestring -securestring $secure
C:\PS> $encrypted
01000000d08c9ddf0115d1118c7a00c04fc297eb010000001a114d45b8dd3f4aa11ad7c0abd
ae9800000000002000000000003660000a8000000100000005df63cea84bfb7d70bd6842e7
efa79820000000004800000a000000010000000f10cd0f4a99a8d5814d94e0687d7430b1000
00008bf11f1960158405b2779613e9352c6d14000000e6b7bf46a9d485ff211b9b2a2df3bd
6eb67aae41

C:\PS> $secure2 = convertto-securestring -string $encrypted
C:\PS> $secure2
System.Security.SecureString

Description
-----------
This example shows how to create a secure string from user input, convert t
he secure string to an encrypted standard string, and then convert the encr
ypted standard string back to a secure string.

The first command uses the AsSecureString parameter of the Read-Host cmdlet
to create a secure string. After you enter the command, any characters tha
t you type are converted into a secure string and then saved in the $secure
variable.

The second command displays the contents of the $secure variable. Because t
he $secure variable contains a secure string, Windows PowerShell displays o
nly the System.Security.SecureString type.

The third command uses the ConvertFrom-SecureString cmdlet to convert the s
ecure string in the $secure variable into an encrypted standard string. It
saves the result in the $encrypted variable. The fourth command displays th
e encrypted string in the value of the $encrypted variable.

The fifth command uses the ConvertTo-SecureString cmdlet to convert the enc
rypted standard string in the $encrypted variable back into a secure string
. It saves the result in the $secure2 variable. The sixth command displays
the value of the $secure2 variable. The SecureString type indicates that th
e command was successful.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$secure = read-host -assecurestring

C:\PS> $encrypted = convertfrom-securestring -secureString $secure -key (1.
.16)

C:\PS> $encrypted | set-content encrypted.txt

C:\PS> $secure2 = get-content encrypted.txt | convertto-securestring -key (
1..16)

Description
-----------
This example shows how to create a secure string from an encrypted standard
string that is saved in a file.

The first command uses the AsSecureString parameter of the Read-Host cmdlet
to create a secure string. After you enter the command, any characters tha
t you type are converted into a secure string and then saved in the $secure
variable.

The second command uses the ConvertFrom-SecureString cmdlet to convert the
secure string in the $secure variable into an encrypted standard string by
using the specified key. The contents are saved in the $encrypted variable.

The third command uses a pipeline operator (|) to send the value of the $en
crypted variable to the Set-Content cmdlet, which saves the value in the En
crypted.txt file.

The fourth command uses the Get-Content cmdlet to get the encrypted standar
d string in the Encrypted.txt file. The command uses a pipeline operator to
send the encrypted string to the ConvertTo-SecureString cmdlet, which conv
erts it to a secure string by using the specified key. The results are save
d in the $secure2 variable.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$secure_string_pwd = convertto-securestring "P@ssW0rD!" -asplaintext
-force

Description
-----------
This command converts the plain text string "P@ssW0rD!" into a secure strin
g and stores the result in the $secure_string_pwd variable. To use the AsPl
ainText parameter, the Force parameter must also be included in the command
.




REMARKS
To see the examples, type: "get-help ConvertTo-SecureString -examples".
For more information, type: "get-help ConvertTo-SecureString -detailed".
For technical information, type: "get-help ConvertTo-SecureString -full".

NAME
ConvertTo-XML

SYNOPSIS
Creates an XML-based representation of an object.


SYNTAX
ConvertTo-XML [-InputObject] <psobject> [-As <string>] [-Depth <int>] [-NoT
ypeInformation] [<CommonParameters>]


DESCRIPTION
The ConvertTo-Xml cmdlet creates an XML-based representation of one or more
Microsoft .NET Framework objects. To use this cmdlet, pipe one or more obj
ects to the cmdlet, or use the InputObject parameter to specify the object.


When you pipe multiple objects to ConvertTo-XML or use the InputObject para
meter to submit multiple objects, ConvertTo-XML returns a single XML docume
nt that includes representations of all of the objects.

This cmdlet is similar to Export-Clixml except that Export-Clixml stores th
e resulting XML in a file. ConvertTo-XML returns the XML, so you can contin
ue to process it in Windows PowerShell.

PARAMETERS
-As <string>
Determines the output format. Valid values are:

-- String: Returns a single string.
-- Stream: Returns an array of strings.
-- Document: Returns an XmlDocument object.

Stream is the default.

-Depth <int>
Specifies how many levels of contained objects are included in the XML
representation. The default value is 1.

For example, if the object's properties also contain objects, to save a
n XML representation of the properties of the contained objects, you mu
st specify a depth of 2.

The default value can be overridden for the object type in the Types.ps
1xml files. For more information, see about_Types.ps1xml.

-InputObject <psobject>
Specifies the object to be converted. Enter a variable that contains th
e objects, or type a command or expression that gets the objects. You c
an also pipe objects to ConvertTo-XML.

-NoTypeInformation [<SwitchParameter>]
Omits the Type attribute from the object nodes.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-date | convertto-xml

Description
-----------
This command converts the current date (a DateTime object) to XML.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>convertto-xml -as Document -inputObject (get-process) -depth 3

Description
-----------
This command converts the process objects that represent all of the process
es on the computer into an XML document. The objects are expanded to a dept
h of three levels.




REMARKS
To see the examples, type: "get-help ConvertTo-XML -examples".
For more information, type: "get-help ConvertTo-XML -detailed".
For technical information, type: "get-help ConvertTo-XML -full".

NAME
Copy-Item

SYNOPSIS
Copies an item from one location to another within a namespace.


SYNTAX
Copy-Item [-LiteralPath] <string[]> [[-Destination] <string>] [-Container]
[-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-For
ce] [-Include <string[]>] [-PassThru] [-Recurse] [-Confirm] [-WhatIf] [-Use
Transaction] [<CommonParameters>]

Copy-Item [-Path] <string[]> [[-Destination] <string>] [-Container] [-Crede
ntial <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-I
nclude <string[]>] [-PassThru] [-Recurse] [-Confirm] [-WhatIf] [-UseTransac
tion] [<CommonParameters>]


DESCRIPTION
The Copy-Item cmdlet copies an item from one location to another in a names
pace. Copy-Item does not delete the items being copied. The particular item
s that the cmdlet can copy depend on the Windows PowerShell providers avail
able. For example, when used with the FileSystem provider, it can copy file
s and directories and when used with the Registry provider, it can copy reg
istry keys and entries.

PARAMETERS
-Container [<SwitchParameter>]
Preserves container objects during the copy operation.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Destination <string>
Specifies the path to the location where the items are to be copied.

-Exclude <string[]>
Omits the specified items. Wildcards are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to copy items that cannot otherwise be changed, such
as copying over a read-only file or alias.

-Include <string[]>
Specifies only those items upon which the cmdlet will act, excluding al
l others.

-LiteralPath <string[]>
Specifies a path to the item. The value of the LiteralPath parameter is
used exactly as it is typed. No characters are interpreted as wildcard
s. If the path includes escape characters, enclose it in single quotati
on marks. Single quotation marks tell Windows PowerShell not to interpr
et any characters as escape sequences.

-PassThru [<SwitchParameter>]
Returns an object representing each copied item. By default, this cmdle
t does not generate any output.

-Path <string[]>
Specifies the path to the items to copy.

-Recurse [<SwitchParameter>]
Specifies a recursive copy.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>copy-item C:\Wabash\Logfiles\mar1604.log.txt -destination C:\Presenta
tion

Description
-----------
This command will copy the file mar1604.log.txt to the C:\Presentation dire
ctory. The command does not delete the original file.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>copy-item C:\Logfiles -destination C:\Drawings -recurse

Description
-----------
This command copies the entire contents of the Logfiles directory into the
Drawings directory. If the source directory contains files in subdirectorie
s, those subdirectories will be copied with their file trees intact. The Co
ntainer parameter is set to true by default. This preserves the directory s
tructure.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>copy-item C:\Logfiles -destination C:\Drawings\Logs -recurse

Description
-----------
This command copies the contents of the C:\Logfiles directory to the C:\Dra
wings\Logs directory. It will create the subdirectory \Logs if it does not
already exist.




REMARKS
To see the examples, type: "get-help Copy-Item -examples".
For more information, type: "get-help Copy-Item -detailed".
For technical information, type: "get-help Copy-Item -full".

NAME
Copy-Item

SYNOPSIS
Copies an item from one location to another within a namespace.


SYNTAX
Copy-Item [-LiteralPath] <string[]> [[-Destination] <string>] [-Container]
[-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-For
ce] [-Include <string[]>] [-PassThru] [-Recurse] [-Confirm] [-WhatIf] [-Use
Transaction] [<CommonParameters>]

Copy-Item [-Path] <string[]> [[-Destination] <string>] [-Container] [-Crede
ntial <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-I
nclude <string[]>] [-PassThru] [-Recurse] [-Confirm] [-WhatIf] [-UseTransac
tion] [<CommonParameters>]


DESCRIPTION
The Copy-Item cmdlet copies an item from one location to another in a names
pace. Copy-Item does not delete the items being copied. The particular item
s that the cmdlet can copy depend on the Windows PowerShell providers avail
able. For example, when used with the FileSystem provider, it can copy file
s and directories and when used with the Registry provider, it can copy reg
istry keys and entries.

PARAMETERS
-Container [<SwitchParameter>]
Preserves container objects during the copy operation.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Destination <string>
Specifies the path to the location where the items are to be copied.

-Exclude <string[]>
Omits the specified items. Wildcards are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to copy items that cannot otherwise be changed, such
as copying over a read-only file or alias.

-Include <string[]>
Specifies only those items upon which the cmdlet will act, excluding al
l others.

-LiteralPath <string[]>
Specifies a path to the item. The value of the LiteralPath parameter is
used exactly as it is typed. No characters are interpreted as wildcard
s. If the path includes escape characters, enclose it in single quotati
on marks. Single quotation marks tell Windows PowerShell not to interpr
et any characters as escape sequences.

-PassThru [<SwitchParameter>]
Returns an object representing each copied item. By default, this cmdle
t does not generate any output.

-Path <string[]>
Specifies the path to the items to copy.

-Recurse [<SwitchParameter>]
Specifies a recursive copy.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>copy-item C:\Wabash\Logfiles\mar1604.log.txt -destination C:\Presenta
tion

Description
-----------
This command will copy the file mar1604.log.txt to the C:\Presentation dire
ctory. The command does not delete the original file.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>copy-item C:\Logfiles -destination C:\Drawings -recurse

Description
-----------
This command copies the entire contents of the Logfiles directory into the
Drawings directory. If the source directory contains files in subdirectorie
s, those subdirectories will be copied with their file trees intact. The Co
ntainer parameter is set to true by default. This preserves the directory s
tructure.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>copy-item C:\Logfiles -destination C:\Drawings\Logs -recurse

Description
-----------
This command copies the contents of the C:\Logfiles directory to the C:\Dra
wings\Logs directory. It will create the subdirectory \Logs if it does not
already exist.




REMARKS
To see the examples, type: "get-help Copy-Item -examples".
For more information, type: "get-help Copy-Item -detailed".
For technical information, type: "get-help Copy-Item -full".

NAME
Copy-ItemProperty

SYNOPSIS
Copies a property and value from a specified location to another location.


SYNTAX
Copy-ItemProperty [-LiteralPath] <string[]> [-Destination] <string> [-Name]
<string> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <stri
ng>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseT
ransaction] [<CommonParameters>]

Copy-ItemProperty [-Path] <string[]> [-Destination] <string> [-Name] <strin
g> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-
Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransact
ion] [<CommonParameters>]


DESCRIPTION
The Copy-ItemProperty cmdlet copies a property and value from a specified l
ocation to another location. For example, you can use Copy-ItemProperty to
copy one or more registry entries from one registry key to another registry
key.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Destination <string>
Specifies the path to the destination location.

-Exclude <string[]>
Omits the specified items. Wildcards are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to override restrictions such as renaming existing fi
les as long as security is not compromised.

-Include <string[]>
Specifies only those items upon which the cmdlet will act, excluding al
l others.

-LiteralPath <string[]>
Specifies a path to the item property. The value of LiteralPath is used
exactly as it is typed. No characters are interpreted as wildcards. If
the path includes escape characters, enclose it in single quotation ma
rks. Single quotation marks tell Windows PowerShell not to interpret an
y characters as escape sequences.

-Name <string>
Specifies the name of the property to be copied.

-PassThru [<SwitchParameter>]
Returns an object representing the copied item property. By default, th
is cmdlet does not generate any output.

-Path <string[]>
Specifies the path to the property to be copied.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>copy-itemproperty -path MyApplication -destination HKLM:\Software\MyA
pplicationRev2 -name MyProperty

Description
-----------
This command copies the property named MyProperty from the MyApplication re
gistry key to the MyApplicationRev2 registry key.




REMARKS
To see the examples, type: "get-help Copy-ItemProperty -examples".
For more information, type: "get-help Copy-ItemProperty -detailed".
For technical information, type: "get-help Copy-ItemProperty -full".

NAME
Copy-Item

SYNOPSIS
Copies an item from one location to another within a namespace.


SYNTAX
Copy-Item [-LiteralPath] <string[]> [[-Destination] <string>] [-Container]
[-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-For
ce] [-Include <string[]>] [-PassThru] [-Recurse] [-Confirm] [-WhatIf] [-Use
Transaction] [<CommonParameters>]

Copy-Item [-Path] <string[]> [[-Destination] <string>] [-Container] [-Crede
ntial <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-I
nclude <string[]>] [-PassThru] [-Recurse] [-Confirm] [-WhatIf] [-UseTransac
tion] [<CommonParameters>]


DESCRIPTION
The Copy-Item cmdlet copies an item from one location to another in a names
pace. Copy-Item does not delete the items being copied. The particular item
s that the cmdlet can copy depend on the Windows PowerShell providers avail
able. For example, when used with the FileSystem provider, it can copy file
s and directories and when used with the Registry provider, it can copy reg
istry keys and entries.

PARAMETERS
-Container [<SwitchParameter>]
Preserves container objects during the copy operation.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Destination <string>
Specifies the path to the location where the items are to be copied.

-Exclude <string[]>
Omits the specified items. Wildcards are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to copy items that cannot otherwise be changed, such
as copying over a read-only file or alias.

-Include <string[]>
Specifies only those items upon which the cmdlet will act, excluding al
l others.

-LiteralPath <string[]>
Specifies a path to the item. The value of the LiteralPath parameter is
used exactly as it is typed. No characters are interpreted as wildcard
s. If the path includes escape characters, enclose it in single quotati
on marks. Single quotation marks tell Windows PowerShell not to interpr
et any characters as escape sequences.

-PassThru [<SwitchParameter>]
Returns an object representing each copied item. By default, this cmdle
t does not generate any output.

-Path <string[]>
Specifies the path to the items to copy.

-Recurse [<SwitchParameter>]
Specifies a recursive copy.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>copy-item C:\Wabash\Logfiles\mar1604.log.txt -destination C:\Presenta
tion

Description
-----------
This command will copy the file mar1604.log.txt to the C:\Presentation dire
ctory. The command does not delete the original file.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>copy-item C:\Logfiles -destination C:\Drawings -recurse

Description
-----------
This command copies the entire contents of the Logfiles directory into the
Drawings directory. If the source directory contains files in subdirectorie
s, those subdirectories will be copied with their file trees intact. The Co
ntainer parameter is set to true by default. This preserves the directory s
tructure.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>copy-item C:\Logfiles -destination C:\Drawings\Logs -recurse

Description
-----------
This command copies the contents of the C:\Logfiles directory to the C:\Dra
wings\Logs directory. It will create the subdirectory \Logs if it does not
already exist.




REMARKS
To see the examples, type: "get-help Copy-Item -examples".
For more information, type: "get-help Copy-Item -detailed".
For technical information, type: "get-help Copy-Item -full".

NAME
Copy-Item

SYNOPSIS
Copies an item from one location to another within a namespace.


SYNTAX
Copy-Item [-LiteralPath] <string[]> [[-Destination] <string>] [-Container]
[-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-For
ce] [-Include <string[]>] [-PassThru] [-Recurse] [-Confirm] [-WhatIf] [-Use
Transaction] [<CommonParameters>]

Copy-Item [-Path] <string[]> [[-Destination] <string>] [-Container] [-Crede
ntial <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-I
nclude <string[]>] [-PassThru] [-Recurse] [-Confirm] [-WhatIf] [-UseTransac
tion] [<CommonParameters>]


DESCRIPTION
The Copy-Item cmdlet copies an item from one location to another in a names
pace. Copy-Item does not delete the items being copied. The particular item
s that the cmdlet can copy depend on the Windows PowerShell providers avail
able. For example, when used with the FileSystem provider, it can copy file
s and directories and when used with the Registry provider, it can copy reg
istry keys and entries.

PARAMETERS
-Container [<SwitchParameter>]
Preserves container objects during the copy operation.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Destination <string>
Specifies the path to the location where the items are to be copied.

-Exclude <string[]>
Omits the specified items. Wildcards are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to copy items that cannot otherwise be changed, such
as copying over a read-only file or alias.

-Include <string[]>
Specifies only those items upon which the cmdlet will act, excluding al
l others.

-LiteralPath <string[]>
Specifies a path to the item. The value of the LiteralPath parameter is
used exactly as it is typed. No characters are interpreted as wildcard
s. If the path includes escape characters, enclose it in single quotati
on marks. Single quotation marks tell Windows PowerShell not to interpr
et any characters as escape sequences.

-PassThru [<SwitchParameter>]
Returns an object representing each copied item. By default, this cmdle
t does not generate any output.

-Path <string[]>
Specifies the path to the items to copy.

-Recurse [<SwitchParameter>]
Specifies a recursive copy.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>copy-item C:\Wabash\Logfiles\mar1604.log.txt -destination C:\Presenta
tion

Description
-----------
This command will copy the file mar1604.log.txt to the C:\Presentation dire
ctory. The command does not delete the original file.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>copy-item C:\Logfiles -destination C:\Drawings -recurse

Description
-----------
This command copies the entire contents of the Logfiles directory into the
Drawings directory. If the source directory contains files in subdirectorie
s, those subdirectories will be copied with their file trees intact. The Co
ntainer parameter is set to true by default. This preserves the directory s
tructure.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>copy-item C:\Logfiles -destination C:\Drawings\Logs -recurse

Description
-----------
This command copies the contents of the C:\Logfiles directory to the C:\Dra
wings\Logs directory. It will create the subdirectory \Logs if it does not
already exist.




REMARKS
To see the examples, type: "get-help Copy-Item -examples".
For more information, type: "get-help Copy-Item -detailed".
For technical information, type: "get-help Copy-Item -full".

NAME
Copy-ItemProperty

SYNOPSIS
Copies a property and value from a specified location to another location.


SYNTAX
Copy-ItemProperty [-LiteralPath] <string[]> [-Destination] <string> [-Name]
<string> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <stri
ng>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseT
ransaction] [<CommonParameters>]

Copy-ItemProperty [-Path] <string[]> [-Destination] <string> [-Name] <strin
g> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-
Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransact
ion] [<CommonParameters>]


DESCRIPTION
The Copy-ItemProperty cmdlet copies a property and value from a specified l
ocation to another location. For example, you can use Copy-ItemProperty to
copy one or more registry entries from one registry key to another registry
key.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Destination <string>
Specifies the path to the destination location.

-Exclude <string[]>
Omits the specified items. Wildcards are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to override restrictions such as renaming existing fi
les as long as security is not compromised.

-Include <string[]>
Specifies only those items upon which the cmdlet will act, excluding al
l others.

-LiteralPath <string[]>
Specifies a path to the item property. The value of LiteralPath is used
exactly as it is typed. No characters are interpreted as wildcards. If
the path includes escape characters, enclose it in single quotation ma
rks. Single quotation marks tell Windows PowerShell not to interpret an
y characters as escape sequences.

-Name <string>
Specifies the name of the property to be copied.

-PassThru [<SwitchParameter>]
Returns an object representing the copied item property. By default, th
is cmdlet does not generate any output.

-Path <string[]>
Specifies the path to the property to be copied.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>copy-itemproperty -path MyApplication -destination HKLM:\Software\MyA
pplicationRev2 -name MyProperty

Description
-----------
This command copies the property named MyProperty from the MyApplication re
gistry key to the MyApplicationRev2 registry key.




REMARKS
To see the examples, type: "get-help Copy-ItemProperty -examples".
For more information, type: "get-help Copy-ItemProperty -detailed".
For technical information, type: "get-help Copy-ItemProperty -full".

NAME
Convert-Path

SYNOPSIS
Converts a path from a Windows PowerShell path to a Windows PowerShell prov
ider path.


SYNTAX
Convert-Path [-LiteralPath] <string[]> [-UseTransaction] [<CommonParameters
>]

Convert-Path [-Path] <string[]> [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Convert-Path cmdlet converts a path from a Windows PowerShell path to a
Windows PowerShell provider path.

PARAMETERS
-LiteralPath <string[]>
Specifies the path to be converted. The value of the LiteralPath parame
ter is used exactly as it is typed. No characters are interpreted as wi
ldcards. If the path includes escape characters, enclose it in single q
uotation marks. Single quotation marks tell Windows PowerShell not to i
nterpret any characters as escape sequences.

-Path <string[]>
Specifies the Windows PowerShell path to be converted.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>convert-path ~

Description
-----------
This command expands the current working directory.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>convert-path HKLM:\software\microsoft

Description
-----------
This command converts the Windows PowerShell provider path to a standard re
gistry path.




REMARKS
To see the examples, type: "get-help Convert-Path -examples".
For more information, type: "get-help Convert-Path -detailed".
For technical information, type: "get-help Convert-Path -full".

D:

NAME
Disable-PSBreakpoint

SYNOPSIS
Disables the breakpoints in the current console.


SYNTAX
Disable-PSBreakpoint [-Id] <Int32[]> [-PassThru] [-Confirm] [-WhatIf] [<Com
monParameters>]

Disable-PSBreakpoint [-Breakpoint] <Breakpoint[]> [-PassThru] [-Confirm] [-
WhatIf] [<CommonParameters>]


DESCRIPTION
The Disable-PSBreakpoint cmdlet disables breakpoints, which assures that th
ey are not hit when the script runs. You can use it to disable all breakpoi
nts, or you can specify breakpoints by submitting breakpoint objects or bre
akpoint IDs.

Technically, this cmdlet changes the value of the Enabled property of a bre
akpoint object to False. To re-enable a breakpoint, use the Enable-PSBreakp
oint cmdlet. Breakpoints are enabled by default when you create them by usi
ng the Set-PSBreakpoint cmdlet.

A breakpoint is a point in a script where execution stops temporarily so th
at you can examine the instructions in the script. Disable-PSBreakpoint is
one of several cmdlets designed for debugging Windows PowerShell scripts. F
or more information about the Windows PowerShell debugger, see about_Debugg
ers.

PARAMETERS
-Breakpoint <Breakpoint[]>
Specifies the breakpoints to disable. Enter a variable that contains br
eakpoint objects or a command that gets breakpoint objects, such as a G
et-PSBreakpoint command. You can also pipe breakpoint objects to the Di
sable-PSBreakpoint cmdlet.

-Id <Int32[]>
Disables the breakpoints with the specified breakpoint IDs. Enter the I
Ds or a variable that contains the IDs. You cannot pipe IDs to Disable-
PSBreakpoint.

-PassThru [<SwitchParameter>]
Returns an object representing the enabled breakpoints. By default, thi
s cmdlet does not generate any output.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$b = set-psbreakpoint -script sample.ps1 -variable name

C:\PS> $b | disable-psbreakpoint

Description
-----------
These commands disable a newly-created breakpoint.

The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint o
n the Name variable in the Sample.ps1 script. Then, it saves the breakpoint
object in the $b variable.

The second command uses the Disable-PSBreakpoint cmdlet to disable the new
breakpoint. It uses a pipeline operator (|) to send the breakpoint object i
n $b to the Disable-PSBreakpoint cmdlet.

As a result of this command, the value of the Enabled property of the break
point object in $b is False.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>disable-psbreakpoint -id 0

Description
-----------
This command disables the breakpoint with breakpoint ID 0.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>disable-psbreakpoint -breakpoint ($b = set-psbreakpoint -script sampl
e.ps1 -line 5)

C:\PS> $b

Description
-----------
This command creates a new breakpoint that is disabled until you enable it.

It uses the Disable-PSBreakpoint cmdlet to disable the breakpoint. The valu
e of the Breakpoint parameter is a Set-PSBreakpoint command that sets a new
breakpoint, generates a breakpoint object, and saves the object in the $b
variable.

Cmdlet parameters that take objects as their values can accept a variable t
hat contains the object or a command that gets or generates the object. In
this case, because Set-PSBreakpoint generates a breakpoint object, it can b
e used as the value of the Breakpoint parameter.

The second command displays the breakpoint object in the value of the $b va
riable.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-psbreakpoint | disable-psbreakpoint

Description
-----------
This command disables all breakpoints in the current console. You can abbre
viate this command as: "gbp | dbp".




REMARKS
To see the examples, type: "get-help Disable-PSBreakpoint -examples".
For more information, type: "get-help Disable-PSBreakpoint -detailed".
For technical information, type: "get-help Disable-PSBreakpoint -full".

NAME
Debug-Process

SYNOPSIS
Debugs one or more processes running on the local computer.


SYNTAX
Debug-Process [-Name] <string[]> [-Confirm] [-WhatIf] [<CommonParameters>]

Debug-Process [-Id] <Int32[]> [-Confirm] [-WhatIf] [<CommonParameters>]

Debug-Process -InputObject <Process[]> [-Confirm] [-WhatIf] [<CommonParamet
ers>]


DESCRIPTION
The Debug-Process cmdlet attaches a debugger to one or more running process
es on a local computer. You can specify the processes by their process name
or process ID (PID), or you can pipe process objects to Debug-Process.

Debug-Process attaches the debugger that is currently registered for the pr
ocess. Before using this cmdlet, verify that a debugger is downloaded and c
orrectly configured.

PARAMETERS
-Id <Int32[]>
Specifies the process IDs of the processes to be debugged. The paramete
r name ("-Id") is optional.

To find the process ID of a process, type "get-process".

-InputObject <Process[]>
Specifies the process objects that represent processes to be debugged.
Enter a variable that contains the process objects or a command that ge
ts the process objects, such as a Get-Process command. You can also pip
e process objects to Debug-Process.

-Name <string[]>
Specifies the names of the processes to be debugged. If there is more t
han one process with the same name, Debug-Process attaches a debugger t
o all processes with that name. The parameter name ("Name") is optiona
l.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>debug-process -name powershell

Description
-----------
This command attaches a debugger to the PowerShell process on the computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>debug-process -name sql*

Description
-----------
This command attaches a debugger to all processes that have names that begi
n with "sql".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>debug-process winlogon, explorer, outlook

Description
-----------
This command attaches a debugger to the Winlogon, Explorer, and Outlook pro
cesses.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>debug-process -id 1132, 2028

Description
-----------
This command attaches a debugger to the processes that have process IDs 113
2 and 2028.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-process powershell | debug-process

Description
-----------
This command attaches a debugger to the PowerShell processes on the compute
r. It uses the Get-Process cmdlet to get the PowerShell processes on the co
mputer, and it uses a pipeline operator (|) to send the processes to the De
bug-Process cmdlet.

To specify a particular PowerShell process, use the ID parameter of Get-Pro
cess.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>$pid | debug-process

Description
-----------
This command attaches a debugger to the current PowerShell processes on the
computer.

It uses the $pid automatic variable, which contains the process ID of the c
urrent PowerShell process. Then, it uses a pipeline operator (|) to send th
e process ID to the Debug-Process cmdlet.

For more information about the $pid automatic variable, see about_Automatic
_Variables.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-process -computername Server01, Server02 -name MyApp | debug-proc
ess

Description
-----------
This command attaches a debugger to the MyApp processes on the Server01 and
Server02 computers.

It uses the Get-Process cmdlet to get the MyApp processes on the Server01 a
nd Server02 computers. It uses a pipeline operator to send the processes to
the Debug-Process cmdlet, which attaches the debuggers.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>$p = get-process powershell

C:\PS> debug-process -inputobject $p

Description
-----------
This command attaches a debugger to the PowerShell processes on the local c
omputer.

The first command uses the Get-Process cmdlet to get the PowerShell process
es on the computer. It saves the resulting process object in the $p variabl
e.

The second command uses the InputObject parameter of Debug-Process to submi
t the process object in the $p variable to Debug-Process.




REMARKS
To see the examples, type: "get-help Debug-Process -examples".
For more information, type: "get-help Debug-Process -detailed".
For technical information, type: "get-help Debug-Process -full".

NAME
Remove-Item

SYNOPSIS
Deletes the specified items.


SYNTAX
Remove-Item [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Exclud
e <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Recurse]
[-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

Remove-Item [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <stri
ng[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Recurse] [-Confi
rm] [-WhatIf] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Remove-Item cmdlet deletes one or more items. Because it is supported b
y many providers, it can delete many different types of items, including fi
les, directories, registry keys, variables, aliases, and functions.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to remove items that cannot otherwise be changed, suc
h as hidden or read-only files or read-only aliases or variables. The c
mdlet cannot remove constant aliases or variables. Implementation vari
es from provider to provider. For more information, see about_Providers
. Even using the Force parameter, the cmdlet cannot override security r
estrictions.

-Include <string[]>
Deletes only the specified items. The value of this parameter qualifies
the Path parameter. Enter a path element or pattern, such as "*.txt".
Wildcards are permitted.

-LiteralPath <string[]>
Specifies a path to the items being removed. Unlike Path, the value of
LiteralPath is used exactly as it is typed. No characters are interpret
ed as wildcards. If the path includes escape characters, enclose it in
single quotation marks. Single quotation marks tell Windows PowerShell
not to interpret any characters as escape sequences.

-Path <string[]>
Specifies a path to the items being removed. Wildcards are permitted. T
he parameter name ("-Path") is optional.

-Recurse [<SwitchParameter>]
Deletes the items in the specified locations and in all child items of
the locations.

The Recurse parameter in this cmdlet does not work properly.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>remove-item C:\Test\*.*

Description
-----------
This command deletes all of the files with names that include a dot (.) fro
m the C:\Test directory. Because the command specifies a dot, the command d
oes not delete directories or files with no file name extension.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>remove-item * -include *.doc -exclude *1*

Description
-----------
This command deletes from the current directory all files with a .doc file
name extension and a name that does not include "1". It uses the wildcard c
haracter (*) to specify the contents of the current directory. It uses the
Include and Exclude parameters to specify the files to delete.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>remove-item -path C:\Test\hidden-RO-file.txt -force

Description
-----------
This command deletes a file that is both hidden and read-only. It uses the
Path parameter to specify the file. It uses the Force parameter to give per
mission to delete it. Without Force, you cannot delete read-only or hidden
files.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-childitem * -include *.csv -recurse | remove-item

Description
-----------
This command deletes all of the CSV files in the current directory and all
subdirectories recursively.

Because the Recurse parameter in this cmdlet is faulty, the command uses th
e Get-Childitem cmdlet to get the desired files, and it uses the pipeline o
perator to pass them to the Remove-Item cmdlet.

In the Get-ChildItem command, the Path parameter has a value of *, which re
presents the contents of the current directory. It uses the Include paramet
er to specify the CSV file type, and it uses the Recurse parameter to make
the retrieval recursive.

If you try to specify the file type in the path, such as "-path *.csv", the
cmdlet interprets the subject of the search to be a file that has no child
items, and Recurse fails.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>remove-item hklm:\software\mycompany\OldApp -recurse

Description
-----------
This command deletes the OldApp registry key and all of its subkeys and val
ues. It uses the Remove-Item cmdlet to remove the key. The path is specifie
d, but the optional parameter name (Path) is omitted.

The Recurse parameter deletes all of the contents of the OldApp key recursi
vely. If the key contains subkeys and you omit the Recurse parameter, you a
re prompted to confirm that you want to delete the contents of the key.




REMARKS
To see the examples, type: "get-help Remove-Item -examples".
For more information, type: "get-help Remove-Item -detailed".
For technical information, type: "get-help Remove-Item -full".

NAME
Compare-Object

SYNOPSIS
Compares two sets of objects.


SYNTAX
Compare-Object [-ReferenceObject] <PSObject[]> [-DifferenceObject] <PSObjec
t[]> [-CaseSensitive] [-Culture <string>] [-ExcludeDifferent] [-IncludeEqua
l] [-PassThru] [-Property <Object[]>] [-SyncWindow <int>] [<CommonParameter
s>]


DESCRIPTION
The Compare-Object cmdlet compares two sets of objects. One set of objects
is the Reference set, and the other set is the Difference set.

The result of the comparison indicates whether a property value appeared on
ly in the object from the Reference set (indicated by the <= symbol), only
in the object from the Difference set (indicated by the => symbol) or, if t
he IncludeEqual parameter is specified, in both objects (indicated by the =
= symbol).

PARAMETERS
-CaseSensitive [<SwitchParameter>]
Indicates that comparisons should be case-sensitive.

-Culture <string>
Specifies the culture to use for comparisons.

-DifferenceObject <PSObject[]>
Specifies the objects that are compared to the reference objects.

-ExcludeDifferent [<SwitchParameter>]
Displays only the characteristics of compared objects that are equal.

-IncludeEqual [<SwitchParameter>]
Displays characteristics of compared objects that are equal. By default
, only characteristics that differ between the reference and difference
objects are displayed.

-PassThru [<SwitchParameter>]
Passes the objects that differed to the pipeline. By default, this cmdl
et does not generate any output.

-Property <Object[]>
Specifies the properties of the reference and difference objects to com
pare.

-ReferenceObject <PSObject[]>
Objects used as a reference for comparison.

-SyncWindow <int>
Defines a search region in which an attempt is made to re-synchronize t
he order if there is no match. The default value is [Int32]::MaxValue.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>compare-object -referenceobject $(get-content C:\test\testfile1.txt)
-differenceobject $(get-content C:\test\testfile2.txt)

Description
-----------
This command compares the contents of two text files. It displays only the
lines that appear in one file or in the other file, not lines that appear i
n both files.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>compare-object -referenceobject $(get-content C:\Test\testfile1.txt)
-differenceobject $(get-content C:\Test\testfile2.txt) -includeequal

Description
-----------
This command compares each line of content in two text files. It displays a
ll lines of content from both files, indicating whether each line appears i
n only Textfile1.txt or Textfile2.txt or whether each line appears in both
files.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$processes_before = get-process

C:\PS> notepad

C:\PS> $processes_after = get-process

C:\PS> compare-object -referenceobject $processes_before -differenceobject
$processes_after

Description
-----------
These commands compare two sets of process objects.

The first command uses the Get-Process cmdlet to get the processes on the c
omputer. It stores them in the $processes_before variable.

The second command starts Notepad.

The third command uses the Get-Process cmdlet again and stores the resultin
g processes in the $processes_after variable.

The fourth command uses the Compare-Object cmdlet to compare the two sets o
f process objects. It displaysthe differences between them, which include t
he new instance of Notepad.




REMARKS
To see the examples, type: "get-help Compare-Object -examples".
For more information, type: "get-help Compare-Object -detailed".
For technical information, type: "get-help Compare-Object -full".

NAME
Get-ChildItem

SYNOPSIS
Gets the items and child items in one or more specified locations.


SYNTAX
Get-ChildItem [[-Path] <string[]>] [[-Filter] <string>] [-Exclude <string[]
>] [-Force] [-Include <string[]>] [-Name] [-Recurse] [-UseTransaction] [<Co
mmonParameters>]

Get-ChildItem [-LiteralPath] <string[]> [[-Filter] <string>] [-Exclude <str
ing[]>] [-Force] [-Include <string[]>] [-Name] [-Recurse] [-UseTransaction]
[<CommonParameters>]


DESCRIPTION
The Get-ChildItem cmdlet gets the items in one or more specified locations.
If the item is a container, it gets the items inside the container, known
as child items. You can use the Recurse parameter to get items in all child
containers.

A location can be a file system location, such as a directory, or a locatio
n exposed by another provider, such as a registry hive or a certificate sto
re.

PARAMETERS
-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to get items that cannot otherwise not be accessed by
the user, such as hidden or system files. Implementation varies from p
rovider to provider. For more information, see about_Providers. Even us
ing the Force parameter, the cmdlet cannot override security restrictio
ns.

-Include <string[]>
Retrieves only the specified items. The value of this parameter qualifi
es the Path parameter. Enter a path element or pattern, such as "*.txt"
. Wildcards are permitted.

The Include parameter is effective only when the command includes the R
ecurse parameter or the path leads to the contents of a directory, such
as C:\Windows\*, where the wildcard character specifies the contents o
f the C:\Windows directory.

-LiteralPath <string[]>
Specifies a path to one or more locations. Unlike Path, the value of Li
teralPath is used exactly as it is typed. No characters are interpreted
as wildcards. If the path includes escape characters, enclose it in si
ngle quotation marks. Single quotation marks tell Windows PowerShell no
t to interpret any characters as escape sequences.

-Name [<SwitchParameter>]
Retrieves only the names of the items in the locations. If you pipe the
output of this command to another command, only the item names are sen
t.

-Path <string[]>
Specifies a path to one or more locations. Wildcards are permitted. The
default location is the current directory (.).

-Recurse [<SwitchParameter>]
Gets the items in the specified locations and in all child items of the
locations.

Recurse works only when the path points to a container that has child i
tems, such as C:\Windows or C:\Windows\*, and not when it points to ite
ms that do not have child items, such as C:\Windows\*.exe.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-childitem

Description
-----------
This command gets the child items in the current location. If the location
is a file system directory, it gets the files and sub-directories in the cu
rrent directory. If the item does not have child items, this command return
s to the command prompt without displaying anything.

The default display lists the mode (attributes), last write time, file size
(length), and the name of the file. The valid values for mode are d (direc
tory), a (archive), r (read-only), h (hidden), and s (system).




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-childitem . -include *.txt -recurse -force

Description
-----------
This command retrieves all of the .txt files in the current directory and i
ts subdirectories. The dot (.) represents the current directory and the Inc
lude parameter specifies the file name extension. The Recurse parameter dir
ects Windows PowerShell to retrieve objects recursively, and it indicates t
hat the subject of the command is the specified directory and its contents.
The force parameter adds hidden files to the display.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-childitem c:\windows\logs\* -include *.txt -exclude A*

Description
-----------
This command lists the .txt files in the Logs subdirectory, except for thos
e whose names start with the letter A. It uses the wildcard character (*) t
o indicate the contents of the Logs subdirectory, not the directory contain
er. Because the command does not include the Recurse parameter, Get-ChildIt
em does not include the content of directory automatically; you need to spe
cify it.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-childitem registry::hklm\software

Description
-----------
This command retrieves all of the registry keys in the HKEY_LOCAL_MACHINE\S
OFTWARE key in the registry of the local computer.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-childitem -name

Description
-----------
This command retrieves only the names of items in the current directory.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-childitem cert:\. -recurse -codesigningcert

Description
-----------
This command gets all of the certificates in the certificate store that hav
e code-signing authority.

The command uses the Get-ChildItem cmdlet. The path specifies the Cert: dri
ve exposed by the Windows PowerShell certificate provider. The backslash (\
) symbol specifies a subdirectory of the certificate store and the dot (.)
represents the current directory, which would be the root directory of the
certificate store. The Recurse parameter specifies a recursive search.

The CodeSigningCertificate parameter is a dynamic parameter that gets only
certificates with code-signing authority. For more information, type "get-h
elp certificate".




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-childitem * -include *.exe

Description
-----------
This command retrieves all of the items in the current directory with a ".e
xe" file name extension. The wildcard character (*) represents the contents
of the current directory (not the container). When using the Include param
eter without the Recurse parameter, the path must point to contents, not a
container.




REMARKS
To see the examples, type: "get-help Get-ChildItem -examples".
For more information, type: "get-help Get-ChildItem -detailed".
For technical information, type: "get-help Get-ChildItem -full".

NAME
Disable-ComputerRestore

SYNOPSIS
Disables the System Restore feature on the specified file system drive.


SYNTAX
Disable-ComputerRestore [-Drive] <string[]> [-Confirm] [-WhatIf] [<CommonPa
rameters>]


DESCRIPTION
The Disable-ComputerRestore cmdlet turns off the System Restore feature on
one or more file system drives. As a result, attempts to restore the comput
er do not affect the specified drive.

To disable System Restore on any drive, it must be disabled on the system d
rive, either first or concurrently.

To re-enable System Restore, use the Enable-ComputerRestore cmdlet. To find
the state of System Restore for each drive, use Rstrui.exe.

PARAMETERS
-Drive <string[]>
Specifies the file system drives. Enter one or more file system drive l
etters, each followed by a colon and a backslash and enclosed in quotat
ion marks, such as "C:\" or "D:\". This parameter is required.

You cannot use this cmdlet to disable System Restore on a remote networ
k drive, even if the drive is mapped to the local computer, and you can
not disable System Restore on drives that are not eligible for System R
estore, such as external drives.

To disable System Restore on any drive, System Restore must be disabled
on the system drive, either before or concurrently.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>disable-computerrestore -drive "C:\"

Description
-----------
This command disables System Restore on the C: drive.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>disable-computerrestore "C:\", "D:\"

Description
-----------
This command disables System Restore on the C: and D: drives. The command u
ses the Drive parameter, but it the omits the optional parameter name.




REMARKS
To see the examples, type: "get-help Disable-ComputerRestore -examples".
For more information, type: "get-help Disable-ComputerRestore -detailed".
For technical information, type: "get-help Disable-ComputerRestore -full".

NAME
Disable-PSBreakpoint

SYNOPSIS
Disables the breakpoints in the current console.


SYNTAX
Disable-PSBreakpoint [-Id] <Int32[]> [-PassThru] [-Confirm] [-WhatIf] [<Com
monParameters>]

Disable-PSBreakpoint [-Breakpoint] <Breakpoint[]> [-PassThru] [-Confirm] [-
WhatIf] [<CommonParameters>]


DESCRIPTION
The Disable-PSBreakpoint cmdlet disables breakpoints, which assures that th
ey are not hit when the script runs. You can use it to disable all breakpoi
nts, or you can specify breakpoints by submitting breakpoint objects or bre
akpoint IDs.

Technically, this cmdlet changes the value of the Enabled property of a bre
akpoint object to False. To re-enable a breakpoint, use the Enable-PSBreakp
oint cmdlet. Breakpoints are enabled by default when you create them by usi
ng the Set-PSBreakpoint cmdlet.

A breakpoint is a point in a script where execution stops temporarily so th
at you can examine the instructions in the script. Disable-PSBreakpoint is
one of several cmdlets designed for debugging Windows PowerShell scripts. F
or more information about the Windows PowerShell debugger, see about_Debugg
ers.

PARAMETERS
-Breakpoint <Breakpoint[]>
Specifies the breakpoints to disable. Enter a variable that contains br
eakpoint objects or a command that gets breakpoint objects, such as a G
et-PSBreakpoint command. You can also pipe breakpoint objects to the Di
sable-PSBreakpoint cmdlet.

-Id <Int32[]>
Disables the breakpoints with the specified breakpoint IDs. Enter the I
Ds or a variable that contains the IDs. You cannot pipe IDs to Disable-
PSBreakpoint.

-PassThru [<SwitchParameter>]
Returns an object representing the enabled breakpoints. By default, thi
s cmdlet does not generate any output.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$b = set-psbreakpoint -script sample.ps1 -variable name

C:\PS> $b | disable-psbreakpoint

Description
-----------
These commands disable a newly-created breakpoint.

The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint o
n the Name variable in the Sample.ps1 script. Then, it saves the breakpoint
object in the $b variable.

The second command uses the Disable-PSBreakpoint cmdlet to disable the new
breakpoint. It uses a pipeline operator (|) to send the breakpoint object i
n $b to the Disable-PSBreakpoint cmdlet.

As a result of this command, the value of the Enabled property of the break
point object in $b is False.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>disable-psbreakpoint -id 0

Description
-----------
This command disables the breakpoint with breakpoint ID 0.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>disable-psbreakpoint -breakpoint ($b = set-psbreakpoint -script sampl
e.ps1 -line 5)

C:\PS> $b

Description
-----------
This command creates a new breakpoint that is disabled until you enable it.

It uses the Disable-PSBreakpoint cmdlet to disable the breakpoint. The valu
e of the Breakpoint parameter is a Set-PSBreakpoint command that sets a new
breakpoint, generates a breakpoint object, and saves the object in the $b
variable.

Cmdlet parameters that take objects as their values can accept a variable t
hat contains the object or a command that gets or generates the object. In
this case, because Set-PSBreakpoint generates a breakpoint object, it can b
e used as the value of the Breakpoint parameter.

The second command displays the breakpoint object in the value of the $b va
riable.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-psbreakpoint | disable-psbreakpoint

Description
-----------
This command disables all breakpoints in the current console. You can abbre
viate this command as: "gbp | dbp".




REMARKS
To see the examples, type: "get-help Disable-PSBreakpoint -examples".
For more information, type: "get-help Disable-PSBreakpoint -detailed".
For technical information, type: "get-help Disable-PSBreakpoint -full".

NAME
Disable-PSRemoting

SYNOPSIS


SYNTAX
Disable-PSRemoting [-force] [-WhatIf] [-Confirm] [<CommonParameters>]


DESCRIPTION

PARAMETERS
-force [<SwitchParameter>]

-WhatIf [<SwitchParameter>]

-Confirm [<SwitchParameter>]

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

REMARKS
To see the examples, type: "get-help Disable-PSRemoting -examples".
For more information, type: "get-help Disable-PSRemoting -detailed".
For technical information, type: "get-help Disable-PSRemoting -full".

NAME
Disable-PSSessionConfiguration

SYNOPSIS
Denies access to the session configurations on the local computer.


SYNTAX
Disable-PSSessionConfiguration [[-Name] <string[]>] [-Force] [-Confirm] [-W
hatIf] [<CommonParameters>]


DESCRIPTION
The Disable-PSSessionConfiguration cmdlet prevents all users of the compute
r from using the session configuration in a session. This is an advanced cm
dlet that is designed to be used by system administrators to manage customi
zed session configurations for their users.

The Disable-PSSessionConfiguration cmdlet adds a "deny all" setting to the
security descriptor of one or more registered session configurations. As a
result, you can unregister, view, and change the configurations, but you ca
nnot use them in a session.

Without parameters, Disable-PSSessionConfiguration disables the Microsoft.P
owerShell configuration, which is the default configuration that is used fo
r sessions. Unless the user specifies a different configuration, both local
and remote users are effectively prevented from creating any sessions that
connect to the computer.

To disable all session configurations on the computer, use Disable-PSRemoti
ng.

PARAMETERS
-Force [<SwitchParameter>]
Suppresses all user prompts. By default, you are prompted to confirm ea
ch operation.

-Name <string[]>
Specifies the names of session configurations to disable. Enter one or
more configuration names. Wildcards are permitted. You can also pipe a
string that contains a configuration name or a session configuration ob
ject to Disable-PSSessionConfiguration.

If you omit this parameter, Disable-PSSessionConfiguration disables the
Microsoft.PowerShell session configuration.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>Disable-PSSessionConfiguration

Description
-----------
This command disables the Microsoft.PowerShell session configuration.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>disable-pssessionConfiguration -name *

Description
-----------
This command disables all registered session configurations on the computer
.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>disable-pssessionConfiguration -name Microsoft* -force

Description
-----------
This command disables all session configurations that have names that begin
with "Microsoft". The command uses the Force parameter to suppress all use
r prompts from the command.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>Get-PSSessionConfiguration -name MaintenanceShell, AdminShell | Disab
le-PSSessionConfiguration

Description
-----------
This command disables the MaintenanceShell and AdminShell session configura
tions.

The command uses a pipeline operator (|) to send the results of a Get-PSSes
sionConfiguration command to Disable-PSSessionConfiguration.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>Get-PSSessionConfiguration | format-table -property Name, Permission
-auto

Name Permission
---- ----------
MaintenanceShell BUILTIN\Administrators AccessAllowed
microsoft.powershell BUILTIN\Administrators AccessAllowed
microsoft.powershell32 BUILTIN\Administrators AccessAllowed

C:\PS> Disable-PSSessionConfiguration -name MaintenanceShell -force

C:\PS> Get-PSSessionConfiguration | format-table -property Name, Permission
-auto

Name Permission
---- ----------
MaintenanceShell Everyone AccessDenied, BUILTIN\Administrators Access
Allowed
microsoft.powershell BUILTIN\Administrators AccessAllowed
microsoft.powershell32 BUILTIN\Administrators AccessAllowed

C:\PS> Set-PSSessionConfiguration -name MaintenanceShell -MaximumReceivedDa
taSizePerCommandMB 60

ParamName ParamValue
--------- ----------
psmaximumreceived... 60

"Restart WinRM service"
WinRM service need to be restarted to make the changes effective. Do you wa
nt to run the command "restart-service winrm"?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y


C:\PS> new-pssession -computername localhost -configurationName Maintenance
Shell

[localhost] Connecting to remote server failed with the following error mes
sage : Access is denied. For more information, see the about_Remote_Troubl
eshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace
:RemoteRunspace) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionOpenFailed

Description
-----------
This example shows the effect of disabling a session configuration.

The first command uses the Get-SessionConfiguration and Format-Table cmdlet
s to display only the Name and Permission properties of the session configu
ration objects. This table format makes it easier to see the values of the
objects. The results show that members of the Administrators group are perm
itted to use the session configurations.

The second command uses the Disable-PSSessionConfiguration cmdlet to disabl
e the MaintenanceShell session configuration. The command uses the Force pa
rameter to suppress all user prompts.

The third command repeats the first command. The results show that you can
still get the object that represents the MaintenanceShell session configura
tion even though everyone is denied access to it. The "AccessDenied" entry
takes precedence over all other entries in the security descriptor.

The fourth command uses the Set-PSSessionConfiguration cmdlet to increase t
he MaximumDataSizePerCommandMB setting on the MaintenanceShell session conf
iguration to 60. The results show that the command was successful even thou
gh everyone is denied access to the configuration.

The fifth command attempts to use the MaintenanceShell session configuratio
n in a session. It uses the New-PSSession cmdlet to create a new session an
d the ConfigurationName parameter to specify the MaintenanceShell configura
tion. The results show that the New-PSSession command fails because the us
er is denied access to the configuration.




REMARKS
To see the examples, type: "get-help Disable-PSSessionConfiguration -exampl
es".
For more information, type: "get-help Disable-PSSessionConfiguration -detai
led".
For technical information, type: "get-help Disable-PSSessionConfiguration -
full".

NAME
Disable-WSManCredSSP

SYNOPSIS
Disables Credential Security Service Provider (CredSSP) authentication on a
client computer.


SYNTAX
Disable-WSManCredSSP [-Role] <string> [<CommonParameters>]


DESCRIPTION
The Disable-WSManCredSPP cmdlet disables CredSSP authentication on a client
or on a server computer. When CredSSP authentication is used, the user's c
redentials are passed to a remote computer to be authenticated. This type o
f authentication is designed for commands that create a remote session from
within another remote session. For example, you use this type of authentic
ation if you want to run a background job on a remote computer.

The cmdlet is used to disable CredSSP on the client by specifying Client in
the Role parameter. The cmdlet then performs the following:

- Disables CredSSP on the client. The WS-Management setting <localhost|
computername>\Client\Auth\CredSSP is set to false.
- Removes any WSMan/* setting from the Windows CredSSP policy AllowFres
hCredentials on the client.

The cmdlet is used to disable CredSSP on the server by specifying Server in
the Role parameter. The cmdlet then performs the following:

- Disables CredSSP on the server. The WS-Management setting <localhost|c
omputername>\Service\Auth\CredSSP is set to false.

Caution: CredSSP authentication delegates the user's credentials from the l
ocal computer to a remote computer. This practice increases the security ri
sk of the remote operation. If the remote computer is compromised, when cre
dentials are passed to it, the credentials can be used to control the netwo
rk session.

To disable CredSSP authentication, use the Disable-WSManCredSSP cmdlet.

PARAMETERS
-Role <string>
Accepts one of two possible values: Client or Server. These values spe
cify whether CredSSP should be disabled as a client or as a server.

If the cmdlet is used to disable CredSSP on the client by specifying Cl
ient in the Role parameter, then the cmdlet performs the following:

- Disables CredSSP on the client. The WS-Management setting <localh
ost|computername>\Client\Auth\CredSSP is set to false.
- Removes any WSMan/* setting from the Windows CredSSP policy Allow
FreshCredentials on the client.

If the cmdlet is used to disable CredSSP on the server by specifying Se
rver in the Role parameter, the cmdlet performs the following:

- Disables CredSSP on the server. The WS-Management setting <localho
st|computername>\Service\Auth\CredSSP is set to false.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>Disable-WSManCredSSP -Role Client

Description
-----------
This command disables CredSSP on the client, which prevents delegation to s
ervers.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>Disable-WSManCredSSP -Role Server

Description
-----------
This command disables CredSSP on the server, which prevents delegation from
clients.




REMARKS
To see the examples, type: "get-help Disable-WSManCredSSP -examples".
For more information, type: "get-help Disable-WSManCredSSP -detailed".
For technical information, type: "get-help Disable-WSManCredSSP -full".

NAME
Disconnect-WSMan

SYNOPSIS
Disconnects the client from the WinRM service on a remote computer.


SYNTAX
Disconnect-WSMan [-ComputerName <string>] [<CommonParameters>]


DESCRIPTION
The Disconnect-WSMan cmdlet disconnects the client from the WinRM service o
n a remote computer. If you saved the WS-Management session in a variable,
the session object remains in the variable, but the state of the WS-Managem
ent session is "Closed". You can use this cmdlet within the context of the
WS-Management provider to disconnect the client from the WinRM service on a
remote computer. However, you can also use this cmdlet to disconnect from
the WinRM service on remote computers before you change to the WS-Managemen
t provider.

For more information about how to connect to the WinRM service on a remote
computer, see Connect-WSMan.

PARAMETERS
-ComputerName <string>
Specifies the computer from which you want to disconnect. The value can
be a fully qualified domain name, a NetBIOS name, or an IP address. Us
e the local computer name, use localhost, or use a dot (.) to specify t
he local computer. The local computer is the default. When the remote c
omputer is in a different domain from the user, you must use a fully qu
alified domain name must be used. You can pipe a value for this paramet
er to the cmdlet.

Note: You cannot disconnect from the local host (the default connection
to the local computer). However, if a separate connection is made to t
he local computer (for example, by using the computer name), you can re
move that connection by using the Disconnect-WSMan cmdlet .

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>Disconnect-WSMan -computer server01

C:\PS> cd WSMan:
PS WSMan:\>
PS WSMan:\> dir


WSManConfig: Microsoft.WSMan.Management\WSMan::WSMan

ComputerName Type
------------ ----
localhost Container

Description
-----------
This command deletes the connection to the remote server01 computer.

This cmdlet is generally used within the context of the WS-Management provi
der to disconnect from a remote computer, in this case the server01 compute
r. However, you can also use the Disconnect-WSMan cmdlet to remove connecti
ons to remote computers before you change to the WSMan provider. Those con
nections will not appear in the ComputerName list.




REMARKS
To see the examples, type: "get-help Disconnect-WSMan -examples".
For more information, type: "get-help Disconnect-WSMan -detailed".
For technical information, type: "get-help Disconnect-WSMan -full".

E:

NAME
Enable-PSBreakpoint

SYNOPSIS
Enables the breakpoints in the current console.


SYNTAX
Enable-PSBreakpoint [-Id] <Int32[]> [-PassThru] [-Confirm] [-WhatIf] [<Comm
onParameters>]

Enable-PSBreakpoint [-Breakpoint] <Breakpoint[]> [-PassThru] [-Confirm] [-W
hatIf] [<CommonParameters>]


DESCRIPTION
The Enable-PSBreakpoint cmdlet re-enables disabled breakpoints. You can use
it to enable all breakpoints, or you can specify breakpoints by submitting
breakpoint objects or breakpoint IDs.

A breakpoint is a point in a script where execution stops temporarily so th
at you can examine the instructions in the script. Newly created breakpoint
s are automatically enabled, but you can disable them by using the Disable-
PSBreakpoint cmdlet.

Technically, this cmdlet changes the value of the Enabled property of a bre
akpoint object to True.

Enable-PSBreakpoint is one of several cmdlets designed for debugging Window
s PowerShell scripts. For more information about the Windows PowerShell deb
ugger, see about_Debuggers.

PARAMETERS
-Breakpoint <Breakpoint[]>
Specifies the breakpoints to enable. Enter a variable that contains bre
akpoint objects or a command that gets breakpoint objects, such as a Ge
t-PSBreakpoint command. You can also pipe breakpoint objects to Enable-
PSBreakpoint.

-Id <Int32[]>
Enables breakpoints that have the specified breakpoint IDs. The default
value is all breakpoints. Enter the IDs or a variable that contains th
e IDs. (You cannot pipe IDs to Enable-PSBreakpoint.) To find the ID of
a breakpoint, use the Get-PSBreakpoint cmdlet.

-PassThru [<SwitchParameter>]
Returns an object representing the enabled breakpoint. By default, this
cmdlet does not generate any output.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-psbreakpoint | enable-psbreakpoint

Description
-----------
This command enables all breakpoints in the current console. You can abbrev
iate the command as "gbp | ebp".




-------------------------- EXAMPLE 2 --------------------------

C:\PS>enable-psbreakpoint -id 0, 1, 5

Description
-----------
This command enables breakpoints with breakpoint IDs 0, 1, and 5.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$b = set-psbreakpoint -script sample.ps1 -variable Name

C:\PS> $b | disable-psbreakpoint -passthru

AccessMode : Write
Variable : Name
Action :
Enabled : False
HitCount : 0
Id : 0
Script : C:\ps-test\sample.ps1
ScriptName : C:\ps-test\sample.ps1

C:\PS> $b | enable-psbreakpoint -passthru

AccessMode : Write
Variable : Name
Action :
Enabled : True
HitCount : 0
Id : 0
Script : C:\ps-test\sample.ps1
ScriptName : C:\ps-test\sample.ps1

Description
-----------
These commands re-enable a breakpoint that has been disabled.

The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint o
n the "Name" variable in the Sample.ps1 script. Then, it saves the breakpoi
nt object in the $b variable.

The second command uses the Disable-PSBreakpoint cmdlet to disable the new
breakpoint. It uses a pipeline operator (|) to send the breakpoint object i
n $b to the Disable-PSBreakpoint cmdlet, and it uses the PassThru parameter
of Disable-PSBreakpoint to display the disabled breakpoint object. This le
ts you verify that the value of the Enabled property of the breakpoint obje
ct is False.

The third command uses the Enable-PSBreakpoint cmdlet to re-enable the brea
kpoint. It uses a pipeline operator (|) to send the breakpoint object in $b
to the Enable-PSBreakpoint cmdlet, and it uses the PassThru parameter of E
nable-PSBreakpoint to display the breakpoint object. This lets you verify t
hat the value of the Enabled property of the breakpoint object is True.

The results are shown in the following sample output.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$b = get-psbreakpoint -id 3, 5

C:\PS> enable-psbreakpoint -breakpoint $b

Description
-----------
These commands enable a set of breakpoints by specifying their breakpoint o
bjects.

The first command uses the Get-PSBreakpoint cmdlet to get the breakpoints a
nd saves them in the $b variable.

The second command uses the Enable-PSBreakpoint cmdlet and its Breakpoint p
arameter to enable the breakpoints.
This command is the equivalent of "enable-psbreakpoint -id 3, 5".




REMARKS
To see the examples, type: "get-help Enable-PSBreakpoint -examples".
For more information, type: "get-help Enable-PSBreakpoint -detailed".
For technical information, type: "get-help Enable-PSBreakpoint -full".

NAME
Write-Output

SYNOPSIS
Sends the specified objects to the next command in the pipeline. If the com
mand is the last command in the pipeline, the objects are displayed in the
console.


SYNTAX
Write-Output [-InputObject] <PSObject[]> [<CommonParameters>]


DESCRIPTION
The Write-Output cmdlet sends the specified object down the pipeline to the
next command. If the command is the last command in the pipeline, the obje
ct is displayed in the console.

Write-Output sends objects down the primary pipeline, also known as the "ou
tput stream" or the "success pipeline." To send error objects down the erro
r pipeline, use Write-Error.

This cmdlet is typically used in scripts to display strings and other objec
ts on the console. However, because the default behavior is to display the
objects at the end of a pipeline, it is generally not necessary to use the
cmdlet. For example, "get-process | write-output" is equivalent to "get-pro
cess".

PARAMETERS
-InputObject <PSObject[]>
Specifies the objects to send down the pipeline. Enter a variable that
contains the objects, or type a command or expression that gets the obj
ects.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$p = get-process

c:\PS> write-output $p

c:\PS> $p

Description
-----------
These commands get objects representing the processes running on the comput
er and display the objects on the console.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>write-output "test output" | get-member

Description
-----------
This command pipes the "test output" string to the Get-Member cmdlet, which
displays the members of the String class, demonstrating that the string wa
s passed along the pipeline.




REMARKS
To see the examples, type: "get-help Write-Output -examples".
For more information, type: "get-help Write-Output -detailed".
For technical information, type: "get-help Write-Output -full".

NAME
Enable-ComputerRestore

SYNOPSIS
Enables the System Restore feature on the specified file system drive.


SYNTAX
Enable-ComputerRestore [-Drive] <string[]> [-Confirm] [-WhatIf] [<CommonPar
ameters>]


DESCRIPTION
The Enable-ComputerRestore cmdlet turns on the System Restore feature on on
e or more file system drives. As a result, you can use tools, such as the R
estore-Computer cmdlet, to restore the computer to a previous state.

By default, System Restore is enabled on all eligible drives, but you can d
isable it, such as by using the Disable-ComputerRestore cmdlet. To enable (
or re-enable) System Restore on any drive, it must be enabled on the system
drive, either first or concurrently. To find the state of System Restore
for each drive, use Rstrui.exe.

PARAMETERS
-Drive <string[]>
Specifies the file system drives. Enter one or more file system drive l
etters, each followed by a colon and a backslash and enclosed in quotat
ion marks, such as "C:\" or "D:\". This parameter is required.

You cannot use this cmdlet to enable System Restore on a remote network
drive, even if the drive is mapped to the local computer, and you cann
ot enable System Restore on drives that are not eligible for System Res
tore, such as external drives.

To enable System Restore on any drive, System Restore must be enabled o
n the system drive, either before or concurrently.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>enable-computerrestore -drive "C:\"

Description
-----------
This command enables System Restore on the C: drive of the local computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>enable-computerrestore -drive "C:\", "D:\"

Description
-----------
This command enables System Restore on the C: and D: drives of the local co
mputer.




REMARKS
To see the examples, type: "get-help Enable-ComputerRestore -examples".
For more information, type: "get-help Enable-ComputerRestore -detailed".
For technical information, type: "get-help Enable-ComputerRestore -full".

NAME
Enable-PSBreakpoint

SYNOPSIS
Enables the breakpoints in the current console.


SYNTAX
Enable-PSBreakpoint [-Id] <Int32[]> [-PassThru] [-Confirm] [-WhatIf] [<Comm
onParameters>]

Enable-PSBreakpoint [-Breakpoint] <Breakpoint[]> [-PassThru] [-Confirm] [-W
hatIf] [<CommonParameters>]


DESCRIPTION
The Enable-PSBreakpoint cmdlet re-enables disabled breakpoints. You can use
it to enable all breakpoints, or you can specify breakpoints by submitting
breakpoint objects or breakpoint IDs.

A breakpoint is a point in a script where execution stops temporarily so th
at you can examine the instructions in the script. Newly created breakpoint
s are automatically enabled, but you can disable them by using the Disable-
PSBreakpoint cmdlet.

Technically, this cmdlet changes the value of the Enabled property of a bre
akpoint object to True.

Enable-PSBreakpoint is one of several cmdlets designed for debugging Window
s PowerShell scripts. For more information about the Windows PowerShell deb
ugger, see about_Debuggers.

PARAMETERS
-Breakpoint <Breakpoint[]>
Specifies the breakpoints to enable. Enter a variable that contains bre
akpoint objects or a command that gets breakpoint objects, such as a Ge
t-PSBreakpoint command. You can also pipe breakpoint objects to Enable-
PSBreakpoint.

-Id <Int32[]>
Enables breakpoints that have the specified breakpoint IDs. The default
value is all breakpoints. Enter the IDs or a variable that contains th
e IDs. (You cannot pipe IDs to Enable-PSBreakpoint.) To find the ID of
a breakpoint, use the Get-PSBreakpoint cmdlet.

-PassThru [<SwitchParameter>]
Returns an object representing the enabled breakpoint. By default, this
cmdlet does not generate any output.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-psbreakpoint | enable-psbreakpoint

Description
-----------
This command enables all breakpoints in the current console. You can abbrev
iate the command as "gbp | ebp".




-------------------------- EXAMPLE 2 --------------------------

C:\PS>enable-psbreakpoint -id 0, 1, 5

Description
-----------
This command enables breakpoints with breakpoint IDs 0, 1, and 5.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$b = set-psbreakpoint -script sample.ps1 -variable Name

C:\PS> $b | disable-psbreakpoint -passthru

AccessMode : Write
Variable : Name
Action :
Enabled : False
HitCount : 0
Id : 0
Script : C:\ps-test\sample.ps1
ScriptName : C:\ps-test\sample.ps1

C:\PS> $b | enable-psbreakpoint -passthru

AccessMode : Write
Variable : Name
Action :
Enabled : True
HitCount : 0
Id : 0
Script : C:\ps-test\sample.ps1
ScriptName : C:\ps-test\sample.ps1

Description
-----------
These commands re-enable a breakpoint that has been disabled.

The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint o
n the "Name" variable in the Sample.ps1 script. Then, it saves the breakpoi
nt object in the $b variable.

The second command uses the Disable-PSBreakpoint cmdlet to disable the new
breakpoint. It uses a pipeline operator (|) to send the breakpoint object i
n $b to the Disable-PSBreakpoint cmdlet, and it uses the PassThru parameter
of Disable-PSBreakpoint to display the disabled breakpoint object. This le
ts you verify that the value of the Enabled property of the breakpoint obje
ct is False.

The third command uses the Enable-PSBreakpoint cmdlet to re-enable the brea
kpoint. It uses a pipeline operator (|) to send the breakpoint object in $b
to the Enable-PSBreakpoint cmdlet, and it uses the PassThru parameter of E
nable-PSBreakpoint to display the breakpoint object. This lets you verify t
hat the value of the Enabled property of the breakpoint object is True.

The results are shown in the following sample output.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$b = get-psbreakpoint -id 3, 5

C:\PS> enable-psbreakpoint -breakpoint $b

Description
-----------
These commands enable a set of breakpoints by specifying their breakpoint o
bjects.

The first command uses the Get-PSBreakpoint cmdlet to get the breakpoints a
nd saves them in the $b variable.

The second command uses the Enable-PSBreakpoint cmdlet and its Breakpoint p
arameter to enable the breakpoints.
This command is the equivalent of "enable-psbreakpoint -id 3, 5".




REMARKS
To see the examples, type: "get-help Enable-PSBreakpoint -examples".
For more information, type: "get-help Enable-PSBreakpoint -detailed".
For technical information, type: "get-help Enable-PSBreakpoint -full".

NAME
Enable-PSRemoting

SYNOPSIS
Configures the computer to receive remote commands.


SYNTAX
Enable-PSRemoting [-Force] [-Confirm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Enable-PSRemoting cmdlet configures the computer to receive Windows Pow
erShell remote commands that are sent by using the WS-Management technology
.

You need to run this command only once on each computer that will receive c
ommands. You do not need to run it on computers that only send commands. Be
cause the configuration activates listeners, it is prudent to run it only w
here it is needed.

The Enable-PSRemoting cmdlet performs the following operations:

-- Runs the Set-WSManQuickConfig cmdlet, which performs the following tasks
:
----- Starts the WinRM service.
----- Sets the startup type on the WinRM service to Automatic.
----- Creates a listener to accept requests on any IP address.
----- Enables a firewall exception for WS-Management communications.

-- Enables all registered Windows PowerShell session configurations to rece
ive instructions from a remote computer.
----- Registers the "Microsoft.PowerShell" session configuration, if it is
not already registered.
----- Registers the "Microsoft.PowerShell32" session configuration on 64-bi
t computers, if it is not already registered.
----- Removes the "Deny Everyone" setting from the security descriptor for
all the registered session configurations.
----- Restarts the WinRM service to make the preceding changes effective.

To run this cmdlet on Windows Vista, Windows Server 2008, and later version
s of Windows, you must start Windows PowerShell with the "Run as administra
tor" option.

PARAMETERS
-Force [<SwitchParameter>]
Suppresses all user prompts. By default, you are prompted to confirm ea
ch operation.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>enable-psremoting

Description
-----------
This command configures the computer to receive remote commands.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>enable-psremoting -force

Description
-----------
This command configures the computer to receive remote commands. It uses th
e Force parameter to suppress the user prompts.




REMARKS
To see the examples, type: "get-help Enable-PSRemoting -examples".
For more information, type: "get-help Enable-PSRemoting -detailed".
For technical information, type: "get-help Enable-PSRemoting -full".

NAME
Enable-PSSessionConfiguration

SYNOPSIS
Enables the session configurations on the local computer.


SYNTAX
Enable-PSSessionConfiguration [[-Name] <string[]>] [-Force] [-SecurityDescr
iptorSDDL <string>] [-Confirm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Enable-PSSessionConfiguration cmdlet re-enables registered session conf
igurations that have been disabled by using the Disable-PSSessionConfigurat
ion cmdlet. This is an advanced cmdlet that is designed to be used by syste
m administrators to manage customized session configurations for their user
s.

Without parameters, Enable-PSSessionConfiguration re-enables the Microsoft.
PowerShell configuration, which is the default configuration that is used f
or sessions.

This cmdlet performs the following operations for each enabled configuratio
n:
-- Removes the "deny all" setting from the security descriptor of the conf
iguration or replaces the security descriptor with one that you specify.
-- Turns on the listener that accepts requests on any IP address.
-- Restarts the WinRM service.

The Enable-PSSessionConfiguration cmdlet calls the Set-WSManQuickConfig cmd
let. However, it should not be used to enable remoting on the computer. Ins
tead, use the more comprehensive cmdlet, Enable-PSRemoting.

PARAMETERS
-Force [<SwitchParameter>]
Suppresses all user prompts, and restarts the WinRM service without pro
mpting. Restarting the service makes the configuration change effective
.

To prevent a restart and suppress the restart prompt, use the NoService
Restart parameter.

-Name <string[]>
Specifies the names of session configurations to enable. Enter one or m
ore configuration names. Wildcards are permitted.

You can also pipe a string that contains a configuration name or a sess
ion configuration object to Enable-PSSessionConfiguration.

If you omit this parameter, Enable-PSSessionConfiguration enables the M
icrosoft.PowerShell session configuration.

-SecurityDescriptorSDDL <string>
Replaces the security descriptor on the session configuration with the
specified security descriptor.

If you omit this parameter, Enable-PSSessionConfiguration just deletes
the "deny all" item from the security descriptor.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>Enable-PSSessionConfiguration

Description
-----------
This command re-enables the Microsoft.PowerShell default session configurat
ion on the computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>Enable-PSSessionConfiguration -name MaintenanceShell, AdminShell

Description
-----------
This command re-enables the MaintenanceShell and AdminShell session configu
rations on the computer.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>Enable-PSSessionConfiguration -name *

C:\PS> Get-PSSessionConfiguration | Enable-PSSessionConfiguration

Description
-----------
These commands re-enable all session configurations on the computer. The co
mmands are equivalent, so you can use either one.

Enable-PSSessionConfiguration does not generate an error if you enable a se
ssion configuration that is already enabled.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>Enable-PSSessionConfiguration -name MaintenanceShell -securityDescrip
torSDDL "O:NSG:BAD:P(A;;GXGWGR;;;BA)(A;;GAGR;;;S-1-5-21-123456789-188441444
-3100496)S:P"

Description
-----------
This command re-enables the MaintenanceShell session configuration and spec
ifies a new security descriptor for the configuration.




REMARKS
To see the examples, type: "get-help Enable-PSSessionConfiguration -example
s".
For more information, type: "get-help Enable-PSSessionConfiguration -detail
ed".
For technical information, type: "get-help Enable-PSSessionConfiguration -f
ull".

NAME
Enable-WSManCredSSP

SYNOPSIS
Enables Credential Security Service Provider (CredSSP) authentication on a
client computer.


SYNTAX
Enable-WSManCredSSP [-Role] <string> [[-DelegateComputer] <string>] [<Commo
nParameters>]


DESCRIPTION
The Enable-WSManCredSPP cmdlet enables CredSSP authentication on a client o
r on a server computer. When CredSSP authentication is used, the user's cre
dentials are passed to a remote computer to be authenticated. This type of
authentication is designed for commands that create a remote session from w
ithin another remote session. For example, you use this type of authenticat
ion if you want to run a background job on a remote computer.

This cmdlet is used to enable CredSSP on the client by specifying Client in
the Role parameter. The cmdlet then performs the following:

- Enables CredSSP on the client. The WS-Management setting <localhost|c
omputername>\Client\Auth\CredSSP is set to true.
- Sets the Windows CredSSP policy AllowFreshCredentials to WSMan/Delega
te on the client.
- Note: These settings allow the client to delegate explicit credential
s to a server when server authentication is achieved.

This cmdlet is used to enable CredSSP on the server by specifying Server in
the Role parameter. The cmdlet then performs the following:

- Enables CredSSP on the server. The WS-Management setting <localhost|co
mputername>\Service\Auth\CredSSP is set to true.
- Note: This policy setting allows the server to act as a delegate for c
lients.

Caution: CredSSP authentication delegates the user's credentials from the l
ocal computer to a remote computer. This practice increases the security ri
sk of the remote operation. If the remote computer is compromised, when cre
dentials are passed to it, the credentials can be used to control the netwo
rk session.

To disable CredSSP authentication, use the Disable-WSManCredSSP cmdlet.

PARAMETERS
-DelegateComputer <string>
Allows the client credentials to be delegated to the server or servers
that are specified by this parameter. The value of this parameter shoul
d be a fully qualified domain name.

If the Role parameter specifies Client, the DelegateComputer parameter
is mandatory.
If the Role parameter specifies Server, the DelegateComputer parameter
is not allowed.

-Role <string>
Accepts one of two possible values: Client or Server. These values spe
cify whether CredSSP should be enabled as a client or as a server.

If the Role parameter specifies Client, the cmdlet performs the followi
ng:

- Enables CredSSP on the client. The WS-Management setting <localho
st|computername>\Client\Auth\CredSSP is set to true.
- Sets the Windows CredSSP policy AllowFreshCredentials to WSMan/De
legate on the client.
- Note: These settings allow the client to delegate explicit creden
tials to a server when server authentication is achieved.

If the Role parameter specifies the Server, the cmdlet performs the fol
lowing:

- Enables CredSSP on the server. The WS-Management setting <localhos
t|computername>\Service\Auth\CredSSP is set to true.
- Note: This policy setting allows the server to act as a delegate f
or clients.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>enable-wsmancredssp -role client -delegatecomputer server02.accountin
g.fabrikam.com

cfg : http://schemas.microsoft.com/wbem/wsman/1/config/client/auth
lang : en-US
Basic : true
Digest : true
Kerberos : true
Negotiate : true
Certificate : true
CredSSP : true

Description
-----------
This command allows the client credentials to be delegated to the server02
computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>enable-wsmancredssp -role client -delegatecomputer *.accounting.fabri
kam.com

cfg : http://schemas.microsoft.com/wbem/wsman/1/config/client/auth
lang : en-US
Basic : true
Digest : true
Kerberos : true
Negotiate : true
Certificate : true
CredSSP : true

Description
-----------
This command allows the client credentials to be delegated to all the compu
ters in the accounting.fabrikam.com domain.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>enable-wsmancredssp -role client -delegatecomputer server02.accountin
g.fabrikam.com, server03.accounting.fabrikam.com, server04.accounting.fabri
kam.com

cfg : http://schemas.microsoft.com/wbem/wsman/1/config/client/auth
lang : en-US
Basic : true
Digest : true
Kerberos : true
Negotiate : true
Certificate : true
CredSSP : true

Description
-----------
This command allows the client credentials to be delegated to multiple comp
uters.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>enable-wsmancredssp -role server

Description
-----------
This command allows a computer to act as a delegate for another. The Enable
-WSManCredSSP cmdlet (shown in the earlier examples) only enables CredSSP a
uthentication on the client, and specifies the remote computers that can ac
t on it's behalf. In order for the remote computer to act as a delegate for
the client, the CredSSP item in the Service node of WSMan must be set to t
rue.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>connect-wsman server02
set-item wsman:\server02\service\auth\credSSP -value $true

Description
-----------
This command allows a computer to act as a delegate for another computer. T
he Enable-WSManCredSSP commands that are shown in the earlier examples enab
le CredSSP authentication only on the client computer, and they specify the
remote computers that can act on behalf of the client computer. For the re
mote computer to act as a delegate for the client computer, the CredSSP ite
m in the Service directory of the WSMan provider must be set to true.

In this example, the first command creates a connection to the remote serve
r02 computer.

The second command sets the credSSP value on the remote server02 computer,
which allows the remote computer to act as a delegate.




REMARKS
To see the examples, type: "get-help Enable-WSManCredSSP -examples".
For more information, type: "get-help Enable-WSManCredSSP -detailed".
For technical information, type: "get-help Enable-WSManCredSSP -full".

NAME
Enter-PSSession

SYNOPSIS
Starts an interactive session with a remote computer.


SYNTAX
Enter-PSSession [-ComputerName] <string> [-ApplicationName <string>] [-Auth
entication {Default | Basic | Negotiate | NegotiateWithImplicitCredential |
Credssp | Digest | Kerberos}] [-CertificateThumbprint <string>] [-Configur
ationName <string>] [-Credential <PSCredential>] [-Port <int>] [-SessionOpt
ion <PSSessionOption>] [-UseSSL] [<CommonParameters>]

Enter-PSSession [[-Id] <int>] [<CommonParameters>]

Enter-PSSession [-InstanceId <Guid>] [<CommonParameters>]

Enter-PSSession [-Name <string>] [<CommonParameters>]

Enter-PSSession [[-Session] <PSSession>] [<CommonParameters>]

Enter-PSSession [[-ConnectionURI] <Uri>] [-AllowRedirection] [-Authenticati
on {Default | Basic | Negotiate | NegotiateWithImplicitCredential | Credssp
| Digest | Kerberos}] [-CertificateThumbprint <string>] [-ConfigurationNam
e <string>] [-Credential <PSCredential>] [-SessionOption <PSSessionOption>]
[<CommonParameters>]


DESCRIPTION
The Enter-PSSession cmdlet starts an interactive session with a single remo
te computer. During the session, the commands that you type run on the remo
te computer, just as though you were typing directly on the remote computer
. You can have only one interactive session at a time.

Typically, you use the ComputerName parameter to specify the name of the re
mote computer. However, you can also use a session that you create by using
New-PSSession for the interactive session.

To end the interactive session and disconnect from the remote computer, use
the Exit-PSSession cmdlet, or type "exit".

PARAMETERS
-AllowRedirection [<SwitchParameter>]
Allows redirection of this connection to an alternate Uniform Resource
Identifier (URI).

When you use the ConnectionURI parameter, the remote destination can re
turn an instruction to redirect to a different URI. By default, Windows
PowerShell does not redirect connections, but you can use this paramet
er to allow it to redirect the connection.

Allows redirection of this connection to an alternate URI.

When you use the ConnectionURI parameter, the remote destination can re
turn an instruction to redirect to a different URI. By default, Windows
PowerShell does not redirect connections, but you can use the AllowRed
irection parameter to allow it to redirect the connection.

You can also limit the number of times that the connection is redirecte
d by setting the MaximumConnectionRedirectionCount property of the $PSS
essionOption preference variable, or the MaximumConnectionRedirectionCo
unt property of the value of the SessionOption parameter. The default v
alue is 5. For more information, see the description of the SessionOpti
on parameter, and see New-PSSessionOption.

-ApplicationName <string>
Specifies the application name segment of the connection URI. Use this
parameter to specify the application name when you are not using the Co
nnectionURI parameter in the command.

The default value is the value of the $PSSessionApplicationName prefere
nce variable on the local computer. If this preference variable is not
defined, the default value is WSMAN. This value is appropriate for most
uses. For more information, see about_Preference_Variables.

The WinRM service uses the application name to select a listener to ser
vice the connection request. The value of this parameter should match t
he value of the URLPrefix property of a listener on the remote computer
.

-Authentication <AuthenticationMechanism>
Specifies the mechanism that is used to authenticate the user's credent
ials. Valid values are "Default", "Basic", "Credssp", "Digest", "Kerb
eros", "Negotiate", and "NegotiateWithImplicitCredential". The default
value is "Default".

CredSSP authentication is available only in Windows Vista, Windows Serv
er 2008, and later versions of Windows.

For information about the values of this parameter, see the description
of the System.Management.Automation.Runspaces.AuthenticationMechanism
enumeration in the MSDN (Microsoft Developer Network) library at http:/
/go.microsoft.com/fwlink/?LinkId=144382.

Caution: Credential Security Service Provider (CredSSP) authentication,
in which the user's credentials are passed to a remote computer to be
authenticated, is designed for commands that require authentication on
more than one resource, such as accessing a remote network share. This
mechanism increases the security risk of the remote operation. If the r
emote computer is compromised, the credentials that are passed to it ca
n be used to control the network session.

-CertificateThumbprint <string>
Specifies the digital public key certificate (X509) of a user account t
hat has permission to perform this action. Enter the certificate thumbp
rint of the certificate.

Certificates are used in client certificate-based authentication. They
can be mapped only to local user accounts; they do not work with domain
accounts.

To get a certificate thumbprint, use the Get-Item or Get-ChildItem comm
and in the Windows PowerShell Cert: drive.

-ComputerName <string>
Starts an interactive session with the specified remote computer. Enter
only one computer name. The default is the local computer.

Type the NetBIOS name, an IP address, or a fully qualified domain name
of one or more remote computers. You can also pipe a computer name to E
nter-PSSession.

To use an IP address in the value of the ComputerName parameter, the co
mmand must include the Credential parameter. Also, the computer must be
configured for HTTPS transport or the IP address of the remote compute
r must be included in the WinRM TrustedHosts list on the local computer
. For instructions for adding a computer name to the TrustedHosts list,
see "How to Add a Computer to the Trusted Host List" in about_Remote_
Troubleshooting.

Note: In Windows Vista and later versions of Windows, to include the l
ocal computer in the value of the ComputerName parameter, you must star
t Windows PowerShell with the "Run as administrator" option.

-ConfigurationName <string>
Specifies the session configuration that is used for the interactive se
ssion.

Enter a configuration name or the fully qualified resource URI for a se
ssion configuration. If you specify only the configuration name, the fo
llowing schema URI is prepended: http://schemas.microsoft.com/powershe
ll.

The session configuration for a session is located on the remote comput
er. If the specified session configuration does not exist on the remote
computer, the command fails.

The default value is the value of the $PSSessionConfigurationName prefe
rence variable on the local computer. If this preference variable is no
t set, the default is Microsoft.PowerShell. For more information, see a
bout_Preference_Variables.

-ConnectionURI <Uri>
Specifies a Uniform Resource Identifier (URI) that defines the connecti
on endpoint for the interactive session. The URI must be fully qualifie
d.

The format of this string is as follows:
<Transport>://<ComputerName>:<Port>/<ApplicationName>

The default value is as follows:
http://localhost:80/WSMAN

Valid values for the Transport segment of the URI are HTTP and HTTPS. I
f you do not specify a ConnectionURI, you can use the UseSSL, ComputerN
ame, Port, and ApplicationName parameters to specify the URI values.

If the destination computer redirects the connection to a different URI
, Windows PowerShell prevents the redirection unless you use the AllowR
edirection parameter in the command.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01", "Domain01\User01", or "User@Domain.
com", or enter a PSCredential object, such as one returned by the Get-C
redential cmdlet.

When you type a user name, you will be prompted for a password.

-Id <int>
Specifies the ID of an existing session. Enter-PSSession uses the speci
fied session for the interactive session.

To find the ID of a session, use the Get-PSSession cmdlet.

-InstanceId <Guid>
Specifies the instance ID of an existing session. Enter-PSSession uses
the specified session for the interactive session.

The instance ID is a GUID. To find the instance ID of a session, use th
e Get-PSSession cmdlet. You can also use the Session, Name, or ID param
eters to specify an existing session. Or, you can use the ComputerName
parameter to start a temporary session.

-Name <string>
Specifies the friendly name of an existing session. Enter-PSSession use
s the specified session for the interactive session.

If the name that you specify matches more than one session, the command
fails. You can also use the Session, InstanceID, or ID parameters to s
pecify an existing session. Or, you can use the ComputerName parameter
to start a temporary session.

To establish a friendly name for a session, use the Name parameter of t
he New-PSSession cmdlet.

-Port <int>
Specifies the network port on the remote computer used for this comman
d. The default is port 80 (the HTTP port).

Before using an alternate port, you must configure the WinRM listener o
n the remote computer to listen at that port. Use the following command
s to configure the listener:

1. winrm delete winrm/config/listener?Address=*+Transport=HTTP
2. winrm create winrm/config/listener?Address=*+Transport=HTTP @{Port="
<port-number>"}

Do not use the Port parameter unless you must. The port setting in the
command applies to all computers or sessions on which the command runs.
An alternate port setting might prevent the command from running on al
l computers.

-Session <PSSession>
Specifies a Windows PowerShell session (PSSession) to use for the inter
active session. This parameter takes a session object. You can also use
the Name, InstanceID, or ID parameters to specify a PSSession.

Enter a variable that contains a session object or a command that creat
es or gets a session object, such as a New-PSSession or Get-PSSession c
ommand. You can also pipe a session object to Enter-PSSession. You can
submit only one PSSession with this parameter. If you enter a variable
that contains more than one PSSession, the command fails.

When you use Exit-PSSession or the EXIT keyword, the interactive sessio
n ends, but the PSSession that you created remains open and available f
or use.

-SessionOption <PSSessionOption>
Sets advanced options for the session. Enter a SessionOption object tha
t you create by using the New-PSSessionOption cmdlet.

The default values for the options are determined by the value of the $
PSSessionOption preference variable, if it is set. Otherwise, the sessi
on uses the system defaults.

For a description of the session options, including the default values,
see New-PSSessionOption. For information about the $PSSessionOption pr
eference variable, see about_Preference_Variables.

-UseSSL [<SwitchParameter>]
Uses the Secure Sockets Layer (SSL) protocol to establish a connection
to the remote computer. By default, SSL is not used.

WS-Management encrypts all Windows PowerShell content transmitted over
the network. UseSSL is an additional protection that sends the data acr
oss an HTTPS connection instead of an HTTP connection.

If you use this parameter, but SSL is not available on the port used fo
r the command, the command fails.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>Enter-PSSession

LocalHost\PS>

Description
-----------
This command starts an interactive session on the local computer. The comma
nd prompt changes to indicate that you are now running commands in a differ
ent session.

The commands that you enter run in the new session, and the results are ret
urned to the default session as text.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>enter-pssession -computer Server01

Server01\PS> get-process powershell > C:\ps-test\process.txt

Server01\PS> exit-pssession
C:\PS>

C:\PS> dir C:\ps-test\process.txt
Get-ChildItem : Cannot find path 'C:\ps-test\process.txt' because it does n
ot exist.
At line:1 char:4
+ dir <<<< c:\ps-test\process.txt

Description
-----------
This command shows how to work in an interactive session with a remote comp
uter.

The first command uses the Enter-PSSession cmdlet to start an interactive s
ession with Server01, a remote computer. When the session starts, the comma
nd prompt changes to include the computer name.

The second command gets the PowerShell process and redirects the output to
the Process.txt file. The command is submitted to the remote computer, and
the file is saved on the remote computer.

The third command uses the Exit keyword to end the interactive session and
close the connection.

The fourth command confirms that the Process.txt file is on the remote comp
uter. A Get-ChildItem ("dir") command on the local computer cannot find the
file.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$s = new-pssession -computername Server01

C:\PS> Enter-PSSession -session $s

Server01\PS>

Description
-----------
These commands use the Session parameter of Enter-PSSession to run the inte
ractive session in an existing Windows PowerShell session (PSSession).




-------------------------- EXAMPLE 4 --------------------------

C:\PS>Enter-PSSession -computername Server01 -port 90 -credential domain01\
user01

Server01\PS>

Description
-----------
This command starts an interactive session with the Server01 computer. It u
ses the Port parameter to specify the port and the Credential parameter to
specify the account of a user with permission to connect to the remote comp
uter.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>Enter-PSSession -computername Server01

Server01:\PS> Exit-PSSession

C:\PS>

Description
-----------
This example shows how to start and stop an interactive session. The first
command uses the Enter-PSSession cmdlet to start an interactive session wit
h the Server01 computer.

The second command uses the Exit-PSSession cmdlet to end the session. You c
an also use the Exit keyword to end the interactive session. Exit-PSSession
and Exit have the same effect.




REMARKS
To see the examples, type: "get-help Enter-PSSession -examples".
For more information, type: "get-help Enter-PSSession -detailed".
For technical information, type: "get-help Enter-PSSession -full".

NAME
Export-Alias

SYNOPSIS
Exports information about currently defined aliases to a file.


SYNTAX
Export-Alias [-Path] <string> [[-Name] <string[]>] [-Append] [-As {Csv | Sc
ript}] [-Description <string>] [-Force] [-NoClobber] [-PassThru] [-Scope <s
tring>] [-Confirm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Export-Alias cmdlet exports the aliases in the current session to a fil
e. If the output file does not exist, the cmdlet will create it.

Export-Alias can export the aliases in a particular scope or all scopes, it
can generate the data in CSV format or as a series of Set-Alias commands t
hat you can add to a session or to a Windows PowerShell profile.

PARAMETERS
-Append [<SwitchParameter>]
Appends the output to the specified file, rather than overwriting the e
xisting contents of that file.

-As <ExportAliasFormat>
Determines the output format. CSV is the default.

Valid values are:

-- CSV: Comma-separated value (CSV) format.
-- Script: Creates a Set-Alias command for each exported alias. If you
name the output file with a .ps1 file name extension, you can run it as
a script to add the aliases to any session.

-Description <string>
Adds a description to the exported file. The description appears as a c
omment at the top of the file, following the header information.

-Force [<SwitchParameter>]
Overwrites the output file, even if the read-only attribute is set on t
he file.

By default, Export-Alias overwrites files without warning, unless the r
ead-only or hidden attribute is set or the NoClobber parameter is used
in the command. The NoClobber parameter takes precedence over the Force
parameter when both are used in a command.

The Force parameter cannot force Export-Alias to overwrite files with t
he hidden attribute.

-Name <string[]>
Specifies the names of the aliases to export. Wildcards are permitted.

By default, Export-Alias exports all aliases in the session or scope.

-NoClobber [<SwitchParameter>]
Prevents Export-Alias from overwriting any files, even if the Force par
ameter is used in the command.

If the NoClobber parameter is omitted, Export-Alias will overwrite an e
xisting file without warning, unless the read-only attribute is set on
the file. NoClobber takes precedence over the Force parameter, which pe
rmits Export-Alias to overwrite a file with the read-only attribute.

NoClobber does not prevent the Append parameter from adding content to
an existing file.

-PassThru [<SwitchParameter>]
Returns objects that represent the aliases that were exported. By defau
lt, this cmdlet does not generate any output.

-Path <string>
Specifies the path to the output file. Wildcards are permitted, but the
resulting path value must resolve to a single file name. This paramete
r is required.

-Scope <string>
Specifies the scope from which the aliases should be exported.

Valid values are "Global", "Local", or "Script", or a number relative t
o the current scope (0 through the number of scopes where 0 is the curr
ent scope and 1 is its parent). "Local" is the default. For more inform
ation, see about_Scopes.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>export-alias -path alias.csv

Description
-----------
This command exports current alias information to a file named Alias.csv in
the current directory.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>export-alias -path alias.csv -noclobber

Description
-----------
This command exports the aliases in the current session to an Alias.csv fil
e.

Because the NoClobber parameter is specified, the command will fail if an A
lias.csv file already exists in the current directory.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>export-alias -path alias.csv -append -description "Appended Aliases"
-force

Description
-----------
This command appends the aliases in the current session to the Alias.csv fi
le.

The command uses the Description parameter to add a description to the comm
ents at the top of the file.

The command also uses the Force parameter to overwrite any existing Alias.c
sv files, even if they have the read-only attribute.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>export-alias -path alias.ps1 -as script

C:\PS> add-content -path $profile -value (get-content alias.ps1)

C:\PS> $s = new-pssession -computername Server01
C:\PS> invoke-command -session $s -filepath .\alias.ps1

Description
-----------
This example shows how to use the script file format that Export-Alias gene
rates.

The first command exports the aliases in the session to the Alias.ps1 file.
It uses the As parameter with a value of Script to generate a file that co
ntains a Set-Alias command for each alias.

The second command adds the aliases in the Alias.ps1 file to the CurrentUse
r-CurrentHost profile. (The path to the profile is saved in the $profile va
riable.) The command uses the Get-Content cmdlet to get the aliases from th
e Alias.ps1 file and the Add-Content cmdlet to add them to the profile. For
more information, see about_Profiles.

The third and fourth commands add the aliases in the Alias.ps1 file to a r
emote session on the Server01 computer. The third command uses the New-PSSe
ssion cmdlet to create the session. The fourth command uses the FilePath pa
rameter of the Invoke-Command cmdlet to run the Alias.ps1 file in the new s
ession.




REMARKS
To see the examples, type: "get-help Export-Alias -examples".
For more information, type: "get-help Export-Alias -detailed".
For technical information, type: "get-help Export-Alias -full".

NAME
Export-CSV

SYNOPSIS
Converts Microsoft .NET Framework objects into a series of comma-separated
value (CSV) variable-length strings and saves the strings in a CSV file.


SYNTAX
Export-CSV [[-Delimiter] <char>] [-Path] <string> -InputObject <psobject> [
-Encoding <string>] [-Force] [-NoClobber] [-NoTypeInformation] [-Confirm] [
-WhatIf] [<CommonParameters>]

Export-CSV [-UseCulture] [-Path] <string> -InputObject <psobject> [-Encodin
g <string>] [-Force] [-NoClobber] [-NoTypeInformation] [-Confirm] [-WhatIf]
[<CommonParameters>]


DESCRIPTION
The Export-CSV cmdlet creates a CSV variable-length file that represents th
e objects that you submit.
You can then use the Import-CSV cmdlet to re-create objects from the CSV st
rings in the files. The resulting objects are CSV versions of the original
objects that consist of string representations of the property values and n
o methods.

You can also use the ConvertTo-CSV and ConvertFrom-CSV cmdlets to convert .
NET Framework objects to CSV strings (and back). Export-CSV is the same as
ConvertTo-CSV, except that it saves the CSV strings in a file.

You can use the parameters of the Export-CSV cmdlet to specify a delimiter
other than a comma or to direct Export-CSV to use the default delimiter for
the current culture.

When you submit multiple objects to Export-CSV, Export-CSV organizes the fi
le based on the properties of the first object that you submit. If the rema
ining objects do not have one of the specified properties, the property val
ue of that object is null, as represented by two consecutive commas. If the
remaining objects have additional properties, those property values are no
t included in the file.

For more information, see Export-CSV, and see the Notes section.

PARAMETERS
-Delimiter <char>
Specifies a delimiter to separate the property values. The default is a
comma (,). Enter a character, such as a colon (:). To specify a semico
lon (;), enclose it in quotation marks.

-Encoding <string>
Specifies the encoding for the exported CSV file. Valid values are Unic
ode, UTF7, UTF8, ASCII, UTF32, BigEndianUnicode, Default, and OEM. The
default is ASCII.

-Force [<SwitchParameter>]
Overwrites the file specified in path without prompting.

-InputObject <psobject>
Specifies the objects to export as CSV strings. Enter a variable that c
ontains the objects or type a command or expression that gets the objec
ts. You can also pipe objects to Export-CSV.

-NoClobber [<SwitchParameter>]
Do not overwrite (replace the contents) of an existing file. By default
, if a file exists in the specified path, Export-CSV overwrites the fil
e without warning.

-NoTypeInformation [<SwitchParameter>]
Omits the type information from the CSV file. By default, the first lin
e of the CSV file contains "#TYPE " followed by the fully-qualified nam
e of the type of the .NET Framework object.

-Path <string>
Specifies the path to the CSV output file. The parameter is required.

-UseCulture [<SwitchParameter>]
Use the list separator for the current culture as the item delimiter. T
he default is a comma (,).

This parameter is very useful in scripts that are being distributed to
users worldwide. To find the list separator for a culture, use the foll
owing command: (Get-Culture).TextInfo.ListSeparator.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-process wmiprvse | select-object basePriority,ID,SessionID,Workin
gSet | export-csv -path data.csv

Description
-----------
This command selects a few properties of the wmiprvse process and exports t
hem to a CSV format file named data.csv.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-process | export-csv processes.csv

C:\PS> get-process | export-csv processes.csv

# In processes.csv

#TYPE System.Diagnostics.Process
__NounName,Name,Handles,VM,WS,PM,NPM,Path,Company,CPU,FileVersion,...
Process,powershell,626,201666560,76058624,61943808,11960,C:\WINDOWS...
Process,powershell,257,151920640,38322176,37052416,7836,C:\WINDOWS\...

Description
-----------
This command exports objects representing the processes on the computer to
the Processes.csv file in the current directory. Because it does not specif
y a delimiter, a comma (,) is used to separate the fields in the file.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-process | export-csv processes.csv -Delimiter ";"

# In processes.csv

#TYPE System.Diagnostics.Process
__NounName;Name;Handles;VM;WS;PM;NPM;Path;Company;CPU;FileVersion;...
Process;powershell;626;201666560;76058624;61943808;11960;C:\WINDOWS...
Process;powershell;257;151920640;38322176;37052416;7836;C:\WINDOWS\...

Description
-----------
This command exports objects representing the processes on the computer to
the Processes.csv file in the current directory. It uses the Delimiter para
meter to specify the semicolon (;). As a result, the fields in the file are
separated by semicolons.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-process | export-csv processes.csv -UseCulture

Description
-----------
This command exports objects representing the processes on the computer to
the Processes.csv file in the current directory. It uses the UseCulture par
ameter to direct Export-CSV to use the delimiter specified by the ListSepar
ator property of the current culture.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-process | export-csv processes.csv -NoTypeInformation

C:\PS> get-process | export-csv processes.csv -NoTypeInformation

# In processes.csv

__NounName,Name,Handles,VM,WS,PM,NPM,Path,Company,CPU,FileVersion,...
Process,powershell,626,201666560,76058624,61943808,11960,C:\WINDOWS...
Process,powershell,257,151920640,38322176,37052416,7836,C:\WINDOWS\...

Description
-----------
This command exports objects representing the processes on the computer to
the Processes.csv file in the current directory. It uses the NoTypeInformat
ion parameter to suppress the type information in the file.




REMARKS
To see the examples, type: "get-help Export-CSV -examples".
For more information, type: "get-help Export-CSV -detailed".
For technical information, type: "get-help Export-CSV -full".

NAME
Export-PSSession

SYNOPSIS
Imports commands from another session and saves them in a Windows PowerShel
l module.


SYNTAX
Export-PSSession [-Session] <PSSession> [-OutputModule] <string> [[-Command
Name] <string[]>] [[-FormatTypeName] <string[]>] [-AllowClobber] [-Argument
List <Object[]>] [-CommandType {Alias | Function | Filter | Cmdlet | Extern
alScript | Application | Script | All}] [-Encoding <string>] [-Force] [-Mod
ule <string[]>] [<CommonParameters>]


DESCRIPTION
The Export-PSSession cmdlet gets cmdlets, functions, aliases, and other com
mand types from another PSSession on a local or remote computer and saves t
hem in a Windows PowerShell module. To add the commands from the module to
the current session, use the Import-Module cmdlet.

Unlike Import-PSSession, which imports commands from another PSSession into
the current session, Export-PSSession saves the commands in a module. The
commands are not imported into the current session.

To export commands, first use the New-PSSession cmdlet to create a PSSessio
n that has the commands that you want to export. Then use the Export-PSSess
ion cmdlet to export the commands. By default, Export-PSSession exports all
commands, except for commands that exist in the current session, but you c
an use the CommandName parameters to specify the commands to export.

The Export-PSSession cmdlet uses the implicit remoting feature of Windows P
owerShell. When you import commands into the current session, they run impl
icitly in the original session or in a similar session on the originating
computer.

PARAMETERS
-AllowClobber [<SwitchParameter>]
Exports the specified commands, even if they have the same names as com
mands in the current session.

If you import a command with the same name as a command in the current
session, the imported command hides or replaces the original commands.
For more information, see about_Command_Precedence.

Export-PSSession does not import commands that have the same names as c
ommands in the current session. The default behavior is designed to pre
vent command name conflicts.

-ArgumentList <Object[]>
Exports the variant of the command that results from using the specifie
d arguments (parameter values).

For example, to export the variant of the Get-Item command in the certi
ficate (Cert:) drive in the PSSession in $s, type "export-pssession -se
ssion $s -command get-item -argumentlist cert:".

-CommandName <string[]>
Exports only the commands with the specified names or name patterns. Wi
ldcards are permitted. Use "CommandName" or its alias, "Name".

By default, Export-PSSession exports all commands from the PSSession ex
cept for commands that have the same names as commands in the current s
ession. This prevents imported commands from hiding or replacing comman
ds in the current session. To export all commands, even those that hide
or replace other commands, use the AllowClobber parameter.

If you use the CommandName parameter, the formatting files for the comm
ands are not exported unless you use the FormatTypeName parameter. Simi
larly, if you use the FormatTypeName parameter, no commands are exporte
d unless you use the CommandName parameter.

-CommandType <CommandTypes>
Exports only the specified types of command objects. Use "CommandType"
or its alias, "Type".

Valid values are:
-- Alias: All Windows PowerShell aliases in the current session.
-- All: All command types. It is the equivalent of "get-command *".
-- Application: All files other than Windows PowerShell files in paths
listed in the Path environment variable ($env:path), including .txt, .e
xe, and .dll files.
-- Cmdlet: The cmdlets in the current session. "Cmdlet" is the default.
-- ExternalScript: All .ps1 files in the paths listed in the Path envir
onment variable ($env:path).
-- Filter and Function: All Windows PowerShell functions.
-- Script: Script blocks in the current session.

-Encoding <string>
Specifies the encoding for the output files. Valid values are "Unicode"
, "UTF7", "UTF8", "ASCII", "UTF32", "BigEndianUnicode", "Default", and
"OEM". The default is "UTF-8".

-Force [<SwitchParameter>]
Overwrites one or more existing output files, even if the file has the
read-only attribute.

-FormatTypeName <string[]>
Exports formatting instructions only for the specified Microsoft .NET F
ramework types. Enter the type names. By default, Export-PSSession expo
rts formatting instructions for all .NET Framework types that are not i
n the System.Management.Automation namespace.

The value of this parameter must be the name of a type that is returned
by a Get-FormatData command in the session from which the commands are
being imported. To get all of the formatting data in the remote sessio
n, type *.

If you use the FormatTypeName parameter, no commands are exported unles
s you use the CommandName parameter.
Similarly, if you use the CommandName parameter, the formatting files f
or the commands are not exported unless you use the FormatTypeName para
meter.

-Module <string[]>
Exports only the commands in the specified Windows PowerShell snap-ins
and modules. Enter the snap-in and module names. Wildcards are not perm
itted.

For more information, see about_PSSnapins and Import-Module.

-OutputModule <string>
Specifies a path (optional) and name for the module that Export-PSSessi
on creates. The default path is $home\Documents\WindowsPowerShell\Modul
es. This parameter is required.

If the module subdirectory or any of the files that Export-PSSession cr
eates already exist, the command fails. To overwrite existing files, us
e the Force parameter.

-Session <PSSession>
Specifies the PSSession from which the commands are exported. Enter a
variable that contains a session object or a command that gets a sessio
n object, such as a Get-PSSession command. This parameter is required.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$s = new-pssession -computerName Server01

C:\PS> export-pssession -session $s -outputModule Server01

Description
-----------
The commands in this example export all commands from a PSSession on the Se
rver01 computer to the Server01 module on the local computer except for com
mands that have the same names as commands in the current session. It also
exports the formatting data for the commands.

The first command creates a PSSession on the Server01 computer. The second
command exports the commands and formatting data from the session into the
Server01 module.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$s = new-pssession -ConnectionUri http://exchange.microsoft.com/mailb
ox -credential exchangeadmin01@hotmail.com -authentication negotiate

C:\PS> export-pssession -session $r -module exch* -commandname get-*, set-*
-formattypename * -outputModule $pshome\Modules\Exchange -encoding ASCII

Description
-----------
These commands export the Get and Set commands from a Microsoft Exchange Se
rver snap-in on a remote computer to an Exchange module in the $pshome\Modu
les directory on the local computer.

Placing the module in the $pshome\Module directory makes it accessible to a
ll users of the computer.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$s = new-pssession -computerName Server01 -credential Server01\User01

C:\PS> export-pssession -session $s -outputModule TestCmdlets -type cmdlet
-commandname *test* -formattypename *

C:\PS> remove-pssession $s

C:\PS> import-module TestCmdlets

C:\PS> get-help test*

C:\PS> test-files

Description
-----------
These commands export cmdlets from a PSSession on a remote computer and sav
e them in a module on the local computer. Then, the commands add the cmdlet
s from the module to the current session so that they can be used.

The first command creates a PSSession on the Server01 computer and saves it
in the $s variable.

The second command exports the cmdlets whose names begin with "Test" from t
he PSSession in $s to the TestCmdlets module on the local computer.

The third command uses the Remove-PSSession cmdlet to delete the PSSession
in $s from the current session. This command shows that the PSSession need
not be active to use the commands that were imported from it.

The fourth command, which can be run in any session at any time, uses the I
mport-Module cmdlet to add the cmdlets in the TestCmdlets module to the cur
rent session.

The fifth command uses the Get-Help cmdlet to get help for cmdlets whose na
mes begin with "Test." After the commands in a module are added to the curr
ent session, you can use the Get-Help and Get-Command cmdlets to learn abou
t the imported commands, just as you would use them for any command in the
session.

The sixth command uses the Test-Files cmdlet, which was exported from the S
erver01 computer and added to the session.

Although it is not evident, the Test-Files command actually runs in a remot
e session on the computer from which the command was imported. Windows Powe
rShell creates a session from information that is stored in the module.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>export-pssession -session $s -AllowClobber -outputModule AllCommands

Description
-----------
This command exports all commands and all formatting data from the PSSessio
n in the $s variable into the current session. The command uses the AllowCl
obber parameter to include commands with the same names as commands in the
current session.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>$options = New-PSSessionOption -NoMachineProfile

C:\PS> $s = new-pssession -computername Server01 -sessionoption $options

C:\PS> export-pssession -session $s -outputModule Server01

C:\PS> remove-pssession $s

C:\PS> new-pssession -computername Server01 -sessionoption $options

C:\PS> import-module Server01

Description
-----------
This example shows how to run the exported commands in a session with parti
cular options when the PSSession from which the commands were exported is c
losed.

When you use Export-PSSession, it saves information about the original PSSe
ssion in the module that it creates. When you import the module, if the ori
ginal remote session is closed, the module will use any open remote session
that connects to originating computer.

If the current session does not include a remote session to the originating
computer, the commands in the module will re-establish a session to that c
omputer. However, Export-PSSession does not save special options, such as t
hose set by using the SessionOption parameter of New-PSSession, in the modu
le.

Therefore, if you want to run the exported commands in a remote session wit
h particular options, you need to create a remote session with the options
that you want before you import the module.

The first command uses the New-PSSessionOption cmdlet to create a PSSession
Option object, and it saves the object in the $options variable.

The second command creates a PSSession that includes the specified options.
The command uses the New-PSSession cmdlet to create a PSSession on the Ser
ver01 computer. It uses the SessionOption parameter to submit the option ob
ject in $options.

The third command uses the Export-PSSession cmdlet to export commands from
the PSSession in $s to the Server01 module.

The fourth command uses the Remove-PSSession cmdlet to delete the PSSession
in the $s variable.

The fifth command uses the New-PSSession cmdlet to create a new PSSession t
hat connects to the Server01 computer. This PSSession also uses the session
options in the $options variable.

The sixth command uses the Import-Module cmdlet to import the commands from
the Server01 module. The commands in the module run in the PSSession on th
e Server01 computer.




REMARKS
To see the examples, type: "get-help Export-PSSession -examples".
For more information, type: "get-help Export-PSSession -detailed".
For technical information, type: "get-help Export-PSSession -full".

NAME
Remove-Item

SYNOPSIS
Deletes the specified items.


SYNTAX
Remove-Item [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Exclud
e <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Recurse]
[-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

Remove-Item [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <stri
ng[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Recurse] [-Confi
rm] [-WhatIf] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Remove-Item cmdlet deletes one or more items. Because it is supported b
y many providers, it can delete many different types of items, including fi
les, directories, registry keys, variables, aliases, and functions.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to remove items that cannot otherwise be changed, suc
h as hidden or read-only files or read-only aliases or variables. The c
mdlet cannot remove constant aliases or variables. Implementation vari
es from provider to provider. For more information, see about_Providers
. Even using the Force parameter, the cmdlet cannot override security r
estrictions.

-Include <string[]>
Deletes only the specified items. The value of this parameter qualifies
the Path parameter. Enter a path element or pattern, such as "*.txt".
Wildcards are permitted.

-LiteralPath <string[]>
Specifies a path to the items being removed. Unlike Path, the value of
LiteralPath is used exactly as it is typed. No characters are interpret
ed as wildcards. If the path includes escape characters, enclose it in
single quotation marks. Single quotation marks tell Windows PowerShell
not to interpret any characters as escape sequences.

-Path <string[]>
Specifies a path to the items being removed. Wildcards are permitted. T
he parameter name ("-Path") is optional.

-Recurse [<SwitchParameter>]
Deletes the items in the specified locations and in all child items of
the locations.

The Recurse parameter in this cmdlet does not work properly.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>remove-item C:\Test\*.*

Description
-----------
This command deletes all of the files with names that include a dot (.) fro
m the C:\Test directory. Because the command specifies a dot, the command d
oes not delete directories or files with no file name extension.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>remove-item * -include *.doc -exclude *1*

Description
-----------
This command deletes from the current directory all files with a .doc file
name extension and a name that does not include "1". It uses the wildcard c
haracter (*) to specify the contents of the current directory. It uses the
Include and Exclude parameters to specify the files to delete.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>remove-item -path C:\Test\hidden-RO-file.txt -force

Description
-----------
This command deletes a file that is both hidden and read-only. It uses the
Path parameter to specify the file. It uses the Force parameter to give per
mission to delete it. Without Force, you cannot delete read-only or hidden
files.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-childitem * -include *.csv -recurse | remove-item

Description
-----------
This command deletes all of the CSV files in the current directory and all
subdirectories recursively.

Because the Recurse parameter in this cmdlet is faulty, the command uses th
e Get-Childitem cmdlet to get the desired files, and it uses the pipeline o
perator to pass them to the Remove-Item cmdlet.

In the Get-ChildItem command, the Path parameter has a value of *, which re
presents the contents of the current directory. It uses the Include paramet
er to specify the CSV file type, and it uses the Recurse parameter to make
the retrieval recursive.

If you try to specify the file type in the path, such as "-path *.csv", the
cmdlet interprets the subject of the search to be a file that has no child
items, and Recurse fails.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>remove-item hklm:\software\mycompany\OldApp -recurse

Description
-----------
This command deletes the OldApp registry key and all of its subkeys and val
ues. It uses the Remove-Item cmdlet to remove the key. The path is specifie
d, but the optional parameter name (Path) is omitted.

The Recurse parameter deletes all of the contents of the OldApp key recursi
vely. If the key contains subkeys and you omit the Recurse parameter, you a
re prompted to confirm that you want to delete the contents of the key.




REMARKS
To see the examples, type: "get-help Remove-Item -examples".
For more information, type: "get-help Remove-Item -detailed".
For technical information, type: "get-help Remove-Item -full".

NAME
Enter-PSSession

SYNOPSIS
Starts an interactive session with a remote computer.


SYNTAX
Enter-PSSession [-ComputerName] <string> [-ApplicationName <string>] [-Auth
entication {Default | Basic | Negotiate | NegotiateWithImplicitCredential |
Credssp | Digest | Kerberos}] [-CertificateThumbprint <string>] [-Configur
ationName <string>] [-Credential <PSCredential>] [-Port <int>] [-SessionOpt
ion <PSSessionOption>] [-UseSSL] [<CommonParameters>]

Enter-PSSession [[-Id] <int>] [<CommonParameters>]

Enter-PSSession [-InstanceId <Guid>] [<CommonParameters>]

Enter-PSSession [-Name <string>] [<CommonParameters>]

Enter-PSSession [[-Session] <PSSession>] [<CommonParameters>]

Enter-PSSession [[-ConnectionURI] <Uri>] [-AllowRedirection] [-Authenticati
on {Default | Basic | Negotiate | NegotiateWithImplicitCredential | Credssp
| Digest | Kerberos}] [-CertificateThumbprint <string>] [-ConfigurationNam
e <string>] [-Credential <PSCredential>] [-SessionOption <PSSessionOption>]
[<CommonParameters>]


DESCRIPTION
The Enter-PSSession cmdlet starts an interactive session with a single remo
te computer. During the session, the commands that you type run on the remo
te computer, just as though you were typing directly on the remote computer
. You can have only one interactive session at a time.

Typically, you use the ComputerName parameter to specify the name of the re
mote computer. However, you can also use a session that you create by using
New-PSSession for the interactive session.

To end the interactive session and disconnect from the remote computer, use
the Exit-PSSession cmdlet, or type "exit".

PARAMETERS
-AllowRedirection [<SwitchParameter>]
Allows redirection of this connection to an alternate Uniform Resource
Identifier (URI).

When you use the ConnectionURI parameter, the remote destination can re
turn an instruction to redirect to a different URI. By default, Windows
PowerShell does not redirect connections, but you can use this paramet
er to allow it to redirect the connection.

Allows redirection of this connection to an alternate URI.

When you use the ConnectionURI parameter, the remote destination can re
turn an instruction to redirect to a different URI. By default, Windows
PowerShell does not redirect connections, but you can use the AllowRed
irection parameter to allow it to redirect the connection.

You can also limit the number of times that the connection is redirecte
d by setting the MaximumConnectionRedirectionCount property of the $PSS
essionOption preference variable, or the MaximumConnectionRedirectionCo
unt property of the value of the SessionOption parameter. The default v
alue is 5. For more information, see the description of the SessionOpti
on parameter, and see New-PSSessionOption.

-ApplicationName <string>
Specifies the application name segment of the connection URI. Use this
parameter to specify the application name when you are not using the Co
nnectionURI parameter in the command.

The default value is the value of the $PSSessionApplicationName prefere
nce variable on the local computer. If this preference variable is not
defined, the default value is WSMAN. This value is appropriate for most
uses. For more information, see about_Preference_Variables.

The WinRM service uses the application name to select a listener to ser
vice the connection request. The value of this parameter should match t
he value of the URLPrefix property of a listener on the remote computer
.

-Authentication <AuthenticationMechanism>
Specifies the mechanism that is used to authenticate the user's credent
ials. Valid values are "Default", "Basic", "Credssp", "Digest", "Kerb
eros", "Negotiate", and "NegotiateWithImplicitCredential". The default
value is "Default".

CredSSP authentication is available only in Windows Vista, Windows Serv
er 2008, and later versions of Windows.

For information about the values of this parameter, see the description
of the System.Management.Automation.Runspaces.AuthenticationMechanism
enumeration in the MSDN (Microsoft Developer Network) library at http:/
/go.microsoft.com/fwlink/?LinkId=144382.

Caution: Credential Security Service Provider (CredSSP) authentication,
in which the user's credentials are passed to a remote computer to be
authenticated, is designed for commands that require authentication on
more than one resource, such as accessing a remote network share. This
mechanism increases the security risk of the remote operation. If the r
emote computer is compromised, the credentials that are passed to it ca
n be used to control the network session.

-CertificateThumbprint <string>
Specifies the digital public key certificate (X509) of a user account t
hat has permission to perform this action. Enter the certificate thumbp
rint of the certificate.

Certificates are used in client certificate-based authentication. They
can be mapped only to local user accounts; they do not work with domain
accounts.

To get a certificate thumbprint, use the Get-Item or Get-ChildItem comm
and in the Windows PowerShell Cert: drive.

-ComputerName <string>
Starts an interactive session with the specified remote computer. Enter
only one computer name. The default is the local computer.

Type the NetBIOS name, an IP address, or a fully qualified domain name
of one or more remote computers. You can also pipe a computer name to E
nter-PSSession.

To use an IP address in the value of the ComputerName parameter, the co
mmand must include the Credential parameter. Also, the computer must be
configured for HTTPS transport or the IP address of the remote compute
r must be included in the WinRM TrustedHosts list on the local computer
. For instructions for adding a computer name to the TrustedHosts list,
see "How to Add a Computer to the Trusted Host List" in about_Remote_
Troubleshooting.

Note: In Windows Vista and later versions of Windows, to include the l
ocal computer in the value of the ComputerName parameter, you must star
t Windows PowerShell with the "Run as administrator" option.

-ConfigurationName <string>
Specifies the session configuration that is used for the interactive se
ssion.

Enter a configuration name or the fully qualified resource URI for a se
ssion configuration. If you specify only the configuration name, the fo
llowing schema URI is prepended: http://schemas.microsoft.com/powershe
ll.

The session configuration for a session is located on the remote comput
er. If the specified session configuration does not exist on the remote
computer, the command fails.

The default value is the value of the $PSSessionConfigurationName prefe
rence variable on the local computer. If this preference variable is no
t set, the default is Microsoft.PowerShell. For more information, see a
bout_Preference_Variables.

-ConnectionURI <Uri>
Specifies a Uniform Resource Identifier (URI) that defines the connecti
on endpoint for the interactive session. The URI must be fully qualifie
d.

The format of this string is as follows:
<Transport>://<ComputerName>:<Port>/<ApplicationName>

The default value is as follows:
http://localhost:80/WSMAN

Valid values for the Transport segment of the URI are HTTP and HTTPS. I
f you do not specify a ConnectionURI, you can use the UseSSL, ComputerN
ame, Port, and ApplicationName parameters to specify the URI values.

If the destination computer redirects the connection to a different URI
, Windows PowerShell prevents the redirection unless you use the AllowR
edirection parameter in the command.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01", "Domain01\User01", or "User@Domain.
com", or enter a PSCredential object, such as one returned by the Get-C
redential cmdlet.

When you type a user name, you will be prompted for a password.

-Id <int>
Specifies the ID of an existing session. Enter-PSSession uses the speci
fied session for the interactive session.

To find the ID of a session, use the Get-PSSession cmdlet.

-InstanceId <Guid>
Specifies the instance ID of an existing session. Enter-PSSession uses
the specified session for the interactive session.

The instance ID is a GUID. To find the instance ID of a session, use th
e Get-PSSession cmdlet. You can also use the Session, Name, or ID param
eters to specify an existing session. Or, you can use the ComputerName
parameter to start a temporary session.

-Name <string>
Specifies the friendly name of an existing session. Enter-PSSession use
s the specified session for the interactive session.

If the name that you specify matches more than one session, the command
fails. You can also use the Session, InstanceID, or ID parameters to s
pecify an existing session. Or, you can use the ComputerName parameter
to start a temporary session.

To establish a friendly name for a session, use the Name parameter of t
he New-PSSession cmdlet.

-Port <int>
Specifies the network port on the remote computer used for this comman
d. The default is port 80 (the HTTP port).

Before using an alternate port, you must configure the WinRM listener o
n the remote computer to listen at that port. Use the following command
s to configure the listener:

1. winrm delete winrm/config/listener?Address=*+Transport=HTTP
2. winrm create winrm/config/listener?Address=*+Transport=HTTP @{Port="
<port-number>"}

Do not use the Port parameter unless you must. The port setting in the
command applies to all computers or sessions on which the command runs.
An alternate port setting might prevent the command from running on al
l computers.

-Session <PSSession>
Specifies a Windows PowerShell session (PSSession) to use for the inter
active session. This parameter takes a session object. You can also use
the Name, InstanceID, or ID parameters to specify a PSSession.

Enter a variable that contains a session object or a command that creat
es or gets a session object, such as a New-PSSession or Get-PSSession c
ommand. You can also pipe a session object to Enter-PSSession. You can
submit only one PSSession with this parameter. If you enter a variable
that contains more than one PSSession, the command fails.

When you use Exit-PSSession or the EXIT keyword, the interactive sessio
n ends, but the PSSession that you created remains open and available f
or use.

-SessionOption <PSSessionOption>
Sets advanced options for the session. Enter a SessionOption object tha
t you create by using the New-PSSessionOption cmdlet.

The default values for the options are determined by the value of the $
PSSessionOption preference variable, if it is set. Otherwise, the sessi
on uses the system defaults.

For a description of the session options, including the default values,
see New-PSSessionOption. For information about the $PSSessionOption pr
eference variable, see about_Preference_Variables.

-UseSSL [<SwitchParameter>]
Uses the Secure Sockets Layer (SSL) protocol to establish a connection
to the remote computer. By default, SSL is not used.

WS-Management encrypts all Windows PowerShell content transmitted over
the network. UseSSL is an additional protection that sends the data acr
oss an HTTPS connection instead of an HTTP connection.

If you use this parameter, but SSL is not available on the port used fo
r the command, the command fails.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>Enter-PSSession

LocalHost\PS>

Description
-----------
This command starts an interactive session on the local computer. The comma
nd prompt changes to indicate that you are now running commands in a differ
ent session.

The commands that you enter run in the new session, and the results are ret
urned to the default session as text.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>enter-pssession -computer Server01

Server01\PS> get-process powershell > C:\ps-test\process.txt

Server01\PS> exit-pssession
C:\PS>

C:\PS> dir C:\ps-test\process.txt
Get-ChildItem : Cannot find path 'C:\ps-test\process.txt' because it does n
ot exist.
At line:1 char:4
+ dir <<<< c:\ps-test\process.txt

Description
-----------
This command shows how to work in an interactive session with a remote comp
uter.

The first command uses the Enter-PSSession cmdlet to start an interactive s
ession with Server01, a remote computer. When the session starts, the comma
nd prompt changes to include the computer name.

The second command gets the PowerShell process and redirects the output to
the Process.txt file. The command is submitted to the remote computer, and
the file is saved on the remote computer.

The third command uses the Exit keyword to end the interactive session and
close the connection.

The fourth command confirms that the Process.txt file is on the remote comp
uter. A Get-ChildItem ("dir") command on the local computer cannot find the
file.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$s = new-pssession -computername Server01

C:\PS> Enter-PSSession -session $s

Server01\PS>

Description
-----------
These commands use the Session parameter of Enter-PSSession to run the inte
ractive session in an existing Windows PowerShell session (PSSession).




-------------------------- EXAMPLE 4 --------------------------

C:\PS>Enter-PSSession -computername Server01 -port 90 -credential domain01\
user01

Server01\PS>

Description
-----------
This command starts an interactive session with the Server01 computer. It u
ses the Port parameter to specify the port and the Credential parameter to
specify the account of a user with permission to connect to the remote comp
uter.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>Enter-PSSession -computername Server01

Server01:\PS> Exit-PSSession

C:\PS>

Description
-----------
This example shows how to start and stop an interactive session. The first
command uses the Enter-PSSession cmdlet to start an interactive session wit
h the Server01 computer.

The second command uses the Exit-PSSession cmdlet to end the session. You c
an also use the Exit keyword to end the interactive session. Exit-PSSession
and Exit have the same effect.




REMARKS
To see the examples, type: "get-help Enter-PSSession -examples".
For more information, type: "get-help Enter-PSSession -detailed".
For technical information, type: "get-help Enter-PSSession -full".

NAME
Exit-PSSession

SYNOPSIS
Ends an interactive session with a remote computer.


SYNTAX
Exit-PSSession [<CommonParameters>]


DESCRIPTION
The Exit-PSSession cmdlet ends interactive sessions that you started by usi
ng Enter-PSSession.

You can also use the Exit keyword to end an interactive session. The effect
is the same as using Exit-PSSession.

PARAMETERS
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>Enter-PSSession -computername Server01

Server01\PS> Exit-PSSession

C:\PS>

Description
-----------
These commands start and then stop an interactive session with the Server01
remote computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$s = new-pssession -computername Server01

C:\PS> Enter-PSSession -session $s

Server01\PS> Exit-PSSession

C:\PS> $s

Id Name ComputerName State ConfigurationName
-- ---- ------------ ----- -----------------
1 Session1 Server01 Opened Microsoft.PowerShell

Description
-----------
These commands start and stop an interactive session with the Server01 comp
uter that uses a Windows PowerShell session (PSSession).

Because the interactive session was started by using a Windows PowerShell s
ession (PSSession), the PSSession is still available when the interactive s
ession ends. If you use the ComputerName parameter, Enter-PSSession creates
a temporary session that it closes when the interactive session ends.

The first command uses the New-PSSession cmdlet to create a PSSession on th
e Server01 computer. The command saves the PSSession in the $s variable.

The second command uses the Enter-PSSession cmdlet to start an interactive
session using the PSSession in $s.

The third command uses the Exit-PSSession cmdlet to stop the interactive se
ssion.

The final command displays the PSSession in the $s variable. The State prop
erty shows the PSSession is still open and available for use.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>Enter-PSSession -computername Server01

Server01\PS> exit

C:\PS>

Description
-----------
This command uses the Exit keyword to stop an interactive session started b
y using the Enter-PSSession cmdlet. The Exit keyword has the same effect as
using Exit-PSSession.




REMARKS
To see the examples, type: "get-help Exit-PSSession -examples".
For more information, type: "get-help Exit-PSSession -detailed".
For technical information, type: "get-help Exit-PSSession -full".

NAME
Export-Alias

SYNOPSIS
Exports information about currently defined aliases to a file.


SYNTAX
Export-Alias [-Path] <string> [[-Name] <string[]>] [-Append] [-As {Csv | Sc
ript}] [-Description <string>] [-Force] [-NoClobber] [-PassThru] [-Scope <s
tring>] [-Confirm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Export-Alias cmdlet exports the aliases in the current session to a fil
e. If the output file does not exist, the cmdlet will create it.

Export-Alias can export the aliases in a particular scope or all scopes, it
can generate the data in CSV format or as a series of Set-Alias commands t
hat you can add to a session or to a Windows PowerShell profile.

PARAMETERS
-Append [<SwitchParameter>]
Appends the output to the specified file, rather than overwriting the e
xisting contents of that file.

-As <ExportAliasFormat>
Determines the output format. CSV is the default.

Valid values are:

-- CSV: Comma-separated value (CSV) format.
-- Script: Creates a Set-Alias command for each exported alias. If you
name the output file with a .ps1 file name extension, you can run it as
a script to add the aliases to any session.

-Description <string>
Adds a description to the exported file. The description appears as a c
omment at the top of the file, following the header information.

-Force [<SwitchParameter>]
Overwrites the output file, even if the read-only attribute is set on t
he file.

By default, Export-Alias overwrites files without warning, unless the r
ead-only or hidden attribute is set or the NoClobber parameter is used
in the command. The NoClobber parameter takes precedence over the Force
parameter when both are used in a command.

The Force parameter cannot force Export-Alias to overwrite files with t
he hidden attribute.

-Name <string[]>
Specifies the names of the aliases to export. Wildcards are permitted.

By default, Export-Alias exports all aliases in the session or scope.

-NoClobber [<SwitchParameter>]
Prevents Export-Alias from overwriting any files, even if the Force par
ameter is used in the command.

If the NoClobber parameter is omitted, Export-Alias will overwrite an e
xisting file without warning, unless the read-only attribute is set on
the file. NoClobber takes precedence over the Force parameter, which pe
rmits Export-Alias to overwrite a file with the read-only attribute.

NoClobber does not prevent the Append parameter from adding content to
an existing file.

-PassThru [<SwitchParameter>]
Returns objects that represent the aliases that were exported. By defau
lt, this cmdlet does not generate any output.

-Path <string>
Specifies the path to the output file. Wildcards are permitted, but the
resulting path value must resolve to a single file name. This paramete
r is required.

-Scope <string>
Specifies the scope from which the aliases should be exported.

Valid values are "Global", "Local", or "Script", or a number relative t
o the current scope (0 through the number of scopes where 0 is the curr
ent scope and 1 is its parent). "Local" is the default. For more inform
ation, see about_Scopes.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>export-alias -path alias.csv

Description
-----------
This command exports current alias information to a file named Alias.csv in
the current directory.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>export-alias -path alias.csv -noclobber

Description
-----------
This command exports the aliases in the current session to an Alias.csv fil
e.

Because the NoClobber parameter is specified, the command will fail if an A
lias.csv file already exists in the current directory.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>export-alias -path alias.csv -append -description "Appended Aliases"
-force

Description
-----------
This command appends the aliases in the current session to the Alias.csv fi
le.

The command uses the Description parameter to add a description to the comm
ents at the top of the file.

The command also uses the Force parameter to overwrite any existing Alias.c
sv files, even if they have the read-only attribute.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>export-alias -path alias.ps1 -as script

C:\PS> add-content -path $profile -value (get-content alias.ps1)

C:\PS> $s = new-pssession -computername Server01
C:\PS> invoke-command -session $s -filepath .\alias.ps1

Description
-----------
This example shows how to use the script file format that Export-Alias gene
rates.

The first command exports the aliases in the session to the Alias.ps1 file.
It uses the As parameter with a value of Script to generate a file that co
ntains a Set-Alias command for each alias.

The second command adds the aliases in the Alias.ps1 file to the CurrentUse
r-CurrentHost profile. (The path to the profile is saved in the $profile va
riable.) The command uses the Get-Content cmdlet to get the aliases from th
e Alias.ps1 file and the Add-Content cmdlet to add them to the profile. For
more information, see about_Profiles.

The third and fourth commands add the aliases in the Alias.ps1 file to a r
emote session on the Server01 computer. The third command uses the New-PSSe
ssion cmdlet to create the session. The fourth command uses the FilePath pa
rameter of the Invoke-Command cmdlet to run the Alias.ps1 file in the new s
ession.




REMARKS
To see the examples, type: "get-help Export-Alias -examples".
For more information, type: "get-help Export-Alias -detailed".
For technical information, type: "get-help Export-Alias -full".

NAME
Export-Clixml

SYNOPSIS
Creates an XML-based representation of an object or objects and stores it i
n a file.


SYNTAX
Export-Clixml [-Path] <string> -InputObject <psobject> [-Depth <int>] [-Enc
oding <string>] [-Force] [-NoClobber] [-Confirm] [-WhatIf] [<CommonParamete
rs>]


DESCRIPTION
The Export-Clixml cmdlet creates an XML-based representation of an object o
r objects and stores it in a file. You can then use the Import-CLIXML cmdle
t to re-create the saved object based on the contents of that file.

This cmdlet is similar to ConvertTo-XML, except that Export-Clixml stores t
he resulting XML in a file. ConvertTo-XML returns the XML, so you can conti
nue to process it in Windows PowerShell.

PARAMETERS
-Depth <int>
Specifies how many levels of contained objects are included in the XML
representation. The default value is 2.

The default value can be overridden for the object type in the Types.ps
1xml files. For more information, see about_Types.ps1xml.

-Encoding <string>
Specifies the type of encoding for the target file. Valid values are AS
CII, UTF8, UTF7, UTF32, Unicode, BigEndianUnicode, Default, and OEM. UT
F8 is the default.

-Force [<SwitchParameter>]
Causes the cmdlet to clear the read-only attribute of the output file i
f necessary. The cmdlet will attempt to reset the read-only attribute
when the command completes.

-InputObject <psobject>
Specifies the object to be converted. Enter a variable that contains th
e objects, or type a command or expression that gets the objects. You c
an also pipe objects to Export-Clixml.

-NoClobber [<SwitchParameter>]
Ensures that the cmdlet does not overwrite the contents of an existing
file. By default, if a file exists in the specified path, Export-Clixml
overwrites the file without warning.

-Path <string>
Specifies the path to the file where the XML representation of the obje
ct will be stored.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>"This is a test" | export-clixml sample.xml

Description
-----------
This command creates an XML file that stores a representation of the string
, "This is a test".




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-acl C:\test.txt | export-clixml -Path fileacl.xml

C:\PS> $fileacl = import-clixml fileacl.xml

Description
-----------
This example shows how to export an object to an XML file and then create a
n object by importing the XML from the file.

The first command uses the Get-ACL cmdlet to get the security descriptor of
the Test.txt file. It uses a pipeline operator to pass the security descri
ptor to Export-Clixml, which stores an XML-based representation of the obje
ct in a file named FileACL.xml.

The second command uses the Import-Clixml cmdlet to create an object from t
he XML in the FileACL.xml file. Then, it saves the object in the $FileAcl v
ariable.




REMARKS
To see the examples, type: "get-help Export-Clixml -examples".
For more information, type: "get-help Export-Clixml -detailed".
For technical information, type: "get-help Export-Clixml -full".

NAME
Export-Console

SYNOPSIS
Exports the names of snap-ins in the current session to a console file.


SYNTAX
Export-Console [[-Path] <string>] [-Force] [-NoClobber] [-Confirm] [-WhatIf
] [<CommonParameters>]


DESCRIPTION
The Export-Console cmdlet exports the names of the Windows PowerShell snap-
ins in the current session to a Windows PowerShell console file (.psc1). Yo
u can use this cmdlet to save the snap-ins for use in future sessions.

To add the snap-ins in the .psc1 console file to a session, start Windows P
owerShell (Powershell.exe) at the command line by using Cmd.exe or another
Windows PowerShell session, and then use the PSConsoleFile parameter of Pow
ershell.exe to specify the console file.

For more information about Windows PowerShell snap-ins, see about_PSSnapins
.

PARAMETERS
-Force [<SwitchParameter>]
Overwrites the data in a console file without warning, even if the file
has the read-only attribute. The read-only attribute is changed and is
not reset when the command completes.

-NoClobber [<SwitchParameter>]
Will not overwrite (replace the contents of) an existing console file.
By default, if a file exists in the specified path, Export-Console over
writes the file without warning.

-Path <string>
Specifies a path and file name for the console file (*.psc1). Enter a p
ath (optional) and name. Wildcards are not permitted.

If you type only a file name, Export-Console creates a file with that n
ame and the ".psc1" file name extension in the current directory.

This parameter is required unless you have opened Windows PowerShell wi
th the PSConsoleFile parameter or exported a console file during the cu
rrent session. It is also required when you use the NoClobber parameter
to prevent the current console file from being overwritten.

If you omit this parameter, Export-Console overwrites (replaces the con
tent of) the console file that was used most recently in this session.
The path to the most recently used console file is stored in the value
of the $ConsoleFileName automatic variable. For more information, see a
bout_Automatic_Variables.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>export-console -path $pshome\Consoles\ConsoleS1.psc1

Description
-----------
This command exports the names of Windows PowerShell snap-ins in the curren
t session to the ConsoleS1.psc1 file in the Consoles subdirectory of the Wi
ndows PowerShell installation directory, $pshome.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>export-console

Description
-----------
This command exports the names of Windows PowerShell snap-ins from current
session to the Windows PowerShell console file that was most recently used
in the current session. It overwrites the previous file contents.

If you have not exported a console file during the current session, you are
prompted for permission to continue and then prompted for a file name.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>add-pssnapin NewPSSnapin

C:\PS> export-console -path NewPSSnapinConsole.psc1

C:\PS> powershell.exe -PsConsoleFile NewPsSnapinConsole.psc1

Description
-----------
These commands add the NewPSSnapin Windows PowerShell snap-in to the curren
t session, export the names of Windows PowerShell snap-ins in the current s
ession to a console file, and then start a Windows PowerShell session with
the console file.

The first command uses the Add-PSSnapin cmdlet to add the NewPSSnapin snap-
in to the current session. You can only add Windows PowerShell snap-ins tha
t are registered on your system.

The second command exports the Windows PowerShell snap-in names to the NewP
SSnapinConsole.psc1 file.

The third command starts Windows PowerShell with the NewPSSnapinConsole.psc
1 file. Because the console file includes the Windows PowerShell snap-in na
me, the cmdlets and providers in the snap-in are available in the current s
ession.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>export-console -path Console01

C:\PS> notepad console01.psc1

<?xml version="1.0" encoding="utf-8"?>
<PSConsoleFile ConsoleSchemaVersion="1.0">
<PSVersion>2.0</PSVersion>
<PSSnapIns>
<PSSnapIn Name="NewPSSnapin" />
</PSSnapIns>
</PSConsoleFile>

Description
-----------
This command exports the names of the Windows PowerShell snap-ins in the cu
rrent session to the Console01.psc1 file in the current directory.

The second command displays the contents of the Console01.psc1 file in Note
pad.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>powershell.exe -PSConsoleFile Console01.psc1

C:\PS> add-pssnapin MySnapin

C:\PS> export-console NewConsole.psc1

C:\PS> $consolefilename

C:\PS> add-pssnapin SnapIn03

C:\PS> export-console

Description
-----------
This example shows how to use the $ConsoleFileName automatic variable to de
termine the console file that will be updated if you use Export-Console wit
hout a Path parameter value.

The first command uses the PSConsoleFile parameter of PowerShell.exe to ope
n Windows PowerShell with the Console01.psc1 file.

The second command uses the Add-PSSnapin cmdlet to add the MySnapin Windows
PowerShell snap-in to the current session.

The third command uses the Export-Console cmdlet to export the names of all
the Windows PowerShell snap-ins in the session to the NewConsole.psc1 file
.

The fourth command uses the $ConsoleFileName parameter to display the most
recently used console file. The sample output shows that NewConsole.ps1 is
the most recently used file.

The fifth command adds SnapIn03 to the current console.

The sixth command uses the ExportConsole cmdlet without a Path parameter. T
his command exports the names of all the Windows PowerShell snap-ins in the
current session to the most recently used file, NewConsole.psc1.




REMARKS
To see the examples, type: "get-help Export-Console -examples".
For more information, type: "get-help Export-Console -detailed".
For technical information, type: "get-help Export-Console -full".

NAME
Export-Counter

SYNOPSIS
The Export-Counter cmdlet takes PerformanceCounterSampleSet objects and exp
orts them as counter log files.


SYNTAX
Export-Counter [-Path] <string> -InputObject <PerformanceCounterSampleSet[]
> [-Circular <switch>] [-FileFormat <string>] [-Force <switch>] [-MaxSize <
int>] [<CommonParameters>]


DESCRIPTION
The Export-Counter cmdlet exports performance counter data (PerformanceCoun
terSampleSet objects) to log files in binary performance log (.blg), comma-
separated value (.csv), or tab-separated value (.tsv) format. You can use
this cmdlet to log or relog performance counter data.

Export-Counter is designed to export data that is returned by the Get-Count
er and Import-Counter cmdlets.

Note: Export-Counter runs only on Windows 7, Windows Server 2008 R2, and la
ter versions of Windows.

PARAMETERS
-Circular <switch>
Indicates that output file should be a circular log with first in, firs
t out (FIFO) format. When you include this parameter, the MaxSize param
eter is required.

-FileFormat <string>
Specifies the output format of the output log file. Valid values are C
SV, TSV, and BLG. The default value is BLG.

-Force <switch>
Overwrites and replaces an existing file if one exists in the location
specified by the Path parameter.

-InputObject <PerformanceCounterSampleSet[]>
Specifies the counter data to export. Enter a variable that contains th
e data or a command that gets the data, such as a Get-Counter or Import
-Counter command.

-MaxSize <int>
Specifies the maximum size of the output file.

If the Circular parameter is specified, then when the log file reaches
the specified maximum size, the oldest entries are deleted as newer one
s are added. If the Circular parameter is not specified, then when the
log file reaches the specified maximum size, no new data is added and t
he cmdlet generates a non-terminating error.

-Path <string>
Specifies the path and file name of the output file. Enter a relative o
r absolute path on the local computer, or a Uniform Naming Convention (
UNC) path to a remote computer, such as \\Computer\Share\file.blg. This
parameter is required.

Note: The file format is determined by the value of the FileFormat para
meter, not by the file name extension in the path.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS># Export-Counter

Description
-----------
This command exports counter data to a .blg file.

The command uses the Get-Counter cmdlet to collect processor time data. It
uses a pipeline operator (|) to send the data to the Export-Counter cmdlet.
The Export-Counter command uses the Path variable to specify the output fi
le.

C:\PS> get-counter "\Processor(*)\% Processor Time" -max 50 | export-counte
r -path $home\counters.blg

Because the data set might be very large, this command sends the data to Ex
port-Counter through the pipeline. If the data were saved in a variable, th
e command might use a disproportionate amount of memory.




-------------------------- EXAMPLE 2 --------------------------

C:\PS># Export-Counter

Description
-----------
These commands convert a CSV file to a counter data BLG format.

The first command uses the built-in Windows PowerShell conversion feature t
o store the value of 1 gigabyte (GB) in bytes in the $1GBinBytes variable.
When you type a value followed by K (kilobyte), MB (megabyte), or GB, Windo
ws PowerShell returns the value in bytes.

C:\PS> $1GBinBytes = 1GB


The second command uses the Import-Counter cmdlet to import performance cou
nter data from the Threads.csv file. The example presumes that this file wa
s previously exported by using the Export-Counter cmdlet.

A pipeline operator (|) sends the imported data to the Export-Counter cmdle
t. The command uses the Path parameter to specify the location of the outpu
t file. It uses the Circular and MaxSize parameters to direct Export-Counte
r to create a circular log that wraps at 1 GB.

C:\PS> import-counter threads.csv | export-counter -path threadtest.blg -ci
rcular -maxsize $1GBinBytes




-------------------------- EXAMPLE 3 --------------------------

C:\PS># Export-Counter

Description
-----------
This example shows how to get performance counter data from a remote comput
er and save the data in a file on the remote computer.


The first command uses the Get-Counter cmdlet to collect working set counte
r data from Server01, a remote computer. The command saves the data in the
$c variable.

C:\PS> $c = get-counter -computername Server01 -counter "\Process(*)\Workin
g Set - Private" -maxSamples 20



The second command uses a pipeline operator (|) to send the data in $c to t
he Export-Counter cmdlet, which saves it in the Workingset.blg file in the
Perf share on the Server01 computer.

C:\PS> $c | export-counter -path \\Server01\Perf\WorkingSet.blg




-------------------------- EXAMPLE 4 --------------------------

C:\PS># Export-Counter

Description
-----------
This example shows how to use the Import-Counter and Export-Counter cmdlets
to relog existing data.

The first command uses the Import-Counter cmdlet to import performance coun
ter data from the DiskSpace.blg log. It saves the data in the $all variable
. This file contains samples of the "LogicalDisk\% Free Space" counter on m
ore than 200 remote computers in the enterprise.

C:\PS> $all = import-counter DiskSpace.blg


The second command uses the CounterSamples property of the sample set objec
t in $all and the Where-Object cmdlet (alias = "where") to select objects w
ith CookedValues of less than 15 (percent). The command saves the results i
n the $lowSpace variable.

C:\PS> $lowSpace = $all.countersamples | where {$_.cookedvalues -lt 15}


The third command uses a pipeline operator (|) to send the data in the $low
Space variable to the Export-Counter cmdlet. The command uses the path vari
able to indicate that the selected data should be logged in the LowDiskSpac
e.blg file.

C:\PS> $lowSpace | export-counter -path LowDiskSpace.blg




REMARKS
To see the examples, type: "get-help Export-Counter -examples".
For more information, type: "get-help Export-Counter -detailed".
For technical information, type: "get-help Export-Counter -full".

NAME
Export-CSV

SYNOPSIS
Converts Microsoft .NET Framework objects into a series of comma-separated
value (CSV) variable-length strings and saves the strings in a CSV file.


SYNTAX
Export-CSV [[-Delimiter] <char>] [-Path] <string> -InputObject <psobject> [
-Encoding <string>] [-Force] [-NoClobber] [-NoTypeInformation] [-Confirm] [
-WhatIf] [<CommonParameters>]

Export-CSV [-UseCulture] [-Path] <string> -InputObject <psobject> [-Encodin
g <string>] [-Force] [-NoClobber] [-NoTypeInformation] [-Confirm] [-WhatIf]
[<CommonParameters>]


DESCRIPTION
The Export-CSV cmdlet creates a CSV variable-length file that represents th
e objects that you submit.
You can then use the Import-CSV cmdlet to re-create objects from the CSV st
rings in the files. The resulting objects are CSV versions of the original
objects that consist of string representations of the property values and n
o methods.

You can also use the ConvertTo-CSV and ConvertFrom-CSV cmdlets to convert .
NET Framework objects to CSV strings (and back). Export-CSV is the same as
ConvertTo-CSV, except that it saves the CSV strings in a file.

You can use the parameters of the Export-CSV cmdlet to specify a delimiter
other than a comma or to direct Export-CSV to use the default delimiter for
the current culture.

When you submit multiple objects to Export-CSV, Export-CSV organizes the fi
le based on the properties of the first object that you submit. If the rema
ining objects do not have one of the specified properties, the property val
ue of that object is null, as represented by two consecutive commas. If the
remaining objects have additional properties, those property values are no
t included in the file.

For more information, see Export-CSV, and see the Notes section.

PARAMETERS
-Delimiter <char>
Specifies a delimiter to separate the property values. The default is a
comma (,). Enter a character, such as a colon (:). To specify a semico
lon (;), enclose it in quotation marks.

-Encoding <string>
Specifies the encoding for the exported CSV file. Valid values are Unic
ode, UTF7, UTF8, ASCII, UTF32, BigEndianUnicode, Default, and OEM. The
default is ASCII.

-Force [<SwitchParameter>]
Overwrites the file specified in path without prompting.

-InputObject <psobject>
Specifies the objects to export as CSV strings. Enter a variable that c
ontains the objects or type a command or expression that gets the objec
ts. You can also pipe objects to Export-CSV.

-NoClobber [<SwitchParameter>]
Do not overwrite (replace the contents) of an existing file. By default
, if a file exists in the specified path, Export-CSV overwrites the fil
e without warning.

-NoTypeInformation [<SwitchParameter>]
Omits the type information from the CSV file. By default, the first lin
e of the CSV file contains "#TYPE " followed by the fully-qualified nam
e of the type of the .NET Framework object.

-Path <string>
Specifies the path to the CSV output file. The parameter is required.

-UseCulture [<SwitchParameter>]
Use the list separator for the current culture as the item delimiter. T
he default is a comma (,).

This parameter is very useful in scripts that are being distributed to
users worldwide. To find the list separator for a culture, use the foll
owing command: (Get-Culture).TextInfo.ListSeparator.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-process wmiprvse | select-object basePriority,ID,SessionID,Workin
gSet | export-csv -path data.csv

Description
-----------
This command selects a few properties of the wmiprvse process and exports t
hem to a CSV format file named data.csv.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-process | export-csv processes.csv

C:\PS> get-process | export-csv processes.csv

# In processes.csv

#TYPE System.Diagnostics.Process
__NounName,Name,Handles,VM,WS,PM,NPM,Path,Company,CPU,FileVersion,...
Process,powershell,626,201666560,76058624,61943808,11960,C:\WINDOWS...
Process,powershell,257,151920640,38322176,37052416,7836,C:\WINDOWS\...

Description
-----------
This command exports objects representing the processes on the computer to
the Processes.csv file in the current directory. Because it does not specif
y a delimiter, a comma (,) is used to separate the fields in the file.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-process | export-csv processes.csv -Delimiter ";"

# In processes.csv

#TYPE System.Diagnostics.Process
__NounName;Name;Handles;VM;WS;PM;NPM;Path;Company;CPU;FileVersion;...
Process;powershell;626;201666560;76058624;61943808;11960;C:\WINDOWS...
Process;powershell;257;151920640;38322176;37052416;7836;C:\WINDOWS\...

Description
-----------
This command exports objects representing the processes on the computer to
the Processes.csv file in the current directory. It uses the Delimiter para
meter to specify the semicolon (;). As a result, the fields in the file are
separated by semicolons.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-process | export-csv processes.csv -UseCulture

Description
-----------
This command exports objects representing the processes on the computer to
the Processes.csv file in the current directory. It uses the UseCulture par
ameter to direct Export-CSV to use the delimiter specified by the ListSepar
ator property of the current culture.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-process | export-csv processes.csv -NoTypeInformation

C:\PS> get-process | export-csv processes.csv -NoTypeInformation

# In processes.csv

__NounName,Name,Handles,VM,WS,PM,NPM,Path,Company,CPU,FileVersion,...
Process,powershell,626,201666560,76058624,61943808,11960,C:\WINDOWS...
Process,powershell,257,151920640,38322176,37052416,7836,C:\WINDOWS\...

Description
-----------
This command exports objects representing the processes on the computer to
the Processes.csv file in the current directory. It uses the NoTypeInformat
ion parameter to suppress the type information in the file.




REMARKS
To see the examples, type: "get-help Export-CSV -examples".
For more information, type: "get-help Export-CSV -detailed".
For technical information, type: "get-help Export-CSV -full".

NAME
Export-FormatData

SYNOPSIS
Saves formatting data from the current session in a formatting file.


SYNTAX
Export-FormatData [-Force] [-IncludeScriptBlock] [-InputObject <ExtendedTyp
eDefinition[]>] [-NoClobber] [-Path <string>] [<CommonParameters>]


DESCRIPTION
The Export-FormatData cmdlet creates Windows PowerShell formatting files (f
ormat.ps1xml) from the formatting objects in the current session. It takes
the ExtendedTypeDefinition objects that Get-FormatData returns and saves th
em in a file in XML format.

Windows PowerShell uses the data in formatting files (format.ps1xml) to gen
erate the default display of Microsoft .NET Framework objects in the sessio
n. You can view and edit the formatting files and use the Update-FormatData
cmdlet to add the formatting data to a session.

For more information about formatting files in Windows PowerShell, see abou
t_Format.ps1xml.

PARAMETERS
-Force [<SwitchParameter>]
Overwrites an existing output file, even if the file has the read-only
attribute.

-IncludeScriptBlock [<SwitchParameter>]
Determines whether script blocks in the format data are exported.

Because script blocks contain code and can be used maliciously, they ar
e not exported by default.

-InputObject <ExtendedTypeDefinition[]>
Specifies the format data objects to be exported. Enter a variable that
contains the objects or a command that gets the objects, such as a Get
-FormatData command. You can also pipe the objects from Get-FormatData
to Export-FormatData.

-NoClobber [<SwitchParameter>]
Prevents the cmdlet from overwriting existing files. By default, Export
-FormatData overwrites files without warning unless the file has the re
ad-only attribute.

To direct Export-FormatData to overwrite read-only files, use the Force
parameter.

-Path <string>
Specifies a location for the output file. Enter a path (optional) and
file name with a format.ps1xml file name extension. If you omit the pat
h, Export-FormatData creates the file in the current directory.

If you use a file name extension other than .ps1xml, the Update-FormatD
ata cmdlet will not recognize the file.

If you specify an existing file, Export-FormatData overwrites the file
without warning, unless the file has the read-only attribute. To overwr
ite a read-only file, use the Force parameter. To prevent files from be
ing overwritten, use the NoClobber parameter.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-formatdata -typename * | export-formatdata -path allformat.ps1xml
-IncludeScriptBlock

Description
-----------
This command exports all of the format data in the session to the AllFormat
.ps1xml file.

The command uses the Get-FormatData cmdlet to get the format data in the se
ssion. A value of * (all) for the TypeName parameter directs the cmdlet to
get all of the data in the session.

The command uses a pipeline operator (|) to send the format data from the G
et-FormatData command to the Export-FormatData cmdlet, which exports the fo
rmat data to the AllFormat.ps1 file.

The Export-FormatData command uses the IncludeScriptBlock parameter to incl
ude script blocks in the format data in the file.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$f = get-formatdata -typename helpinfoshort

C:\PS> export-formatdata -inputObject $f -path c:\test\help.format.ps1xml -
IncludeScriptBlock

Description
-----------
These commands export the format data for the HelpInfoShort type to the Hel
p.format.ps1xml file.

The first command uses the Get-FormatData cmdlet to get the format data for
the HelpInfoShort type, and it saves it in the $f variable.

The second command uses the InputObject parameter of the Export-FormatData
to enter the format data saved in the $f variable. It also uses the Include
ScriptBlock parameter to include script blocks in the output.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-formatdata -typename System.Diagnostics.Process | export-FormatDa
ta -path process.format.ps1xml

C:\PS> Update-FormatData -prependPath .\process.format.ps1xml

C:\PS> get-process p*

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
323 5600 powershell
336 3900 powershell_ise
138 4076 PresentationFontCache

Description
-----------
This example shows the effect of omitting the IncludeScriptBlock parameter
from an Export-FormatData command.

The first command uses the Get-FormatData cmdlet to get the format data for
the System.Diagnostics.Process object that the Get-Process cmdlet returns.
The command uses a pipeline operator (|) to send the formatting data to th
e Export-FormatData cmdlet, which exports it to the Process.format.ps1xml f
ile in the current directory.

In this case, the Export-FormatData command does not use the IncludeScriptB
lock parameter.

The second command uses the Update-FormatData cmdlet to add the Process.for
mat.ps1xml file to the current session. The command uses the PrependPath pa
rameter to ensure that the formatting data for process objects in the Proce
ss.format.ps1xml file is found before the standard formatting data for proc
ess objects.

The third command shows the effects of this change. The command uses the Ge
t-Process cmdlet to get processes that have names that begin with "P". The
output shows that property values that are calculated by using script block
s are missing from the display.




REMARKS
To see the examples, type: "get-help Export-FormatData -examples".
For more information, type: "get-help Export-FormatData -detailed".
For technical information, type: "get-help Export-FormatData -full".

NAME
Export-ModuleMember

SYNOPSIS
Specifies the module members that are exported.


SYNTAX
Export-ModuleMember [[-Function] <string[]>] [-Alias <string[]>] [-Cmdlet <
string[]>] [-Variable <string[]>] [<CommonParameters>]


DESCRIPTION
The Export-ModuleMember cmdlet specifies the module members (such as cmdlet
s, functions, variables, and aliases) that are exported from a script modul
e (.psm1) file, or from a dynamic module created by using the New-Module cm
dlet. This cmdlet can be used only in a script module file or a dynamic mod
ule.

If a script module does not include an Export-ModuleMember command, the fun
ctions in the script module are exported, but the variables and aliases are
not. When a script module includes an Export-ModuleMember command, only th
e members specified in the Export-ModuleMember command are exported.

If a script module contains multiple Export-ModuleMember commands, only the
members listed in an Export-ModuleMember command are exported.

You can also use Export-ModuleMember to export members that the script modu
le imports from other modules.

PARAMETERS
-Alias <string[]>
Specifies the aliases that are exported from the script module file. En
ter the alias names. Wildcards are permitted.

-Cmdlet <string[]>
Specifies the cmdlets that are exported from the script module file. En
ter the cmdlet names. Wildcards are permitted.

You cannot create cmdlets in a script module file, but you can import c
mdlets from a binary module into a script module and re-export them fro
m the script module.

-Function <string[]>
Specifies the functions that are exported from the script module file.
Enter the function names. Wildcards are permitted. You can also pipe fu
nction name strings to Export-ModuleMember.

-Variable <string[]>
Specifies the variables that are exported from the script module file.
Enter the variable names (without a dollar sign). Wildcards are permitt
ed.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>Export-ModuleMember -function * -alias *

Description
-----------
This command exports the aliases defined in the script module, along with t
he functions defined in the script module.

To export the aliases, which are not exported by default, you must also exp
licitly specify the functions. Otherwise, only the aliases will be exported
.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>Export-ModuleMember -function Get-Test, New-Test, Start-Test -alias g
tt, ntt, stt

Description
-----------
This command exports three aliases and three functions defined in the scrip
t module.

You can use this command format to specify the names of module members.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>Export-ModuleMember

Description
-----------
This command specifies that no members defined in the script module are exp
orted.

This command prevents the module members from being exported, but it does n
ot hide the members. Users can read and copy module members or use the call
operator (&) to invoke module members that are not exported.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>Export-ModuleMember -variable increment

Description
-----------
This command exports only the $increment variable from the script module. N
o other members are exported.

If you want to export a variable, in addition to exporting the functions in
a module, the Export-ModuleMember command must include the names of all of
the functions and the name of the variable.




-------------------------- EXAMPLE 5 --------------------------

C:\PS># From TestModule.psm1

function new-test
{ <function code> }
export-modulemember -function new-test

function validate-test
{ <function code> }

function start-test
{ <function code> }
set-alias stt start-test
export-modulemember -function *-test -alias stt

Description
-----------
These commands show how multiple Export-ModuleMember commands are interpret
ed in a script module (.psm1) file.

These commands create three functions and one alias, and then they export t
wo of the functions and the alias.

Without the Export-ModuleMember commands, all three of the functions would
be exported, but the alias would not be exported. With the Export-ModuleMem
ber commands, only the Get-Test and Start-Test functions and the STT alias
are exported.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>new-module -script {function SayHello {"Hello!"}; set-alias Hi SayHel
lo; Export-ModuleMember -alias Hi -function SayHello}

Description
-----------
This command shows how to use Export-ModuleMember in a dynamic module that
is created by using the New-Module cmdlet.

In this example, Export-ModuleMember is used to export both the "Hi" alias
and the "SayHello" function in the dynamic module.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>function export
{
param (
[parameter(mandatory=$true)] [validateset("function","variable")] $
type,
[parameter(mandatory=$true)] $name,
[parameter(mandatory=$true)] $value
)
if ($type -eq "function")
{
Set-item "function:script:$name" $value
Export-ModuleMember $name
}
else
{
Set-Variable -scope Script $name $value
Export-ModuleMember -variable $name
}
}

export function New-Test
{
...
}


function helper
{
...
}

export variable interval 0
$interval = 2

Description
-----------
This example includes a function named Export that declares a function or c
reates a variable, and then writes an Export-ModuleMember command for the f
unction or variable. This lets you declare and export a function or variabl
e in a single command.

To use the Export function, include it in your script module. To export a f
unction, type "Export" before the Function keyword.

To export a variable, use the following format to declare the variable and
set its value:

export variable <variable-name> <value>

The commands in the example show the correct format. In this example, only
the New-Test function and the $Interval variable are exported.




REMARKS
To see the examples, type: "get-help Export-ModuleMember -examples".
For more information, type: "get-help Export-ModuleMember -detailed".
For technical information, type: "get-help Export-ModuleMember -full".

NAME
Export-PSSession

SYNOPSIS
Imports commands from another session and saves them in a Windows PowerShel
l module.


SYNTAX
Export-PSSession [-Session] <PSSession> [-OutputModule] <string> [[-Command
Name] <string[]>] [[-FormatTypeName] <string[]>] [-AllowClobber] [-Argument
List <Object[]>] [-CommandType {Alias | Function | Filter | Cmdlet | Extern
alScript | Application | Script | All}] [-Encoding <string>] [-Force] [-Mod
ule <string[]>] [<CommonParameters>]


DESCRIPTION
The Export-PSSession cmdlet gets cmdlets, functions, aliases, and other com
mand types from another PSSession on a local or remote computer and saves t
hem in a Windows PowerShell module. To add the commands from the module to
the current session, use the Import-Module cmdlet.

Unlike Import-PSSession, which imports commands from another PSSession into
the current session, Export-PSSession saves the commands in a module. The
commands are not imported into the current session.

To export commands, first use the New-PSSession cmdlet to create a PSSessio
n that has the commands that you want to export. Then use the Export-PSSess
ion cmdlet to export the commands. By default, Export-PSSession exports all
commands, except for commands that exist in the current session, but you c
an use the CommandName parameters to specify the commands to export.

The Export-PSSession cmdlet uses the implicit remoting feature of Windows P
owerShell. When you import commands into the current session, they run impl
icitly in the original session or in a similar session on the originating
computer.

PARAMETERS
-AllowClobber [<SwitchParameter>]
Exports the specified commands, even if they have the same names as com
mands in the current session.

If you import a command with the same name as a command in the current
session, the imported command hides or replaces the original commands.
For more information, see about_Command_Precedence.

Export-PSSession does not import commands that have the same names as c
ommands in the current session. The default behavior is designed to pre
vent command name conflicts.

-ArgumentList <Object[]>
Exports the variant of the command that results from using the specifie
d arguments (parameter values).

For example, to export the variant of the Get-Item command in the certi
ficate (Cert:) drive in the PSSession in $s, type "export-pssession -se
ssion $s -command get-item -argumentlist cert:".

-CommandName <string[]>
Exports only the commands with the specified names or name patterns. Wi
ldcards are permitted. Use "CommandName" or its alias, "Name".

By default, Export-PSSession exports all commands from the PSSession ex
cept for commands that have the same names as commands in the current s
ession. This prevents imported commands from hiding or replacing comman
ds in the current session. To export all commands, even those that hide
or replace other commands, use the AllowClobber parameter.

If you use the CommandName parameter, the formatting files for the comm
ands are not exported unless you use the FormatTypeName parameter. Simi
larly, if you use the FormatTypeName parameter, no commands are exporte
d unless you use the CommandName parameter.

-CommandType <CommandTypes>
Exports only the specified types of command objects. Use "CommandType"
or its alias, "Type".

Valid values are:
-- Alias: All Windows PowerShell aliases in the current session.
-- All: All command types. It is the equivalent of "get-command *".
-- Application: All files other than Windows PowerShell files in paths
listed in the Path environment variable ($env:path), including .txt, .e
xe, and .dll files.
-- Cmdlet: The cmdlets in the current session. "Cmdlet" is the default.
-- ExternalScript: All .ps1 files in the paths listed in the Path envir
onment variable ($env:path).
-- Filter and Function: All Windows PowerShell functions.
-- Script: Script blocks in the current session.

-Encoding <string>
Specifies the encoding for the output files. Valid values are "Unicode"
, "UTF7", "UTF8", "ASCII", "UTF32", "BigEndianUnicode", "Default", and
"OEM". The default is "UTF-8".

-Force [<SwitchParameter>]
Overwrites one or more existing output files, even if the file has the
read-only attribute.

-FormatTypeName <string[]>
Exports formatting instructions only for the specified Microsoft .NET F
ramework types. Enter the type names. By default, Export-PSSession expo
rts formatting instructions for all .NET Framework types that are not i
n the System.Management.Automation namespace.

The value of this parameter must be the name of a type that is returned
by a Get-FormatData command in the session from which the commands are
being imported. To get all of the formatting data in the remote sessio
n, type *.

If you use the FormatTypeName parameter, no commands are exported unles
s you use the CommandName parameter.
Similarly, if you use the CommandName parameter, the formatting files f
or the commands are not exported unless you use the FormatTypeName para
meter.

-Module <string[]>
Exports only the commands in the specified Windows PowerShell snap-ins
and modules. Enter the snap-in and module names. Wildcards are not perm
itted.

For more information, see about_PSSnapins and Import-Module.

-OutputModule <string>
Specifies a path (optional) and name for the module that Export-PSSessi
on creates. The default path is $home\Documents\WindowsPowerShell\Modul
es. This parameter is required.

If the module subdirectory or any of the files that Export-PSSession cr
eates already exist, the command fails. To overwrite existing files, us
e the Force parameter.

-Session <PSSession>
Specifies the PSSession from which the commands are exported. Enter a
variable that contains a session object or a command that gets a sessio
n object, such as a Get-PSSession command. This parameter is required.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$s = new-pssession -computerName Server01

C:\PS> export-pssession -session $s -outputModule Server01

Description
-----------
The commands in this example export all commands from a PSSession on the Se
rver01 computer to the Server01 module on the local computer except for com
mands that have the same names as commands in the current session. It also
exports the formatting data for the commands.

The first command creates a PSSession on the Server01 computer. The second
command exports the commands and formatting data from the session into the
Server01 module.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$s = new-pssession -ConnectionUri http://exchange.microsoft.com/mailb
ox -credential exchangeadmin01@hotmail.com -authentication negotiate

C:\PS> export-pssession -session $r -module exch* -commandname get-*, set-*
-formattypename * -outputModule $pshome\Modules\Exchange -encoding ASCII

Description
-----------
These commands export the Get and Set commands from a Microsoft Exchange Se
rver snap-in on a remote computer to an Exchange module in the $pshome\Modu
les directory on the local computer.

Placing the module in the $pshome\Module directory makes it accessible to a
ll users of the computer.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$s = new-pssession -computerName Server01 -credential Server01\User01

C:\PS> export-pssession -session $s -outputModule TestCmdlets -type cmdlet
-commandname *test* -formattypename *

C:\PS> remove-pssession $s

C:\PS> import-module TestCmdlets

C:\PS> get-help test*

C:\PS> test-files

Description
-----------
These commands export cmdlets from a PSSession on a remote computer and sav
e them in a module on the local computer. Then, the commands add the cmdlet
s from the module to the current session so that they can be used.

The first command creates a PSSession on the Server01 computer and saves it
in the $s variable.

The second command exports the cmdlets whose names begin with "Test" from t
he PSSession in $s to the TestCmdlets module on the local computer.

The third command uses the Remove-PSSession cmdlet to delete the PSSession
in $s from the current session. This command shows that the PSSession need
not be active to use the commands that were imported from it.

The fourth command, which can be run in any session at any time, uses the I
mport-Module cmdlet to add the cmdlets in the TestCmdlets module to the cur
rent session.

The fifth command uses the Get-Help cmdlet to get help for cmdlets whose na
mes begin with "Test." After the commands in a module are added to the curr
ent session, you can use the Get-Help and Get-Command cmdlets to learn abou
t the imported commands, just as you would use them for any command in the
session.

The sixth command uses the Test-Files cmdlet, which was exported from the S
erver01 computer and added to the session.

Although it is not evident, the Test-Files command actually runs in a remot
e session on the computer from which the command was imported. Windows Powe
rShell creates a session from information that is stored in the module.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>export-pssession -session $s -AllowClobber -outputModule AllCommands

Description
-----------
This command exports all commands and all formatting data from the PSSessio
n in the $s variable into the current session. The command uses the AllowCl
obber parameter to include commands with the same names as commands in the
current session.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>$options = New-PSSessionOption -NoMachineProfile

C:\PS> $s = new-pssession -computername Server01 -sessionoption $options

C:\PS> export-pssession -session $s -outputModule Server01

C:\PS> remove-pssession $s

C:\PS> new-pssession -computername Server01 -sessionoption $options

C:\PS> import-module Server01

Description
-----------
This example shows how to run the exported commands in a session with parti
cular options when the PSSession from which the commands were exported is c
losed.

When you use Export-PSSession, it saves information about the original PSSe
ssion in the module that it creates. When you import the module, if the ori
ginal remote session is closed, the module will use any open remote session
that connects to originating computer.

If the current session does not include a remote session to the originating
computer, the commands in the module will re-establish a session to that c
omputer. However, Export-PSSession does not save special options, such as t
hose set by using the SessionOption parameter of New-PSSession, in the modu
le.

Therefore, if you want to run the exported commands in a remote session wit
h particular options, you need to create a remote session with the options
that you want before you import the module.

The first command uses the New-PSSessionOption cmdlet to create a PSSession
Option object, and it saves the object in the $options variable.

The second command creates a PSSession that includes the specified options.
The command uses the New-PSSession cmdlet to create a PSSession on the Ser
ver01 computer. It uses the SessionOption parameter to submit the option ob
ject in $options.

The third command uses the Export-PSSession cmdlet to export commands from
the PSSession in $s to the Server01 module.

The fourth command uses the Remove-PSSession cmdlet to delete the PSSession
in the $s variable.

The fifth command uses the New-PSSession cmdlet to create a new PSSession t
hat connects to the Server01 computer. This PSSession also uses the session
options in the $options variable.

The sixth command uses the Import-Module cmdlet to import the commands from
the Server01 module. The commands in the module run in the PSSession on th
e Server01 computer.




REMARKS
To see the examples, type: "get-help Export-PSSession -examples".
For more information, type: "get-help Export-PSSession -detailed".
For technical information, type: "get-help Export-PSSession -full".

NAME
Exit-PSSession

SYNOPSIS
Ends an interactive session with a remote computer.


SYNTAX
Exit-PSSession [<CommonParameters>]


DESCRIPTION
The Exit-PSSession cmdlet ends interactive sessions that you started by usi
ng Enter-PSSession.

You can also use the Exit keyword to end an interactive session. The effect
is the same as using Exit-PSSession.

PARAMETERS
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>Enter-PSSession -computername Server01

Server01\PS> Exit-PSSession

C:\PS>

Description
-----------
These commands start and then stop an interactive session with the Server01
remote computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$s = new-pssession -computername Server01

C:\PS> Enter-PSSession -session $s

Server01\PS> Exit-PSSession

C:\PS> $s

Id Name ComputerName State ConfigurationName
-- ---- ------------ ----- -----------------
1 Session1 Server01 Opened Microsoft.PowerShell

Description
-----------
These commands start and stop an interactive session with the Server01 comp
uter that uses a Windows PowerShell session (PSSession).

Because the interactive session was started by using a Windows PowerShell s
ession (PSSession), the PSSession is still available when the interactive s
ession ends. If you use the ComputerName parameter, Enter-PSSession creates
a temporary session that it closes when the interactive session ends.

The first command uses the New-PSSession cmdlet to create a PSSession on th
e Server01 computer. The command saves the PSSession in the $s variable.

The second command uses the Enter-PSSession cmdlet to start an interactive
session using the PSSession in $s.

The third command uses the Exit-PSSession cmdlet to stop the interactive se
ssion.

The final command displays the PSSession in the $s variable. The State prop
erty shows the PSSession is still open and available for use.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>Enter-PSSession -computername Server01

Server01\PS> exit

C:\PS>

Description
-----------
This command uses the Exit keyword to stop an interactive session started b
y using the Enter-PSSession cmdlet. The Exit keyword has the same effect as
using Exit-PSSession.




REMARKS
To see the examples, type: "get-help Exit-PSSession -examples".
For more information, type: "get-help Exit-PSSession -detailed".
For technical information, type: "get-help Exit-PSSession -full".

F:

NAME
Format-Custom

SYNOPSIS
Uses a customized view to format the output.


SYNTAX
Format-Custom [[-Property] <Object[]>] [-Depth <int>] [-DisplayError] [-Exp
and <string>] [-Force] [-GroupBy <Object>] [-InputObject <psobject>] [-Show
Error] [-View <string>] [<CommonParameters>]


DESCRIPTION
The Format-Custom cmdlet formats the output of a command as defined in an a
lternate view. Format-Custom is designed to display views that are not just
tables or just lists. You can use the views defined in the *format.PS1XML
files in the Windows PowerShell directory, or you can create your own views
in new PS1XML files and use the Update-FormatData cmdlet to add them to Wi
ndows PowerShell.

PARAMETERS
-Depth <int>
Specifies the number of columns in the display.

-DisplayError [<SwitchParameter>]
Displays errors at the command line.

-Expand <string>
Formats the collection object, as well as the objects in the collection
. This parameter is designed to format objects that support the ICollec
tion (System.Collections) interface. The default value is EnumOnly.

Valid values are:
-- EnumOnly: Displays the properties of the objects in the collection.
-- CoreOnly: Displays the properties of the collection object.
-- Both: Displays the properties of the collection object and the prope
rties of objects in the collection.

-Force [<SwitchParameter>]
Directs the cmdlet to display all of the error information. Use with th
e DisplayError or ShowError parameters. By default, when an error objec
t is written to the error or display streams, only some of the error in
formation is displayed.

-GroupBy <Object>
Formats the output in groups based on a shared property or value. Enter
an expression or a property of the output.

The value of the GroupBy parameter can be a new calculated property. To
create a calculated, property, use a hash table. Valid keys are:

-- Name (or Label) <string>
-- Expression <string> or <script block>
-- FormatString <string>

-InputObject <psobject>
Specifies the objects to be formatted. Enter a variable that contains t
he objects or type a command or expression that gets the objects.

-Property <Object[]>
Specifies the object properties that appear in the display and the orde
r in which they appear. Wildcards are permitted.

If you omit this parameter, the properties that appear in the display d
epend on the object being displayed. The parameter name ("Property") is
optional. You cannot use the Property and View parameters in the same
command.

The value of the Property parameter can be a new calculated property. T
o create a calculated property, use a hash table. Valid keys are:

-- Expression <string> or <script block>
-- Depth <int32>

-ShowError [<SwitchParameter>]
Sends errors through the pipeline.

-View <string>
Specifies the name of an alternate format or "view." If you omit this p
arameter, Format-Custom uses a default custom view. You cannot use the
Property and View parameters in the same command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-command start-transcript | format-custom -view MyView

Description
-----------
This command formats information about the Start-Transcript cmdlet in the f
ormat defined by the MyView view, a custom view created by the user. To run
this command successfully, you must first create a new PS1XML file, define
the MyView view, and then use the Update-FormatData command to add the PS1
XML file to Windows PowerShell.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-process Winlogon | format-custom

Description
-----------
This command formats information about the Winlogon process in an alternate
customized view. Because the command does not use the View parameter, Form
at-Custom uses a default custom view to format the data.




REMARKS
To see the examples, type: "get-help Format-Custom -examples".
For more information, type: "get-help Format-Custom -detailed".
For technical information, type: "get-help Format-Custom -full".

NAME
Format-List

SYNOPSIS
Formats the output as a list of properties in which each property appears o
n a new line.


SYNTAX
Format-List [[-Property] <Object[]>] [-DisplayError] [-Expand <string>] [-F
orce] [-GroupBy <Object>] [-InputObject <psobject>] [-ShowError] [-View <st
ring>] [<CommonParameters>]


DESCRIPTION
The Format-List cmdlet formats the output of a command as a list of propert
ies in which each property is displayed on a separate line. You can use For
mat-List to format and display all or selected properties of an object as a
list (format-list *).

Because more space is available for each item in a list than in a table, Wi
ndows PowerShell displays more properties of the object in the list, and th
e property values are less likely to be truncated.

PARAMETERS
-DisplayError [<SwitchParameter>]
Displays errors at the command line.

-Expand <string>
Formats the collection object, as well as the objects in the collection
. This parameter is designed to format objects that support the ICollec
tion (System.Collections) interface. The default value is EnumOnly.

Valid values are:
-- EnumOnly: Displays the properties of the objects in the collection.
-- CoreOnly: Displays the properties of the collection object.
-- Both: Displays the properties of the collection object and the prope
rties of objects in the collection.

-Force [<SwitchParameter>]
Directs the cmdlet to display all of the error information. Use with th
e DisplayError or ShowError parameters. By default, when an error objec
t is written to the error or display streams, only some of the error in
formation is displayed.

-GroupBy <Object>
Formats the output in groups based on a shared property or value. Enter
an expression or a property of the output.

The value of the GroupBy parameter can be a new calculated property. To
create a calculated, property, use a hash table. Valid keys are:

-- Name (or Label) <string>
-- Expression <string> or <script block>
-- FormatString <string>

-InputObject <psobject>
Specifies the objects to be formatted. Enter a variable that contains t
he objects or type a command or expression that gets the objects.

-Property <Object[]>
Specifies the object properties that appear in the display and the orde
r in which they appear. Wildcards are permitted.

If you omit this parameter, the properties that appear in the display d
epend on the object being displayed. The parameter name ("Property") is
optional. You cannot use the Property and View parameters in the same
command.

The value of the Property parameter can be a new calculated property. T
o create a calculated, property, use a hash table. Valid keys are:

-- Name (or Label) <string>
-- Expression <string> or <script block>
-- FormatString <string>

-ShowError [<SwitchParameter>]
Sends errors through the pipeline.

-View <string>
Specifies the name of an alternate list format or "view." You cannot us
e the Property and View parameters in the same command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-service | format-list

Description
-----------
This command formats information about services on the computer as a list.
By default, the services are formatted as a table. The Get-Service cmdlet g
ets objects representing the services on the computer. The pipeline operato
r (|) passes the results through the pipeline to Format-List. Then, the For
mat-List command formats the service information in a list and sends it to
the default output cmdlet for display.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$a = get-childitem $pshome\*.ps1xml

Description
-----------
These commands display information about the PS1XML files in the Windows Po
werShell directory as a list. The first command gets the objects representi
ng the files and stores them in the $a variable. The second command uses Fo
rmat-List to format information about objects stored in $a. This command us
es the InputObject parameter to pass the variable to Format-List, which the
n sends the formatted output to the default output cmdlet for display.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-process | format-list -property name, basepriority, priorityclass

Description
-----------
This command displays the name, base priority, and priority class of each p
rocess on the computer. It uses the Get-Process cmdlet to get an object rep
resenting each process. The pipeline operator (|) passes the process object
s through the pipeline to Format-List. Format-List formats the processes as
a list of the specified properties. The "Property" parameter name is optio
nal, so you can omit it.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-process winlogon | format-list -property *

Description
-----------
This command displays all of the properties of the Winlogon process. It use
s the Get-Process cmdlet to get an object representing the Winlogon process
. The pipeline operator (|) passes the Winlogon process object through the
pipeline to Format-List. The command uses the Property parameter to specify
the properties and the * to indicate all properties. Because the name of t
he Property parameter is optional, you can omit it and type the command as:
"format-list *". Format-List automatically sends the results to the defaul
t output cmdlet for display.




REMARKS
To see the examples, type: "get-help Format-List -examples".
For more information, type: "get-help Format-List -detailed".
For technical information, type: "get-help Format-List -full".

NAME
ForEach-Object

SYNOPSIS
Performs an operation against each of a set of input objects.


SYNTAX
ForEach-Object [-Process] <ScriptBlock[]> [-Begin <scriptblock>] [-End <scr
iptblock>] [-InputObject <psobject>] [<CommonParameters>]


DESCRIPTION
The ForEach-Object cmdlet performs an operation on each of a set of input o
bjects. The input objects can be piped to the cmdlet or specified by using
the InputObject parameter.

The operation to perform is described within a script block that is provide
d to the cmdlet as the value of the Process parameter. The script block can
contain any Windows PowerShell script.

Within the script block, the current input object is represented by the $_
variable.
In addition to using the script block that describes the operations to be c
arried out on each input object, you can provide two additional script bloc
ks. One, specified as the value of the Begin parameter, runs before the fir
st input object is processed. The other, specified as the value of the End
parameter, runs after the last input object is processed.

The results of the evaluation of all the script blocks, including the ones
specified with Begin and End, are passed down the pipeline.

PARAMETERS
-Begin <scriptblock>
Specifies a script block to run before processing any input objects.

-End <scriptblock>
Specifies a script block to run after processing all input objects.

-InputObject <psobject>
Accepts an object that the script block specified in the process parame
ter will act upon. Enter a variable that contains the objects, or type
a command or expression that gets the objects.

-Process <ScriptBlock[]>
Specifies the script block that is applied to each incoming object.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>30000,56798,12432 | foreach-object -process {$_/1024}

Description
-----------
This command accepts an array of integers, divides each one of them by 1024
, and displays the results.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-childitem C:\ | foreach-object -process { $_.length / 1024 }

Description
-----------
This command retrieves the files and directories in the root of the C: driv
e, and it returns and displays the size of each of them. The zeros represen
t directories in which no file size was available.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$events = get-eventlog -logname system -newest 1000

C:\PS> $events | foreach-object -begin {get-date} -process {out-file -filep
ath events.txt -append -inputobject $_.message} -end {get-date}

Description
-----------
This command retrieves the 1000 most recent events from the system log and
stores them in the $events variable. It then pipes the events to the ForEac
h-Object cmdlet. The Begin parameter displays the current date and time. Ne
xt, the Process parameter uses the Out-File cmdlet to create a text file na
med events.txt and stores the message property of each of the events in tha
t file. Last, the End parameter is used to display the date and time after
all of the processing has completed.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-itemproperty -path hkcu:\Network\* | foreach-object {set-itemprop
erty -path $_.pspath -name RemotePath -value $_.RemotePath.ToUpper();}

Description
-----------
This command changes the value of the RemotePath registry entry in all of t
he subkeys under the HKCU:\Network key to uppercase text. You can use this
format to change the form or content of a registry entry value.

Each subkey in the Network key represents a mapped network drive that will
reconnect at logon. The RemotePath entry contains the UNC path of the conne
cted drive. For example, if you map the E: drive to \\Server\Share, there w
ill be an E subkey of HKCU:\Network and the value of the RemotePath registr
y entry in the E subkey will be \\Server\Share.

The command uses the Get-ItemProperty cmdlet to get all of the subkeys of t
he Network key and the Set-ItemProperty cmdlet to change the value of the R
emotePath registry entry in each key. In the Set-ItemProperty command, the
path is the value of the PSPath property of the registry key. (This is a pr
operty of the Microsoft .NET Framework object that represents the registry
key; it is not a registry entry.) The command uses the ToUpper() method of
the RemotePath value, which is a string (REG_SZ).

Because Set-ItemProperty is changing the property of each key, the ForEach-
Object cmdlet is required to access the property.




REMARKS
To see the examples, type: "get-help ForEach-Object -examples".
For more information, type: "get-help ForEach-Object -detailed".
For technical information, type: "get-help ForEach-Object -full".

NAME
ForEach-Object

SYNOPSIS
Performs an operation against each of a set of input objects.


SYNTAX
ForEach-Object [-Process] <ScriptBlock[]> [-Begin <scriptblock>] [-End <scr
iptblock>] [-InputObject <psobject>] [<CommonParameters>]


DESCRIPTION
The ForEach-Object cmdlet performs an operation on each of a set of input o
bjects. The input objects can be piped to the cmdlet or specified by using
the InputObject parameter.

The operation to perform is described within a script block that is provide
d to the cmdlet as the value of the Process parameter. The script block can
contain any Windows PowerShell script.

Within the script block, the current input object is represented by the $_
variable.
In addition to using the script block that describes the operations to be c
arried out on each input object, you can provide two additional script bloc
ks. One, specified as the value of the Begin parameter, runs before the fir
st input object is processed. The other, specified as the value of the End
parameter, runs after the last input object is processed.

The results of the evaluation of all the script blocks, including the ones
specified with Begin and End, are passed down the pipeline.

PARAMETERS
-Begin <scriptblock>
Specifies a script block to run before processing any input objects.

-End <scriptblock>
Specifies a script block to run after processing all input objects.

-InputObject <psobject>
Accepts an object that the script block specified in the process parame
ter will act upon. Enter a variable that contains the objects, or type
a command or expression that gets the objects.

-Process <ScriptBlock[]>
Specifies the script block that is applied to each incoming object.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>30000,56798,12432 | foreach-object -process {$_/1024}

Description
-----------
This command accepts an array of integers, divides each one of them by 1024
, and displays the results.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-childitem C:\ | foreach-object -process { $_.length / 1024 }

Description
-----------
This command retrieves the files and directories in the root of the C: driv
e, and it returns and displays the size of each of them. The zeros represen
t directories in which no file size was available.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$events = get-eventlog -logname system -newest 1000

C:\PS> $events | foreach-object -begin {get-date} -process {out-file -filep
ath events.txt -append -inputobject $_.message} -end {get-date}

Description
-----------
This command retrieves the 1000 most recent events from the system log and
stores them in the $events variable. It then pipes the events to the ForEac
h-Object cmdlet. The Begin parameter displays the current date and time. Ne
xt, the Process parameter uses the Out-File cmdlet to create a text file na
med events.txt and stores the message property of each of the events in tha
t file. Last, the End parameter is used to display the date and time after
all of the processing has completed.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-itemproperty -path hkcu:\Network\* | foreach-object {set-itemprop
erty -path $_.pspath -name RemotePath -value $_.RemotePath.ToUpper();}

Description
-----------
This command changes the value of the RemotePath registry entry in all of t
he subkeys under the HKCU:\Network key to uppercase text. You can use this
format to change the form or content of a registry entry value.

Each subkey in the Network key represents a mapped network drive that will
reconnect at logon. The RemotePath entry contains the UNC path of the conne
cted drive. For example, if you map the E: drive to \\Server\Share, there w
ill be an E subkey of HKCU:\Network and the value of the RemotePath registr
y entry in the E subkey will be \\Server\Share.

The command uses the Get-ItemProperty cmdlet to get all of the subkeys of t
he Network key and the Set-ItemProperty cmdlet to change the value of the R
emotePath registry entry in each key. In the Set-ItemProperty command, the
path is the value of the PSPath property of the registry key. (This is a pr
operty of the Microsoft .NET Framework object that represents the registry
key; it is not a registry entry.) The command uses the ToUpper() method of
the RemotePath value, which is a string (REG_SZ).

Because Set-ItemProperty is changing the property of each key, the ForEach-
Object cmdlet is required to access the property.




REMARKS
To see the examples, type: "get-help ForEach-Object -examples".
For more information, type: "get-help ForEach-Object -detailed".
For technical information, type: "get-help ForEach-Object -full".

NAME
Format-Custom

SYNOPSIS
Uses a customized view to format the output.


SYNTAX
Format-Custom [[-Property] <Object[]>] [-Depth <int>] [-DisplayError] [-Exp
and <string>] [-Force] [-GroupBy <Object>] [-InputObject <psobject>] [-Show
Error] [-View <string>] [<CommonParameters>]


DESCRIPTION
The Format-Custom cmdlet formats the output of a command as defined in an a
lternate view. Format-Custom is designed to display views that are not just
tables or just lists. You can use the views defined in the *format.PS1XML
files in the Windows PowerShell directory, or you can create your own views
in new PS1XML files and use the Update-FormatData cmdlet to add them to Wi
ndows PowerShell.

PARAMETERS
-Depth <int>
Specifies the number of columns in the display.

-DisplayError [<SwitchParameter>]
Displays errors at the command line.

-Expand <string>
Formats the collection object, as well as the objects in the collection
. This parameter is designed to format objects that support the ICollec
tion (System.Collections) interface. The default value is EnumOnly.

Valid values are:
-- EnumOnly: Displays the properties of the objects in the collection.
-- CoreOnly: Displays the properties of the collection object.
-- Both: Displays the properties of the collection object and the prope
rties of objects in the collection.

-Force [<SwitchParameter>]
Directs the cmdlet to display all of the error information. Use with th
e DisplayError or ShowError parameters. By default, when an error objec
t is written to the error or display streams, only some of the error in
formation is displayed.

-GroupBy <Object>
Formats the output in groups based on a shared property or value. Enter
an expression or a property of the output.

The value of the GroupBy parameter can be a new calculated property. To
create a calculated, property, use a hash table. Valid keys are:

-- Name (or Label) <string>
-- Expression <string> or <script block>
-- FormatString <string>

-InputObject <psobject>
Specifies the objects to be formatted. Enter a variable that contains t
he objects or type a command or expression that gets the objects.

-Property <Object[]>
Specifies the object properties that appear in the display and the orde
r in which they appear. Wildcards are permitted.

If you omit this parameter, the properties that appear in the display d
epend on the object being displayed. The parameter name ("Property") is
optional. You cannot use the Property and View parameters in the same
command.

The value of the Property parameter can be a new calculated property. T
o create a calculated property, use a hash table. Valid keys are:

-- Expression <string> or <script block>
-- Depth <int32>

-ShowError [<SwitchParameter>]
Sends errors through the pipeline.

-View <string>
Specifies the name of an alternate format or "view." If you omit this p
arameter, Format-Custom uses a default custom view. You cannot use the
Property and View parameters in the same command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-command start-transcript | format-custom -view MyView

Description
-----------
This command formats information about the Start-Transcript cmdlet in the f
ormat defined by the MyView view, a custom view created by the user. To run
this command successfully, you must first create a new PS1XML file, define
the MyView view, and then use the Update-FormatData command to add the PS1
XML file to Windows PowerShell.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-process Winlogon | format-custom

Description
-----------
This command formats information about the Winlogon process in an alternate
customized view. Because the command does not use the View parameter, Form
at-Custom uses a default custom view to format the data.




REMARKS
To see the examples, type: "get-help Format-Custom -examples".
For more information, type: "get-help Format-Custom -detailed".
For technical information, type: "get-help Format-Custom -full".

NAME
Format-List

SYNOPSIS
Formats the output as a list of properties in which each property appears o
n a new line.


SYNTAX
Format-List [[-Property] <Object[]>] [-DisplayError] [-Expand <string>] [-F
orce] [-GroupBy <Object>] [-InputObject <psobject>] [-ShowError] [-View <st
ring>] [<CommonParameters>]


DESCRIPTION
The Format-List cmdlet formats the output of a command as a list of propert
ies in which each property is displayed on a separate line. You can use For
mat-List to format and display all or selected properties of an object as a
list (format-list *).

Because more space is available for each item in a list than in a table, Wi
ndows PowerShell displays more properties of the object in the list, and th
e property values are less likely to be truncated.

PARAMETERS
-DisplayError [<SwitchParameter>]
Displays errors at the command line.

-Expand <string>
Formats the collection object, as well as the objects in the collection
. This parameter is designed to format objects that support the ICollec
tion (System.Collections) interface. The default value is EnumOnly.

Valid values are:
-- EnumOnly: Displays the properties of the objects in the collection.
-- CoreOnly: Displays the properties of the collection object.
-- Both: Displays the properties of the collection object and the prope
rties of objects in the collection.

-Force [<SwitchParameter>]
Directs the cmdlet to display all of the error information. Use with th
e DisplayError or ShowError parameters. By default, when an error objec
t is written to the error or display streams, only some of the error in
formation is displayed.

-GroupBy <Object>
Formats the output in groups based on a shared property or value. Enter
an expression or a property of the output.

The value of the GroupBy parameter can be a new calculated property. To
create a calculated, property, use a hash table. Valid keys are:

-- Name (or Label) <string>
-- Expression <string> or <script block>
-- FormatString <string>

-InputObject <psobject>
Specifies the objects to be formatted. Enter a variable that contains t
he objects or type a command or expression that gets the objects.

-Property <Object[]>
Specifies the object properties that appear in the display and the orde
r in which they appear. Wildcards are permitted.

If you omit this parameter, the properties that appear in the display d
epend on the object being displayed. The parameter name ("Property") is
optional. You cannot use the Property and View parameters in the same
command.

The value of the Property parameter can be a new calculated property. T
o create a calculated, property, use a hash table. Valid keys are:

-- Name (or Label) <string>
-- Expression <string> or <script block>
-- FormatString <string>

-ShowError [<SwitchParameter>]
Sends errors through the pipeline.

-View <string>
Specifies the name of an alternate list format or "view." You cannot us
e the Property and View parameters in the same command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-service | format-list

Description
-----------
This command formats information about services on the computer as a list.
By default, the services are formatted as a table. The Get-Service cmdlet g
ets objects representing the services on the computer. The pipeline operato
r (|) passes the results through the pipeline to Format-List. Then, the For
mat-List command formats the service information in a list and sends it to
the default output cmdlet for display.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$a = get-childitem $pshome\*.ps1xml

Description
-----------
These commands display information about the PS1XML files in the Windows Po
werShell directory as a list. The first command gets the objects representi
ng the files and stores them in the $a variable. The second command uses Fo
rmat-List to format information about objects stored in $a. This command us
es the InputObject parameter to pass the variable to Format-List, which the
n sends the formatted output to the default output cmdlet for display.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-process | format-list -property name, basepriority, priorityclass

Description
-----------
This command displays the name, base priority, and priority class of each p
rocess on the computer. It uses the Get-Process cmdlet to get an object rep
resenting each process. The pipeline operator (|) passes the process object
s through the pipeline to Format-List. Format-List formats the processes as
a list of the specified properties. The "Property" parameter name is optio
nal, so you can omit it.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-process winlogon | format-list -property *

Description
-----------
This command displays all of the properties of the Winlogon process. It use
s the Get-Process cmdlet to get an object representing the Winlogon process
. The pipeline operator (|) passes the Winlogon process object through the
pipeline to Format-List. The command uses the Property parameter to specify
the properties and the * to indicate all properties. Because the name of t
he Property parameter is optional, you can omit it and type the command as:
"format-list *". Format-List automatically sends the results to the defaul
t output cmdlet for display.




REMARKS
To see the examples, type: "get-help Format-List -examples".
For more information, type: "get-help Format-List -detailed".
For technical information, type: "get-help Format-List -full".

NAME
Format-Table

SYNOPSIS
Formats the output as a table.


SYNTAX
Format-Table [[-Property] <Object[]>] [-AutoSize] [-DisplayError] [-Expand
<string>] [-Force] [-GroupBy <Object>] [-HideTableHeaders] [-InputObject <p
sobject>] [-ShowError] [-View <string>] [-Wrap] [<CommonParameters>]


DESCRIPTION
The Format-Table cmdlet formats the output of a command as a table with the
selected properties of the object in each column. The object type determin
es the default layout and properties that are displayed in each column, but
you can use the Property parameter to select the properties that you want
to see.

You can also use a hash table to add calculated properties to an object bef
ore displaying it and to specify the column headings in the table. To add a
calculated property, use the Property or GroupBy parameters.

PARAMETERS
-AutoSize [<SwitchParameter>]
Adjusts the column size and number of columns based on the width of the
data. By default, the column size and number are determined by the vie
w.

-DisplayError [<SwitchParameter>]
Displays errors at the command line.

-Expand <string>
Formats the collection object, as well as the objects in the collection
. This parameter is designed to format objects that support the ICollec
tion (System.Collections) interface. The default value is EnumOnly.

Valid values are:
-- EnumOnly: Displays the properties of the objects in the collection.
-- CoreOnly: Displays the properties of the collection object.
-- Both: Displays the properties of the collection object and the prope
rties of objects in the collection.

-Force [<SwitchParameter>]
Directs the cmdlet to display all of the error information. Use with th
e DisplayError or ShowError parameters. By default, when an error objec
t is written to the error or display streams, only some of the error in
formation is displayed.

-GroupBy <Object>
Arranges sorted output in separate tables based on a property value. Fo
r example, you can use GroupBy to list services in separate tables base
d on their status.

Enter an expression or a property of the output. The output must be sor
ted before you send it to Format-Table.

The value of the GroupBy parameter can be a new calculated property. To
create a calculated, property, use a hash table. Valid keys are:

-- Name (or Label) <string>
-- Expression <string> or <script block>
-- FormatString <string>

-HideTableHeaders [<SwitchParameter>]
Omits the column headings from the table.

-InputObject <psobject>
Specifies the objects to be formatted. Enter a variable that contains t
he objects, or type a command or expression that gets the objects.

-Property <Object[]>
Specifies the object properties that appear in the display and the orde
r in which they appear. Type one or more property names (separated by c
ommas), or use a hash table to display a calculated property. Wildcards
are permitted.

If you omit this parameter, the properties that appear in the display d
epend on the object being displayed. The parameter name ("Property") is
optional. You cannot use the Property and View parameters in the same
command.

The value of the Property parameter can be a new calculated property. T
o create a calculated, property, use a hash table. Valid keys are:

-- Name (or Label) <string>
-- Expression <string> or <script block>
-- FormatString <string>
-- Width <int32>
-- Alignment (value can be "Left", "Center", or "Right")

-ShowError [<SwitchParameter>]
Sends errors through the pipeline.

-View <string>
Specifies the name of an alternate table format or "view." You cannot u
se the Property and View parameters in the same command.

-Wrap [<SwitchParameter>]
Displays text that exceeds the column width on the next line. By defaul
t, text that exceeds the column width is truncated.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-pssnapin | format-table -auto

Description
-----------
This command formats information about Windows PowerShell snap-ins in a tab
le. By default, they are formatted in a list. The Get-PSSnapin cmdlets gets
objects representing the snap-ins. The pipeline operator (|) passes the ob
ject to the Format-Table command. Format-Table formats the objects in a tab
le. The Autosize parameter adjusts the column widths to minimize truncation
.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-process | sort-object -property basepriority | format-table -grou
pby basepriority -wrap

Description
-----------
This command displays the processes on the computer in groups with the same
base priority.

The Get-Process cmdlet gets objects representing each process on the comput
er. The pipeline operator (|) passes the object to the Sort-Object cmdlet,
which sorts the objects in order of their base priority.


Another pipeline operator passes the results to the Format-Table command. T
he GroupBy parameter arranges the data about the processes into groups base
d on the value of their BasePriority property. The Wrap parameter ensures t
hat data is not truncated.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-process | sort-object starttime | format-table -view starttime

Description
-----------
This command displays information about the processes on the computer in gr
oup based on the start date of the process. It uses the Get-Process cmdlet
to get objects representing the processes on the computer. The pipeline ope
rator (|) sends the output of Get-Process to the Sort-Object cmdlet, which
sorts it based on the StartTime property. Another pipeline operator sends t
he sorted results to Format-Table.

The View parameter is used to select the StartTime view that is defined in
the DotNetTypes.format.ps1xml formatting file for System.Diagnostics.Proces
s objects, such as those returned by Get-Process. This view converts the St
artTime of the process to a short date and then groups the processes by sta
rt date.

The DotNetTypes.format.ps1xml formatting file also contains a Priority view
for processes, and you can create your own format.ps1xml files with custom
ized views.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-service | format-table -property Name, DependentServices

Description
-----------
This command displays all of the services on the computer in a table with t
wo columns, Name and DependentServices. The command uses the Get-Service cm
dlet to get all of the services on the computer. The pipeline operator (|)
sends the results to the Format-Table cmdlet, which formats the output in a
table. The Property parameter specifies the properties that appear in the
table as columns. The name of the Property parameter is optional, so you ca
n omit it ("format-table name, dependentservices").

Property and DependentServices are just two of the properties of service ob
jects. To view all of the properties, type "get-service | get-member".




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-process notepad | format-table ProcessName, `
@{Label="TotalRunningTime"; Expression={(get-date) - $_.StartTime}}

Description
-----------
This command shows how to use a calculated property in a table. The command
displays a table with the process name and total running time of all Notep
ad processes on the local computer. The total running time is calculated by
subtracting the start time of each process from the current time.

The command uses the Get-Process cmdlet to get all processes named "Notepad
" on the local computer. The pipeline operator (|) sends the results to For
mat-Table, which displays a table with two columns: ProcessName, a standard
property of processes, and TotalRunningTime, a calculated property.

The TotalRunningTime property is specified by a hash table with two keys, L
abel and Expression. The name of the property is assigned to the Label key.
The calculation is assigned to the Expression key. The expression gets the
StartTime property of each process object and subtracts it from the result
of a Get-Date command, which gets the current date (and time).




-------------------------- EXAMPLE 6 --------------------------

C:\PS>$processes = get-wmiobject -ComputerName Server01 win32_process -filt
er "name='notepad.exe'"

C:\PS> $processes | format-table ProcessName, @{ Label = "Total Running Ti
me"; `
Expression={(get-date) - $_.ConvertToDateTime($_.CreationDate)}}

Description
-----------
These commands are similar to the previous command, except that these comma
nds use the Get-WmiObject cmdlet and the Win32_Process class to display inf
ormation about Notepad processes on a remote computer.

The first command uses the Get-WmiObject cmdlet to get instances of the Win
dows Management Instrumentation (WMI) Win32_Process class that describes al
l of the processes on the Server01 computer that are named Notepad.exe. The
command stores the process information in the $processes variable.


The second command uses a pipeline operator (|) to send the process informa
tion in the $processes variable to the Format-Table cmdlet, which displays
the ProcessName of each process along with a new calculated property.

The command assigns the name of the new calculated property, Total Running
Time, to the Label key. The script block that is assigned to the Expression
key calculates how long the process has been running by subtracting the cr
eation date of the process from the current date. The Get-Date cmdlet gets
the current date. The ConvertToDateTime method converts the CreationDate pr
operty of the Win32_Process object from a WMI CIM_DATETIME object to a Micr
osoft .NET Framework DateTime object that can be compared with the output o
f Get-Date. Then, the converted creation date is subtracted from the curren
t date. The result is the value of Total Running Time.

The backtick characters (`) are line continuation characters.




REMARKS
To see the examples, type: "get-help Format-Table -examples".
For more information, type: "get-help Format-Table -detailed".
For technical information, type: "get-help Format-Table -full".

NAME
Format-Wide

SYNOPSIS
Formats objects as a wide table that displays only one property of each obj
ect.


SYNTAX
Format-Wide [[-Property] <Object>] [-AutoSize] [-Column <int>] [-DisplayErr
or] [-Expand <string>] [-Force] [-GroupBy <Object>] [-InputObject <psobject
>] [-ShowError] [-View <string>] [<CommonParameters>]


DESCRIPTION
The Format-Wide cmdlet formats objects as a wide table that displays only o
ne property of each object. You can use the Property parameter to determine
which property is displayed.

PARAMETERS
-AutoSize [<SwitchParameter>]
Adjusts the column size and number of columns based on the width of the
data. By default, the column size and number are determined by the vie
w. You cannot use the AutoSize and Column parameters in the same comman
d.

-Column <int>
Specifies the number of columns in the display. You cannot use the Auto
Size and Column parameters in the same command.

-DisplayError [<SwitchParameter>]
Displays errors at the command line.

-Expand <string>
Formats the collection object, as well as the objects in the collection
. This parameter is designed to format objects that support the ICollec
tion (System.Collections) interface. The default value is EnumOnly.

Valid values are:
-- EnumOnly: Displays the properties of the objects in the collection.
-- CoreOnly: Displays the properties of the collection object.
-- Both: Displays the properties of the collection object and the prope
rties of objects in the collection.

-Force [<SwitchParameter>]
Overrides restrictions that prevent the command from succeeding, just s
o the changes do not compromise security. For example, Force will overr
ide the read-only attribute or create directories to complete a file pa
th, but it will not attempt to change file permissions.

-GroupBy <Object>
Formats the output in groups based on a shared property or value. Enter
an expression or a property of the output.

The value of the GroupBy parameter can be a new calculated property. To
create a calculated, property, use a hash table. Valid keys are:

-- Name (or Label) <string>
-- Expression <string> or <script block>
-- FormatString <string>

-InputObject <psobject>
Specifies the objects to be formatted. Enter a variable that contains t
he objects, or type a command or expression that gets the objects.

-Property <Object>
Specifies the object properties that appear in the display and the orde
r in which they appear. Wildcards are permitted.

If you omit this parameter, the properties that appear in the display d
epend on the object being displayed. The parameter name ("Property") is
optional. You cannot use the Property and View parameters in the same
command.

The value of the Property parameter can be a new calculated property. T
o create a calculated, property, use a hash table. Valid keys are:

-- Expression <string> or <script block>
-- FormatString <string>

-ShowError [<SwitchParameter>]
Sends errors through the pipeline.

-View <string>
Specifies the name of an alternate table format or "view." You cannot u
se the Property and View parameters in the same command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-childitem | format-wide -column 3

Description
-----------
This command displays the names of files in the current directory in three
columns across the screen. The Get-ChildItem cmdlet gets objects representi
ng each file in the directory. The pipeline operator (|) passes the file ob
jects through the pipeline to Format-Wide, which formats them for output. T
he Column parameter specifies the number of columns.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-childitem HKCU:\software\microsoft | format-wide -property pschil
dname -autosize

Description
-----------
This command displays the names of registry keys in the HKEY_CURRENT_USER\S
oftware\Microsoft key. The Get-ChildItem cmdlet gets objects representing t
he keys. The path is specified as "HKCU:", one of the drives exposed by the
Windows PowerShell Registry provider, followed by the key path. The pipeli
ne operator (|) passes the registry key objects through the pipeline to For
mat-Wide, which formats them for output. The Property parameter specifies t
he name of the property, and the AutoSize parameter adjusts the columns for
readability.




REMARKS
To see the examples, type: "get-help Format-Wide -examples".
For more information, type: "get-help Format-Wide -detailed".
For technical information, type: "get-help Format-Wide -full".

NAME
Format-Table

SYNOPSIS
Formats the output as a table.


SYNTAX
Format-Table [[-Property] <Object[]>] [-AutoSize] [-DisplayError] [-Expand
<string>] [-Force] [-GroupBy <Object>] [-HideTableHeaders] [-InputObject <p
sobject>] [-ShowError] [-View <string>] [-Wrap] [<CommonParameters>]


DESCRIPTION
The Format-Table cmdlet formats the output of a command as a table with the
selected properties of the object in each column. The object type determin
es the default layout and properties that are displayed in each column, but
you can use the Property parameter to select the properties that you want
to see.

You can also use a hash table to add calculated properties to an object bef
ore displaying it and to specify the column headings in the table. To add a
calculated property, use the Property or GroupBy parameters.

PARAMETERS
-AutoSize [<SwitchParameter>]
Adjusts the column size and number of columns based on the width of the
data. By default, the column size and number are determined by the vie
w.

-DisplayError [<SwitchParameter>]
Displays errors at the command line.

-Expand <string>
Formats the collection object, as well as the objects in the collection
. This parameter is designed to format objects that support the ICollec
tion (System.Collections) interface. The default value is EnumOnly.

Valid values are:
-- EnumOnly: Displays the properties of the objects in the collection.
-- CoreOnly: Displays the properties of the collection object.
-- Both: Displays the properties of the collection object and the prope
rties of objects in the collection.

-Force [<SwitchParameter>]
Directs the cmdlet to display all of the error information. Use with th
e DisplayError or ShowError parameters. By default, when an error objec
t is written to the error or display streams, only some of the error in
formation is displayed.

-GroupBy <Object>
Arranges sorted output in separate tables based on a property value. Fo
r example, you can use GroupBy to list services in separate tables base
d on their status.

Enter an expression or a property of the output. The output must be sor
ted before you send it to Format-Table.

The value of the GroupBy parameter can be a new calculated property. To
create a calculated, property, use a hash table. Valid keys are:

-- Name (or Label) <string>
-- Expression <string> or <script block>
-- FormatString <string>

-HideTableHeaders [<SwitchParameter>]
Omits the column headings from the table.

-InputObject <psobject>
Specifies the objects to be formatted. Enter a variable that contains t
he objects, or type a command or expression that gets the objects.

-Property <Object[]>
Specifies the object properties that appear in the display and the orde
r in which they appear. Type one or more property names (separated by c
ommas), or use a hash table to display a calculated property. Wildcards
are permitted.

If you omit this parameter, the properties that appear in the display d
epend on the object being displayed. The parameter name ("Property") is
optional. You cannot use the Property and View parameters in the same
command.

The value of the Property parameter can be a new calculated property. T
o create a calculated, property, use a hash table. Valid keys are:

-- Name (or Label) <string>
-- Expression <string> or <script block>
-- FormatString <string>
-- Width <int32>
-- Alignment (value can be "Left", "Center", or "Right")

-ShowError [<SwitchParameter>]
Sends errors through the pipeline.

-View <string>
Specifies the name of an alternate table format or "view." You cannot u
se the Property and View parameters in the same command.

-Wrap [<SwitchParameter>]
Displays text that exceeds the column width on the next line. By defaul
t, text that exceeds the column width is truncated.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-pssnapin | format-table -auto

Description
-----------
This command formats information about Windows PowerShell snap-ins in a tab
le. By default, they are formatted in a list. The Get-PSSnapin cmdlets gets
objects representing the snap-ins. The pipeline operator (|) passes the ob
ject to the Format-Table command. Format-Table formats the objects in a tab
le. The Autosize parameter adjusts the column widths to minimize truncation
.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-process | sort-object -property basepriority | format-table -grou
pby basepriority -wrap

Description
-----------
This command displays the processes on the computer in groups with the same
base priority.

The Get-Process cmdlet gets objects representing each process on the comput
er. The pipeline operator (|) passes the object to the Sort-Object cmdlet,
which sorts the objects in order of their base priority.


Another pipeline operator passes the results to the Format-Table command. T
he GroupBy parameter arranges the data about the processes into groups base
d on the value of their BasePriority property. The Wrap parameter ensures t
hat data is not truncated.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-process | sort-object starttime | format-table -view starttime

Description
-----------
This command displays information about the processes on the computer in gr
oup based on the start date of the process. It uses the Get-Process cmdlet
to get objects representing the processes on the computer. The pipeline ope
rator (|) sends the output of Get-Process to the Sort-Object cmdlet, which
sorts it based on the StartTime property. Another pipeline operator sends t
he sorted results to Format-Table.

The View parameter is used to select the StartTime view that is defined in
the DotNetTypes.format.ps1xml formatting file for System.Diagnostics.Proces
s objects, such as those returned by Get-Process. This view converts the St
artTime of the process to a short date and then groups the processes by sta
rt date.

The DotNetTypes.format.ps1xml formatting file also contains a Priority view
for processes, and you can create your own format.ps1xml files with custom
ized views.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-service | format-table -property Name, DependentServices

Description
-----------
This command displays all of the services on the computer in a table with t
wo columns, Name and DependentServices. The command uses the Get-Service cm
dlet to get all of the services on the computer. The pipeline operator (|)
sends the results to the Format-Table cmdlet, which formats the output in a
table. The Property parameter specifies the properties that appear in the
table as columns. The name of the Property parameter is optional, so you ca
n omit it ("format-table name, dependentservices").

Property and DependentServices are just two of the properties of service ob
jects. To view all of the properties, type "get-service | get-member".




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-process notepad | format-table ProcessName, `
@{Label="TotalRunningTime"; Expression={(get-date) - $_.StartTime}}

Description
-----------
This command shows how to use a calculated property in a table. The command
displays a table with the process name and total running time of all Notep
ad processes on the local computer. The total running time is calculated by
subtracting the start time of each process from the current time.

The command uses the Get-Process cmdlet to get all processes named "Notepad
" on the local computer. The pipeline operator (|) sends the results to For
mat-Table, which displays a table with two columns: ProcessName, a standard
property of processes, and TotalRunningTime, a calculated property.

The TotalRunningTime property is specified by a hash table with two keys, L
abel and Expression. The name of the property is assigned to the Label key.
The calculation is assigned to the Expression key. The expression gets the
StartTime property of each process object and subtracts it from the result
of a Get-Date command, which gets the current date (and time).




-------------------------- EXAMPLE 6 --------------------------

C:\PS>$processes = get-wmiobject -ComputerName Server01 win32_process -filt
er "name='notepad.exe'"

C:\PS> $processes | format-table ProcessName, @{ Label = "Total Running Ti
me"; `
Expression={(get-date) - $_.ConvertToDateTime($_.CreationDate)}}

Description
-----------
These commands are similar to the previous command, except that these comma
nds use the Get-WmiObject cmdlet and the Win32_Process class to display inf
ormation about Notepad processes on a remote computer.

The first command uses the Get-WmiObject cmdlet to get instances of the Win
dows Management Instrumentation (WMI) Win32_Process class that describes al
l of the processes on the Server01 computer that are named Notepad.exe. The
command stores the process information in the $processes variable.


The second command uses a pipeline operator (|) to send the process informa
tion in the $processes variable to the Format-Table cmdlet, which displays
the ProcessName of each process along with a new calculated property.

The command assigns the name of the new calculated property, Total Running
Time, to the Label key. The script block that is assigned to the Expression
key calculates how long the process has been running by subtracting the cr
eation date of the process from the current date. The Get-Date cmdlet gets
the current date. The ConvertToDateTime method converts the CreationDate pr
operty of the Win32_Process object from a WMI CIM_DATETIME object to a Micr
osoft .NET Framework DateTime object that can be compared with the output o
f Get-Date. Then, the converted creation date is subtracted from the curren
t date. The result is the value of Total Running Time.

The backtick characters (`) are line continuation characters.




REMARKS
To see the examples, type: "get-help Format-Table -examples".
For more information, type: "get-help Format-Table -detailed".
For technical information, type: "get-help Format-Table -full".

NAME
Format-Wide

SYNOPSIS
Formats objects as a wide table that displays only one property of each obj
ect.


SYNTAX
Format-Wide [[-Property] <Object>] [-AutoSize] [-Column <int>] [-DisplayErr
or] [-Expand <string>] [-Force] [-GroupBy <Object>] [-InputObject <psobject
>] [-ShowError] [-View <string>] [<CommonParameters>]


DESCRIPTION
The Format-Wide cmdlet formats objects as a wide table that displays only o
ne property of each object. You can use the Property parameter to determine
which property is displayed.

PARAMETERS
-AutoSize [<SwitchParameter>]
Adjusts the column size and number of columns based on the width of the
data. By default, the column size and number are determined by the vie
w. You cannot use the AutoSize and Column parameters in the same comman
d.

-Column <int>
Specifies the number of columns in the display. You cannot use the Auto
Size and Column parameters in the same command.

-DisplayError [<SwitchParameter>]
Displays errors at the command line.

-Expand <string>
Formats the collection object, as well as the objects in the collection
. This parameter is designed to format objects that support the ICollec
tion (System.Collections) interface. The default value is EnumOnly.

Valid values are:
-- EnumOnly: Displays the properties of the objects in the collection.
-- CoreOnly: Displays the properties of the collection object.
-- Both: Displays the properties of the collection object and the prope
rties of objects in the collection.

-Force [<SwitchParameter>]
Overrides restrictions that prevent the command from succeeding, just s
o the changes do not compromise security. For example, Force will overr
ide the read-only attribute or create directories to complete a file pa
th, but it will not attempt to change file permissions.

-GroupBy <Object>
Formats the output in groups based on a shared property or value. Enter
an expression or a property of the output.

The value of the GroupBy parameter can be a new calculated property. To
create a calculated, property, use a hash table. Valid keys are:

-- Name (or Label) <string>
-- Expression <string> or <script block>
-- FormatString <string>

-InputObject <psobject>
Specifies the objects to be formatted. Enter a variable that contains t
he objects, or type a command or expression that gets the objects.

-Property <Object>
Specifies the object properties that appear in the display and the orde
r in which they appear. Wildcards are permitted.

If you omit this parameter, the properties that appear in the display d
epend on the object being displayed. The parameter name ("Property") is
optional. You cannot use the Property and View parameters in the same
command.

The value of the Property parameter can be a new calculated property. T
o create a calculated, property, use a hash table. Valid keys are:

-- Expression <string> or <script block>
-- FormatString <string>

-ShowError [<SwitchParameter>]
Sends errors through the pipeline.

-View <string>
Specifies the name of an alternate table format or "view." You cannot u
se the Property and View parameters in the same command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-childitem | format-wide -column 3

Description
-----------
This command displays the names of files in the current directory in three
columns across the screen. The Get-ChildItem cmdlet gets objects representi
ng each file in the directory. The pipeline operator (|) passes the file ob
jects through the pipeline to Format-Wide, which formats them for output. T
he Column parameter specifies the number of columns.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-childitem HKCU:\software\microsoft | format-wide -property pschil
dname -autosize

Description
-----------
This command displays the names of registry keys in the HKEY_CURRENT_USER\S
oftware\Microsoft key. The Get-ChildItem cmdlet gets objects representing t
he keys. The path is specified as "HKCU:", one of the drives exposed by the
Windows PowerShell Registry provider, followed by the key path. The pipeli
ne operator (|) passes the registry key objects through the pipeline to For
mat-Wide, which formats them for output. The Property parameter specifies t
he name of the property, and the AutoSize parameter adjusts the columns for
readability.




REMARKS
To see the examples, type: "get-help Format-Wide -examples".
For more information, type: "get-help Format-Wide -detailed".
For technical information, type: "get-help Format-Wide -full".

G:

NAME
Get-Alias

SYNOPSIS
Gets the aliases for the current session.


SYNTAX
Get-Alias [[-Name] <string[]>] [-Exclude <string[]>] [-Scope <string>] [<Co
mmonParameters>]

Get-Alias [-Definition <string[]>] [-Exclude <string[]>] [-Scope <string>]
[<CommonParameters>]


DESCRIPTION
The Get-Alias cmdlet gets the aliases (alternate names for commands and exe
cutable files) in the current session. This includes built-in aliases, alia
ses that you have set or imported, and aliases that you have added to your
Windows PowerShell profile.

By default, Get-Alias takes an alias and returns the command name. When you
use the Definition parameter, Get-Alias takes a command name and returns i
ts aliases.

PARAMETERS
-Definition <string[]>
Gets the aliases for the specified item. Enter the name of a cmdlet, fu
nction, script, file, or executable file.

This parameter is called Definition, because it searches for the item n
ame in the Definition property of the alias object.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Na
me and Definition parameters. Enter a name, a definition, or a pattern,
such as "s*". Wildcards are permitted.

-Name <string[]>
Specifies the aliases to retrieve. Wildcards are permitted. By default,
Get-Alias retrieves all aliases defined for the current session. The p
arameter name ("Name") is optional. You can also pipe alias names to Ge
t-Alias.

-Scope <string>
Gets only the aliases in the specified scope. Valid values are "Global"
, "Local", or "Script", or a number relative to the current scope (0 th
rough the number of scopes, where 0 is the current scope and 1 is its p
arent). "Local" is the default. For more information, see about_Scopes.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-alias

Description
-----------
This command gets all aliases in the current session.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-alias -name g*, s* -exclude get-*

Description
-----------
This command gets all aliases that begin with "g" or "s", except for aliase
s that begin with "get-".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-alias -definition Get-ChildItem

Description
-----------
This command gets the aliases for the Get-ChildItem cmdlet.

By default, the Get-Alias cmdlet gets the item name when you know the alias
. The Definition parameter gets the alias when you know the item name.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-alias | where-object {$_.Options -match "ReadOnly"}

Description
-----------
This command retrieves all aliases in which the value of the Options proper
ty is ReadOnly. This command provides a quick way to find the aliases that
are built into Windows PowerShell, because they have the ReadOnly option.

Options is just one property of the AliasInfo objects that Get-Alias gets.
To find all properties and methods of AliasInfo objects, type "get-alias |
get-member".




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-alias -definition "*-pssession" -exclude e* -scope global

Description
-----------
This example gets aliases for commands that have names that end in "-pssess
ion", except for those that begin with "e".

The command uses the Scope parameter to apply the command in the global sco
pe. This is useful in scripts when you want to get the aliases in the sessi
on.




REMARKS
To see the examples, type: "get-help Get-Alias -examples".
For more information, type: "get-help Get-Alias -detailed".
For technical information, type: "get-help Get-Alias -full".

NAME
Get-PSBreakpoint

SYNOPSIS
Gets the breakpoints that are set in the current session.


SYNTAX
Get-PSBreakpoint [[-Script] <string[]>] [<CommonParameters>]

Get-PSBreakpoint -Command <string[]> [-Script <string[]>] [<CommonParameter
s>]

Get-PSBreakpoint [-Id] <Int32[]> [<CommonParameters>]

Get-PSBreakpoint [-Type] <BreakpointType[]> [-Script <string[]>] [<CommonPa
rameters>]

Get-PSBreakpoint -Variable <string[]> [-Script <string[]>] [<CommonParamete
rs>]


DESCRIPTION
The Get-PSBreakPoint cmdlet gets the breakpoints that are set in the curren
t session. You can use the cmdlet parameters to get particular breakpoints.

A breakpoint is a point in a command or script where execution stops tempor
arily so that you can examine the instructions. Get-PSBreakpoint is one of
several cmdlets designed for debugging Windows PowerShell scripts and comma
nds. For more information about the Windows PowerShell debugger, see about_
Debuggers.

PARAMETERS
-Command <string[]>
Gets command breakpoints that are set on the specified command names. E
nter the command names, such as the name of a cmdlet or function.

-Id <Int32[]>
Gets the breakpoints with the specified breakpoint IDs. Enter the IDs i
n a comma-separated list. You can also pipe breakpoint IDs to Get-PSBre
akpoint.

-Script <string[]>
Gets only the breakpoints in the specified scripts. Enter the path (op
tional) and names of one or more script files. The default location is
the current directory.

-Type <BreakpointType[]>
Gets only breakpoints of the specified types. Enter one or more types.
Valid values are Line, Command, and Variable. You can also pipe breakpo
int types to Get-PSBreakpoint.

-Variable <string[]>
Gets variable breakpoints that are set on the specified variable names.
Enter the variable names without dollar signs.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-psbreakpoint

Description
-----------
This command gets all breakpoints set on all scripts and functions in the c
urrent session.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-psbreakpoint -Id 2

Function : Increment
Action :
Enabled : True
HitCount : 0
Id : 2
Script : C:\ps-test\sample.ps1
ScriptName : C:\ps-test\sample.ps1

Description
-----------
This command gets the breakpoint with breakpoint ID 2.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$b = set-psbreakpoint -script sample.ps1 -function increment

C:\PS> $b.Id | get-psbreakpoint

Description
-----------
These commands show how to get a breakpoint by piping a breakpoint ID to Ge
t-PSBreakpoint.

The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint o
n the Increment function in the Sample.ps1 script. It saves the breakpoint
object in the $b variable.

The second command uses the dot operator (.) to get the Id property of the
breakpoint object in the $b variable. It uses a pipeline operator (|) to se
nd the ID to the Get-PSBreakpoint cmdlet.

As a result, Get-PSBreakpoint gets the breakpoint with the specified ID.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-psbreakpoint -script Sample.ps1, SupportScript.ps1

Description
-----------
This command gets all of the breakpoints in the Sample.ps1 and SupportScrip
t.ps1 files.

This command does not get other breakpointS that might be set in other scri
pts or on functions in the session.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-psbreakpoint -command Read-Host, Write-Host -script Sample.ps1

Description
-----------
This command gets all Command breakpoints that are set on Read-Host or Writ
e-Host commands in the Sample.ps1 file.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-psbreakpoint -type Command -script Sample.ps1

Description
-----------
This command gets all Command breakpoints in the Sample.ps1 file.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-psbreakpoint -variable Index, Swap

Description
-----------
This command gets breakpoints that are set on the $index and $swap variable
s in the current session.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>get-psbreakpoint -type line, variable -script Sample.ps1

Description
-----------
This command gets all line and variable breakpoints in the Sample.ps1 scrip
t.




REMARKS
To see the examples, type: "get-help Get-PSBreakpoint -examples".
For more information, type: "get-help Get-PSBreakpoint -detailed".
For technical information, type: "get-help Get-PSBreakpoint -full".

NAME
Get-Content

SYNOPSIS
Gets the content of the item at the specified location.


SYNTAX
Get-Content [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Exclud
e <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-ReadCount
<Int64>] [-TotalCount <Int64>] [-UseTransaction] [<CommonParameters>]

Get-Content [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <stri
ng[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-ReadCount <Int64
>] [-TotalCount <Int64>] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Get-Content cmdlet gets the content of the item at the location specifi
ed by the path, such as the text in a file. It reads the content one line a
t a time and returns an object for each line.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers that are installed wit
h Windows PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Overrides restrictions that prevent the command from succeeding, just s
o the changes do not compromise security. For example, Force will overr
ide the read-only attribute or create directories to complete a file pa
th, but it will not attempt to change file permissions.

-Include <string[]>
Retrieves only the specified items. The value of this parameter qualifi
es the Path parameter. Enter a path element or pattern, such as "*.txt"
. Wildcards are permitted.

-LiteralPath <string[]>
Specifies the path to an item. Unlike Path, the value of LiteralPath is
used exactly as it is typed. No characters are interpreted as wildcard
s. If the path includes escape characters, enclose it in single quotati
on marks. Single quotation marks tell Windows PowerShell not to interpr
et any characters as escape sequences.

-Path <string[]>
Specifies the path to an item. Get-Content retrieves the content of the
item. Wildcards are permitted. The parameter name ("Path" or "FilePath
") is optional.

-ReadCount <Int64>
Specifies how many lines of content are sent through the pipeline at a
time. The default value is 1. A value of 0 (zero) sends all of the cont
ent at one time.

This parameter does not change the content displayed, but it does affec
t the time it takes to display the content. As the value of ReadCount i
ncreases, the time it takes to return the first line increases, but the
total time for the operation decreases. This can make a perceptible di
fference in very large items.

-TotalCount <Int64>
Specifies how many lines of content are retrieved. The default is -1 (a
ll lines).

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-content -Path C:\Chapters\chapter1.txt

Description
-----------
This command displays the content of the Chapter1.txt file on the console.
It uses the Path parameter to specify the name of the item. Get-Content act
ually passes the content down the pipeline, but because there are no other
pipeline elements, the content is formatted and displayed on the console.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-content c:\Logs\Log060912.txt -totalcount 50 | set-content sample
.txt

Description
-----------
This command gets the first 50 lines of the Log060912.txt file and stores t
hem in the sample.txt file. The command uses the Get-Content cmdlet to get
the text in the file. (The name of Path parameter, which is optional, is om
itted.) The TotalCount parameter limits the retrieval to the first 50 lines
. The pipeline operator (|) sends the result to Set-Content, which places i
t in the sample.txt file.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>(get-content cmdlets.txt -totalcount 5)[-1]

Description
-----------
This command gets the fifth line of the Cmdlets.txt text file. It uses the
TotalCount parameter to get the first five lines and then uses array notati
on to get the last line (indicated by "-1") of the resulting set.




REMARKS
To see the examples, type: "get-help Get-Content -examples".
For more information, type: "get-help Get-Content -detailed".
For technical information, type: "get-help Get-Content -full".

NAME
Get-ChildItem

SYNOPSIS
Gets the items and child items in one or more specified locations.


SYNTAX
Get-ChildItem [[-Path] <string[]>] [[-Filter] <string>] [-Exclude <string[]
>] [-Force] [-Include <string[]>] [-Name] [-Recurse] [-UseTransaction] [<Co
mmonParameters>]

Get-ChildItem [-LiteralPath] <string[]> [[-Filter] <string>] [-Exclude <str
ing[]>] [-Force] [-Include <string[]>] [-Name] [-Recurse] [-UseTransaction]
[<CommonParameters>]


DESCRIPTION
The Get-ChildItem cmdlet gets the items in one or more specified locations.
If the item is a container, it gets the items inside the container, known
as child items. You can use the Recurse parameter to get items in all child
containers.

A location can be a file system location, such as a directory, or a locatio
n exposed by another provider, such as a registry hive or a certificate sto
re.

PARAMETERS
-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to get items that cannot otherwise not be accessed by
the user, such as hidden or system files. Implementation varies from p
rovider to provider. For more information, see about_Providers. Even us
ing the Force parameter, the cmdlet cannot override security restrictio
ns.

-Include <string[]>
Retrieves only the specified items. The value of this parameter qualifi
es the Path parameter. Enter a path element or pattern, such as "*.txt"
. Wildcards are permitted.

The Include parameter is effective only when the command includes the R
ecurse parameter or the path leads to the contents of a directory, such
as C:\Windows\*, where the wildcard character specifies the contents o
f the C:\Windows directory.

-LiteralPath <string[]>
Specifies a path to one or more locations. Unlike Path, the value of Li
teralPath is used exactly as it is typed. No characters are interpreted
as wildcards. If the path includes escape characters, enclose it in si
ngle quotation marks. Single quotation marks tell Windows PowerShell no
t to interpret any characters as escape sequences.

-Name [<SwitchParameter>]
Retrieves only the names of the items in the locations. If you pipe the
output of this command to another command, only the item names are sen
t.

-Path <string[]>
Specifies a path to one or more locations. Wildcards are permitted. The
default location is the current directory (.).

-Recurse [<SwitchParameter>]
Gets the items in the specified locations and in all child items of the
locations.

Recurse works only when the path points to a container that has child i
tems, such as C:\Windows or C:\Windows\*, and not when it points to ite
ms that do not have child items, such as C:\Windows\*.exe.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-childitem

Description
-----------
This command gets the child items in the current location. If the location
is a file system directory, it gets the files and sub-directories in the cu
rrent directory. If the item does not have child items, this command return
s to the command prompt without displaying anything.

The default display lists the mode (attributes), last write time, file size
(length), and the name of the file. The valid values for mode are d (direc
tory), a (archive), r (read-only), h (hidden), and s (system).




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-childitem . -include *.txt -recurse -force

Description
-----------
This command retrieves all of the .txt files in the current directory and i
ts subdirectories. The dot (.) represents the current directory and the Inc
lude parameter specifies the file name extension. The Recurse parameter dir
ects Windows PowerShell to retrieve objects recursively, and it indicates t
hat the subject of the command is the specified directory and its contents.
The force parameter adds hidden files to the display.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-childitem c:\windows\logs\* -include *.txt -exclude A*

Description
-----------
This command lists the .txt files in the Logs subdirectory, except for thos
e whose names start with the letter A. It uses the wildcard character (*) t
o indicate the contents of the Logs subdirectory, not the directory contain
er. Because the command does not include the Recurse parameter, Get-ChildIt
em does not include the content of directory automatically; you need to spe
cify it.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-childitem registry::hklm\software

Description
-----------
This command retrieves all of the registry keys in the HKEY_LOCAL_MACHINE\S
OFTWARE key in the registry of the local computer.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-childitem -name

Description
-----------
This command retrieves only the names of items in the current directory.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-childitem cert:\. -recurse -codesigningcert

Description
-----------
This command gets all of the certificates in the certificate store that hav
e code-signing authority.

The command uses the Get-ChildItem cmdlet. The path specifies the Cert: dri
ve exposed by the Windows PowerShell certificate provider. The backslash (\
) symbol specifies a subdirectory of the certificate store and the dot (.)
represents the current directory, which would be the root directory of the
certificate store. The Recurse parameter specifies a recursive search.

The CodeSigningCertificate parameter is a dynamic parameter that gets only
certificates with code-signing authority. For more information, type "get-h
elp certificate".




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-childitem * -include *.exe

Description
-----------
This command retrieves all of the items in the current directory with a ".e
xe" file name extension. The wildcard character (*) represents the contents
of the current directory (not the container). When using the Include param
eter without the Recurse parameter, the path must point to contents, not a
container.




REMARKS
To see the examples, type: "get-help Get-ChildItem -examples".
For more information, type: "get-help Get-ChildItem -detailed".
For technical information, type: "get-help Get-ChildItem -full".

NAME
Get-Command

SYNOPSIS
Gets basic information about cmdlets and other elements of Windows PowerShe
ll commands.


SYNTAX
Get-Command [[-Name] <string[]>] [-CommandType {Alias | Function | Filter |
Cmdlet | ExternalScript | Application | Script | All}] [[-ArgumentList] <O
bject[]>] [-Module <string[]>] [-Syntax] [-TotalCount <int>] [<CommonParame
ters>]

Get-Command [-Noun <string[]>] [-Verb <string[]>] [[-ArgumentList] <Object[
]>] [-Module <string[]>] [-Syntax] [-TotalCount <int>] [<CommonParameters>]


DESCRIPTION
The Get-Command cmdlet gets basic information about cmdlets and other eleme
nts of Windows PowerShell commands in the session, such as aliases, functio
ns, filters, scripts, and applications.

Get-Command gets its data directly from the code of a cmdlet, function, scr
ipt, or alias, unlike Get-Help, which gets its information from help topic
files.

Without parameters, "Get-Command" gets all of the cmdlets and functions in
the current session. "Get-Command *" gets all Windows PowerShell elements a
nd all of the non-Windows-PowerShell files in the Path environment variable
($env:path). It groups the files in the "Application" command type.

You can use the Module parameter of Get-Command to find the commands that w
ere added to the session by adding a Windows PowerShell snap-in or importin
g a module.

PARAMETERS
-ArgumentList <Object[]>
Gets information about a cmdlet or function when it is used with the sp
ecified parameters ("arguments"), such as a path. The alias for Argum
entList is Args.

To detect parameters that are added to a cmdlet when it is used with a
particular provider, set the value of ArgumentList to a path in the pro
vider drive, such as "HKML\Software" or "cert:\my".

-CommandType <CommandTypes>
Gets only the specified types of commands. Use "CommandType" or its ali
as, "Type". By default, Get-Command gets cmdlets and functions.

Valid values are:
-- Alias: All Windows PowerShell aliases in the current session.

-- All: All command types. It is the equivalent of "get-command *".

-- Application: All non-Windows-PowerShell files in paths listed in the
Path environment variable ($env:path), including .txt, .exe, and .dll
files.

-- Cmdlet: The cmdlets in the current session. "Cmdlet" is the default.

-- ExternalScript: All .ps1 files in the paths listed in the Path envir
onment variable ($env:path).

-- Filter and Function: All Windows PowerShell functions.

-- Script: Script blocks in the current session.

-Module <string[]>
Gets the commands that came from the specified modules or snap-ins. Ent
er the names of modules or snap-ins, or enter snap-in or module objects
.

You can refer to this parameter by its name, Module, or by its alias, P
SSnapin. The parameter name that you choose has no effect on the comman
d or its output.

This parameter takes string values, but you can also supply a PSModuleI
nfo or PSSnapinInfo object, such as the objects that Get-Module, Get-PS
Snapin, and Import-PSSession return.

-Name <string[]>
Gets information only about the cmdlets or command elements with the sp
ecified name. <String> represents all or part of the name of the cmdlet
or command element. Wildcards are permitted.

To list commands with the same name in execution order, type the comman
d name without wildcard characters. For more information, see the Notes
section.

-Noun <string[]>
Gets cmdlets and functions with names that include the specified noun.
<String> represents one or more nouns or noun patterns, such as "proces
s" or "*item*". Wildcards are permitted.

-Syntax [<SwitchParameter>]
Gets only specified data about the command element.
* For aliases, retrieves the standard name.
* For cmdlets, retrieves the syntax.
* For functions and filters, retrieves the function definiti
on.
* For scripts and applications (files), retrieves the path a
nd filename.

-TotalCount <int>
Gets only the specified number of command elements. You can use this pa
rameter to limit the output of a command.

-Verb <string[]>
Gets information about cmdlets and functions with names that include th
e specified verb. <String> represents one or more verbs or verb pattern
s, such as "remove" or *et". Wildcards are permitted.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-command

Description
-----------
This command gets information about all of the Windows PowerShell cmdlets a
nd functions.

The default display lists the command type ("Cmdlet" or "Function" or "Filt
er"), the name of the cmdlet or function, and the syntax or function defini
tion.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-command -verb set | format-list

Description
-----------
This command gets information about all of the cmdlets and functions with t
he verb "set", and it displays some of that information in a list.

The list format includes fields that are omitted from the table display, in
cluding the complete syntax. To display all fields (all properties of the o
bject), type "get-command -verb set | format-list *".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-command -type cmdlet | sort-object noun | format-table -group nou
n

Description
-----------
This command retrieves all of the cmdlets, sorts them alphabetically by the
noun in the cmdlet name, and then displays them in noun-based
groups. This display can help you find the cmdlets for a task.

By default, Get-Command displays items in the order in which the system dis
covers them, which is also the order in which they are selected to run when
a run command is ambiguous.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-command -module Microsoft.PowerShell.Security, TestModule

Description
-----------
This command gets the commands in the Microsoft.PowerShell.Security snap-in
and the Test-Module module.

The Module parameter gets commands that were added by importing modules or
adding Windows PowerShell snap-ins.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-command get-childitem -args cert: -syntax

Description
-----------
This command retrieves information about the Get-ChildItem cmdlet when Get-
ChildItem is used with the Windows PowerShell Certificate provider.

When you compare the syntax displayed in the output with the syntax that is
displayed when you omit the Args (ArgumentList) parameter, you'll see that
the Certificate provider dynamically adds a parameter, CodeSigningCert, to
the Get-ChildItem cmdlet.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>(get-command get-childitem -ArgumentList cert:).parametersets[0].para
meters | where-object { $_.IsDynamic }

Description
-----------
This command retrieves only parameters that are added to the Get-ChildItem
cmdlet dynamically when it is used with the Windows PowerShell Certificate
provider. This is an alternative to the method used in the previous example
.

In this command, the "get-command get-childitem -ArgumentList cert:" is pro
cessed first. It requests information from Get-Command about the Get-ChildI
tem cmdlet when it is used with the Certificate provider. The ".parameterse
ts[0]" selects the first parameter set (set 0) of "get-childitem -argumentL
ist cert:" and ".parameters" selects the parameters in that parameter set.
The resulting parameters are piped to the Where-Object cmdlet to test each
parameter ("$_.") by using the IsDynamic property. To find the properties o
f the objects in a command, use Get-Member.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-command *

Description
-----------
This command gets information about the Windows PowerShell cmdlets, functio
ns, filters, scripts, and aliases in the current console.

It also gets information about all of the files in the paths of the Path en
vironment variable ($env:path). It returns an ApplicationInfo object (Syste
m.Management.Automation.ApplicationInfo) for each file, not a FileInfo obje
ct (System.IO.FileInfo).




-------------------------- EXAMPLE 8 --------------------------

C:\PS>get-command | where-object {$_.definition -like "*first*"}

CommandType Name Definition
----------- ---- ---------
Cmdlet Select-Object Select-Object [[-Property]

Description
-----------
This command finds a cmdlet or function based on the name of one of its par
ameters. You can use this command to identify a cmdlet or function when all
that you can recall is the name of one of its parameters.

In this case, you recall that one of the cmdlets or functions has a First p
arameter that gets the first "n" objects in a list, but you cannot remember
which cmdlet it is.

This command uses the Get-Command cmdlet to get a CmdletInfo object represe
nting each of the cmdlets and functions in the session. The CmdletInfo obje
ct has a Definition property that contains the syntax of the cmdlet or func
tion, which includes its parameters.

The command uses a pipeline operator (|) to pass the CmdletInfo object to t
he Where-Object cmdlet, which examines the definition (syntax) of each obje
ct ($_) for a value that includes "first".

The result shows that the First parameter belongs to the Select-Object cmdl
et.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>get-command dir | format-list

Name : dir
CommandType : Alias
Definition : Get-ChildItem
ReferencedCommand : Get-ChildItem
ResolvedCommand : Get-ChildItem

Description
-----------
This example shows how to use the Get-Command cmdlet with an alias. Althoug
h it is typically used on cmdlets, Get-Command also displays information ab
out the code in scripts, functions, aliases, and executable files.

This command displays the "dir" alias in the current console. The command p
ipes the result to the Format-List cmdlets.




-------------------------- EXAMPLE 10 --------------------------

C:\PS>get-command notepad

CommandType Name Definition
----------- ---- ----------
Application notepad.exe C:\WINDOWS\system32\notepad.exe
Application NOTEPAD.EXE C:\WINDOWS\NOTEPAD.EXE

Description
-----------
This example shows how to use Get-Command to determine which command Window
s PowerShell runs when it has access to multiple commands with the same nam
e. When you use the Name parameter without wildcard characters, Get-Command
lists the commands with that name in execution precedence order.

This command shows which Notepad program Windows PowerShell runs when you t
ype "Notepad" without a fully qualified path. The command uses the Name par
ameter without wildcard characters.

The sample output shows the Notepad commands in the current console. It ind
icates that Windows PowerShell will run the instance of Notepad.exe in the
C:\Windows\System32 directory.




-------------------------- EXAMPLE 11 --------------------------

C:\PS>(get-command get-date).pssnapin

C:\PS> (get-command remove-gpo).module

Description
-----------
These commands show how to find the snap-in or module from which a particul
ar cmdlet originated.

The first command uses the PSSnapin property of the CmdletInfo object to fi
nd the snap-in that added the Get-Date cmdlet.

The second command uses the Module property of the CmdletInfo object to fin
d the module that added the Remove-GPO cmdlet.




REMARKS
To see the examples, type: "get-help Get-Command -examples".
For more information, type: "get-help Get-Command -detailed".
For technical information, type: "get-help Get-Command -full".

NAME
Get-PSCallStack

SYNOPSIS
Displays the current call stack.


SYNTAX
Get-PSCallStack [<CommonParameters>]


DESCRIPTION
The Get-PSCallStack cmdlet displays the current call stack.

Although it is designed to be used with the Windows PowerShell debugger, yo
u can use this cmdlet to display the call stack in a script or function out
side of the debugger.

To run a Get-PSCallStack command while in the debugger, type "k" or "get-p
scallstack".

PARAMETERS
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>function my-alias {
$p = $args[0]
get-alias | where {$_.definition -like "*$p"} | ft definition, name -aut
o
}

PS C:\ps-test> set-psbreakpoint -command my-alias

Command : my-alias
Action :
Enabled : True
HitCount : 0
Id : 0
Script : prompt


PS C:\ps-test> my-alias get-content
Entering debug mode. Use h or ? for help.

Hit Command breakpoint on 'prompt:my-alias'

my-alias get-content

[DBG]: PS C:\ps-test> s
$p = $args[0]

DEBUG: Stepped to ': $p = $args[0] '

[DBG]: PS C:\ps-test> s
get-alias | Where {$_.Definition -like "*$p*"} | ft Definition,

[DBG]: PS C:\ps-test>get-pscallstack

Name CommandLineParameters UnboundArguments Loc
ation
---- --------------------- ---------------- ---
-----
prompt {} {} pro
mpt
my-alias {} {get-content} pro
mpt
prompt {} {} pro
mpt


[DBG]: PS C:\ps-test> o

Definition Name
---------- ----
Get-Content gc
Get-Content cat
Get-Content type

Description
-----------
This command uses the Get-PSCallStack cmdlet to display the call stack for
My-Alias, a simple function that gets the aliases for a cmdlet name.

The first command enters the function at the Windows PowerShell prompt. The
second command uses the Set-PSBreakpoint cmdlet to set a breakpoint on the
My-Alias function. The third command uses the My-Alias function to get all
of the aliases in the current session for the Get-Content cmdlet.

The debugger breaks in at the function call. Two consecutive step-into (s)
commands begin executing the function line by line. Then, a Get-PSCallStack
command is used to retrieve the call stack.

The final command is a Step-Out command (o) that exits the debugger and con
tinues executing the script to completion.




REMARKS
To see the examples, type: "get-help Get-PSCallStack -examples".
For more information, type: "get-help Get-PSCallStack -detailed".
For technical information, type: "get-help Get-PSCallStack -full".

NAME
Get-PSDrive

SYNOPSIS
Gets the Windows PowerShell drives in the current session.


SYNTAX
Get-PSDrive [-LiteralName] <string[]> [-PSProvider <string[]>] [-Scope <str
ing>] [-UseTransaction] [<CommonParameters>]

Get-PSDrive [[-Name] <string[]>] [-PSProvider <string[]>] [-Scope <string>]
[-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Get-PSDrive cmdlet gets the Windows PowerShell drives in the current se
ssion. You can get a particular drive or all drives in the console.

Get-PSDrive gets the following drives:

-- Windows logical drives on the computer, including drives mapped to netwo
rk shares.

-- Drives exposed by Windows PowerShell providers (such as the Certificate:
, Function:, and Alias: drives) and the HKLM: and HKCU: drives that are exp
osed by the Windows PowerShell Registry provider.

-- Drives that you create by using New-PSDrive.

Get-PSDrive does not get Windows mapped drives that are added or created af
ter the Windows PowerShell console is opened.

PARAMETERS
-LiteralName <string[]>
Specifies the name of the Windows PowerShell drive.

The value of LiteralName is used exactly as it is typed. No characters
are interpreted as wildcards. If the name includes escape characters, e
nclose it in single quotation marks. Single quotation marks tell Window
s PowerShell not to interpret any characters as escape sequences.

-Name <string[]>
Gets only the specified drives. Type the drive name or letter without a
colon (:).

-PSProvider <string[]>
Gets only the drives supported by the specified Windows PowerShell prov
ider. Type the name of a provider, such as FileSystem, Registry, or Cer
tificate.

-Scope <string>
Gets only the Windows PowerShell drives in the specified scope. Valid v
alues are "Global", "Local", or "Script", or a number relative to the c
urrent scope (0 through the number of scopes, where 0 is the current sc
ope and 1 is its parent). "Local" is the default. For more information,
see about_Scopes.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-psdrive

Name Provider Root
---- -------- ----
Alias Alias
C FileSystem C:\
cert Certificate \
D FileSystem D:\
Env Environment
Function Function
HKCU Registry HKEY_CURRENT_USER
HKLM Registry HKEY_LOCAL_MACHINE
Variable Variable
X FileSystem X:\

Description
-----------
This command gets the Windows PowerShell drives in the current session.

The output shows the hard drive (C:) and CD-ROM drive (D:) on the computer,
the drives exposed by the Windows PowerShell providers (Alias:, Cert:, Env
:, Function:, HKCU:, HKLM:, and Variable:), and a drive mapped to a network
share (X:).




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-psdrive d

Name Provider Root
---- -------- ----
D FileSystem D:\

Description
-----------
This command displays the D: drive on the computer. Note that the drive let
ter is not followed by a colon.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-psdrive -psprovider filesystem

Name Provider Root
---- -------- ----
C FileSystem C:\
D FileSystem D:\
X FileSystem X:\
Y FileSystem \\Server01\Public
Z FileSystem C:\Windows\System32

Description
-----------
This command displays all of the drives that are supported by the Windows P
owerShell FileSystem provider. This includes fixed drives, logical partitio
ns, mapped network drives, and drives that you create by using New-PSDrive
that are mapped to the file system drives.

This example shows that drives created by New-PSDrive have the name of the
mapped location in the value of the Root property. Windows drives just have
the root of the drive letter.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>if (!(get-psdrive X)) {
new-psdrive -name X -psprovider Registry -root HKLM:\Network
}
else { write-host "The X: drive is already in use." }

Description
-----------
This command checks to see whether the X drive is already in use as the Win
dows PowerShell drive name. If it is not, the command uses the New-PSDrive
cmdlet to create a Windows PowerShell drive that is mapped to the HKLM:\Net
work registry key.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-psdrive -provider filesystem

C:\PS> get-psdrive -provider filesystem

Name Provider Root
---- -------- ----
C FileSystem C:\
D FileSystem D:\
X FileSystem X:\
Y FileSystem \\Server01\Public
Z FileSystem C:\Windows\System32

C:\PS> net use
New connections will be remembered.

Status Local Remote Network
---------------------------------------------------------------------------
----
X: \\Server01\Public Microsoft Windows Network


C:\PS> [System.IO.DriveInfo]::getdrives()

Name : C:\
DriveType : Fixed
DriveFormat : NTFS
IsReady : True
AvailableFreeSpace : 39831498752
TotalFreeSpace : 39831498752
TotalSize : 79900368896
RootDirectory : C:\
VolumeLabel :
Name : D:\
DriveType : CDRom
DriveFormat :
IsReady : False
AvailableFreeSpace :
TotalFreeSpace :
TotalSize :
RootDirectory : D:\
VolumeLabel :
Name : X:\
DriveType : Network
DriveFormat : NTFS
IsReady : True
AvailableFreeSpace : 36340559872
TotalFreeSpace : 36340559872
TotalSize : 36413280256
RootDirectory : X:\
VolumeLabel : D_Drive


C:\PS> get-wmiobject win32_logicaldisk

DeviceID : C:
DriveType : 3
ProviderName :
FreeSpace : 39831252992
Size : 79900368896
VolumeName :
DeviceID : D:
DriveType : 5
ProviderName :
FreeSpace :
Size :
VolumeName :
DeviceID : X:
DriveType : 4
ProviderName : \\server01\public
FreeSpace : 36340559872
Size : 36413280256
VolumeName : D_Drive


C:\PS> get-wmiobject win32_networkconnection
LocalName RemoteName
-------------- ------------
x: \\server01\public

Description
-----------
This example compares the types of file system drives that are displayed by
Get-PSDrive to those displayed by using other methods. This example demons
trates different ways to display drives in Windows PowerShell, and it shows
that the drives created by using New-PSDrive are accessible only in Window
s PowerShell.

The first command uses Get-PSDrive to get all of the file system drives in
the Windows PowerShell console. This includes the fixed drives (C: and D:),
the mapped network drive (X:), and two Windows PowerShell drives (Y: and Z
:) that were created by using New-PsDrive.

A "net use" command, which displays Windows mapped network drives, displays
only the X drive. It does not display drives that are created by New-PSDri
ve. It shows that the X: drive is also mapped to \\Server01\Public.

The third command uses the GetDrives method of the Microsoft .NET Framework
System.IO.DriveInfo class. This command gets the Windows file system drive
s, including drive X:, but it does not get the drives created by New-PSDriv
e.

The fourth command uses the Get-WmiObject cmdlet to display the instances o
f the Win32_LogicalDisk class. It returns the C:, D:, and X: drives, but no
t the drives created by New-PSDrive.

The last command uses the Get-WmiObject cmdlet to display the instances of
the Win32_NetworkConnection class. Like "net use", it returns only the X: d
rive.




REMARKS
To see the examples, type: "get-help Get-PSDrive -examples".
For more information, type: "get-help Get-PSDrive -detailed".
For technical information, type: "get-help Get-PSDrive -full".

NAME
Get-Acl

SYNOPSIS
Gets the security descriptor for a resource, such as a file or registry key
.


SYNTAX
Get-Acl [[-Path] <string[]>] [-Audit] [-Exclude <string[]>] [-Filter <strin
g>] [-Include <string[]>] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Get-Acl cmdlet gets objects that represent the security descriptor of a
file or resource. The security descriptor contains the access control list
s (ACLs) of the resource. The ACL specifies the permissions that users and
user groups have to access the resource.

PARAMETERS
-Audit [<SwitchParameter>]
Gets the audit data for the security descriptor from the system access
control list (SACL).

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Include <string[]>
Retrieves only the specified items. The value of this parameter qualifi
es the Path parameter. Enter a path element or pattern, such as "*.txt"
. Wildcards are permitted.

-Path <string[]>
Specifies the path to a resource. Get-Acl gets the security descriptor
of the resource indicated by the path. Wildcards are permitted. If you
omit the Path parameter, Get-Acl gets the security descriptor of the cu
rrent directory.

The parameter name ("Path") is optional.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-acl C:\windows

Description
-----------
This command gets the security descriptor of the C:Windows directory.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-acl C:\Windows\k*.log | format-list -property PSPath, Sddl

Description
-----------
This command gets the Windows PowerShell path and SDDL for all of the .log
files in the C:\Windows directory whose names begin with "k."

The command uses Get-Acl to get objects representing the security descripto
rs of each log file. It uses a pipeline operator (|) to send the results to
the Format-List cmdlet. The command uses the Property parameter of Format-
List to display only the PsPath and SDDL properties of each security descri
ptor object.

Lists are often used in Windows PowerShell, because long values appear trun
cated in tables.

The SDDL values are valuable to system administrators, because they are sim
ple text strings that contain all of the information in the security descri
ptor. As such, they are easy to pass and store, and they can be parsed when
needed.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-ACL c:/windows/k*.log -Audit | foreach-object { $_.Audit.Count }

Description
-----------
This command gets the security descriptors of the .log files in the C:\Wind
ows directory whose names begin with "k." It uses the Audit parameter to re
trieve the audit records from the SACL in the security descriptor. Then it
uses the For-EachObject parameter to count the number of audit records asso
ciated with each file. The result is a list of numbers representing the num
ber of audit records for each log file.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-acl -path hklm:\system\currentcontrolset\control | format-list

Description
-----------
This command uses Get-Acl to get the security descriptor of the Control sub
key (HKLM\SYSTEM\CurrentControlSet\Control) of the registry.

The Path parameter specifies the Control subkey. The pipeline operator (|)
passes the security descriptor that Get-Acl retrieves to the Format-List co
mmand, which formats the properties of the security descriptor as a list so
that they are easy to read.




REMARKS
To see the examples, type: "get-help Get-Acl -examples".
For more information, type: "get-help Get-Acl -detailed".
For technical information, type: "get-help Get-Acl -full".

NAME
Get-Alias

SYNOPSIS
Gets the aliases for the current session.


SYNTAX
Get-Alias [[-Name] <string[]>] [-Exclude <string[]>] [-Scope <string>] [<Co
mmonParameters>]

Get-Alias [-Definition <string[]>] [-Exclude <string[]>] [-Scope <string>]
[<CommonParameters>]


DESCRIPTION
The Get-Alias cmdlet gets the aliases (alternate names for commands and exe
cutable files) in the current session. This includes built-in aliases, alia
ses that you have set or imported, and aliases that you have added to your
Windows PowerShell profile.

By default, Get-Alias takes an alias and returns the command name. When you
use the Definition parameter, Get-Alias takes a command name and returns i
ts aliases.

PARAMETERS
-Definition <string[]>
Gets the aliases for the specified item. Enter the name of a cmdlet, fu
nction, script, file, or executable file.

This parameter is called Definition, because it searches for the item n
ame in the Definition property of the alias object.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Na
me and Definition parameters. Enter a name, a definition, or a pattern,
such as "s*". Wildcards are permitted.

-Name <string[]>
Specifies the aliases to retrieve. Wildcards are permitted. By default,
Get-Alias retrieves all aliases defined for the current session. The p
arameter name ("Name") is optional. You can also pipe alias names to Ge
t-Alias.

-Scope <string>
Gets only the aliases in the specified scope. Valid values are "Global"
, "Local", or "Script", or a number relative to the current scope (0 th
rough the number of scopes, where 0 is the current scope and 1 is its p
arent). "Local" is the default. For more information, see about_Scopes.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-alias

Description
-----------
This command gets all aliases in the current session.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-alias -name g*, s* -exclude get-*

Description
-----------
This command gets all aliases that begin with "g" or "s", except for aliase
s that begin with "get-".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-alias -definition Get-ChildItem

Description
-----------
This command gets the aliases for the Get-ChildItem cmdlet.

By default, the Get-Alias cmdlet gets the item name when you know the alias
. The Definition parameter gets the alias when you know the item name.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-alias | where-object {$_.Options -match "ReadOnly"}

Description
-----------
This command retrieves all aliases in which the value of the Options proper
ty is ReadOnly. This command provides a quick way to find the aliases that
are built into Windows PowerShell, because they have the ReadOnly option.

Options is just one property of the AliasInfo objects that Get-Alias gets.
To find all properties and methods of AliasInfo objects, type "get-alias |
get-member".




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-alias -definition "*-pssession" -exclude e* -scope global

Description
-----------
This example gets aliases for commands that have names that end in "-pssess
ion", except for those that begin with "e".

The command uses the Scope parameter to apply the command in the global sco
pe. This is useful in scripts when you want to get the aliases in the sessi
on.




REMARKS
To see the examples, type: "get-help Get-Alias -examples".
For more information, type: "get-help Get-Alias -detailed".
For technical information, type: "get-help Get-Alias -full".

NAME
Get-AuthenticodeSignature

SYNOPSIS
Gets information about the Authenticode signature in a file.


SYNTAX
Get-AuthenticodeSignature [-FilePath] <string[]> [<CommonParameters>]


DESCRIPTION
The Get-AuthenticodeSignature cmdlet gets information about the Authenticod
e signature in a file. If the file is not signed, the information is retrie
ved, but the fields are blank.

PARAMETERS
-FilePath <string[]>
Specifies the path to the file being examined. Wildcards are permitted,
but they must lead to a single file. The parameter name ("FilePath") i
s optional.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-AuthenticodeSignature -filepath C:\Test\NewScript.ps1

Description
-----------
This command gets information about the Authenticode signature in the NewSc
ript.ps1 file. It uses the FilePath parameter to specify the file.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-authenticodesignature test.ps1, test1.ps1, sign-file.ps1, makexml
.ps1

Description
-----------
This command gets information about the Authenticode signature in the four
files listed at the command line. In this command, the name of the FilePath
parameter, which is optional, is omitted.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-childitem $pshome\*.* | foreach-object {Get-AuthenticodeSignature
$_} | where {$_.status -eq "Valid"}

Description
-----------
This command lists all of the files in the $pshome directory that have a va
lid Authenticode signature. The $pshome automatic variable contains the pat
h to the Windows PowerShell installation directory.

The command uses the Get-ChildItem cmdlet to get the files in the $pshome d
irectory. It uses a pattern of *.* to exclude directories (although it also
excludes files without a dot in the filename).

The command uses a pipeline operator (|) to send the files in $pshome to th
e Foreach-Object cmdlet, where Get-AuthenticodeSignature is called for each
file.

The results of the Get-AuthenticodeSignature command are sent to a Where-Ob
ject command that selects only the signature objects with a status of "Vali
d".




REMARKS
To see the examples, type: "get-help Get-AuthenticodeSignature -examples".
For more information, type: "get-help Get-AuthenticodeSignature -detailed".
For technical information, type: "get-help Get-AuthenticodeSignature -full"
.

NAME
Get-ChildItem

SYNOPSIS
Gets the items and child items in one or more specified locations.


SYNTAX
Get-ChildItem [[-Path] <string[]>] [[-Filter] <string>] [-Exclude <string[]
>] [-Force] [-Include <string[]>] [-Name] [-Recurse] [-UseTransaction] [<Co
mmonParameters>]

Get-ChildItem [-LiteralPath] <string[]> [[-Filter] <string>] [-Exclude <str
ing[]>] [-Force] [-Include <string[]>] [-Name] [-Recurse] [-UseTransaction]
[<CommonParameters>]


DESCRIPTION
The Get-ChildItem cmdlet gets the items in one or more specified locations.
If the item is a container, it gets the items inside the container, known
as child items. You can use the Recurse parameter to get items in all child
containers.

A location can be a file system location, such as a directory, or a locatio
n exposed by another provider, such as a registry hive or a certificate sto
re.

PARAMETERS
-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to get items that cannot otherwise not be accessed by
the user, such as hidden or system files. Implementation varies from p
rovider to provider. For more information, see about_Providers. Even us
ing the Force parameter, the cmdlet cannot override security restrictio
ns.

-Include <string[]>
Retrieves only the specified items. The value of this parameter qualifi
es the Path parameter. Enter a path element or pattern, such as "*.txt"
. Wildcards are permitted.

The Include parameter is effective only when the command includes the R
ecurse parameter or the path leads to the contents of a directory, such
as C:\Windows\*, where the wildcard character specifies the contents o
f the C:\Windows directory.

-LiteralPath <string[]>
Specifies a path to one or more locations. Unlike Path, the value of Li
teralPath is used exactly as it is typed. No characters are interpreted
as wildcards. If the path includes escape characters, enclose it in si
ngle quotation marks. Single quotation marks tell Windows PowerShell no
t to interpret any characters as escape sequences.

-Name [<SwitchParameter>]
Retrieves only the names of the items in the locations. If you pipe the
output of this command to another command, only the item names are sen
t.

-Path <string[]>
Specifies a path to one or more locations. Wildcards are permitted. The
default location is the current directory (.).

-Recurse [<SwitchParameter>]
Gets the items in the specified locations and in all child items of the
locations.

Recurse works only when the path points to a container that has child i
tems, such as C:\Windows or C:\Windows\*, and not when it points to ite
ms that do not have child items, such as C:\Windows\*.exe.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-childitem

Description
-----------
This command gets the child items in the current location. If the location
is a file system directory, it gets the files and sub-directories in the cu
rrent directory. If the item does not have child items, this command return
s to the command prompt without displaying anything.

The default display lists the mode (attributes), last write time, file size
(length), and the name of the file. The valid values for mode are d (direc
tory), a (archive), r (read-only), h (hidden), and s (system).




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-childitem . -include *.txt -recurse -force

Description
-----------
This command retrieves all of the .txt files in the current directory and i
ts subdirectories. The dot (.) represents the current directory and the Inc
lude parameter specifies the file name extension. The Recurse parameter dir
ects Windows PowerShell to retrieve objects recursively, and it indicates t
hat the subject of the command is the specified directory and its contents.
The force parameter adds hidden files to the display.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-childitem c:\windows\logs\* -include *.txt -exclude A*

Description
-----------
This command lists the .txt files in the Logs subdirectory, except for thos
e whose names start with the letter A. It uses the wildcard character (*) t
o indicate the contents of the Logs subdirectory, not the directory contain
er. Because the command does not include the Recurse parameter, Get-ChildIt
em does not include the content of directory automatically; you need to spe
cify it.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-childitem registry::hklm\software

Description
-----------
This command retrieves all of the registry keys in the HKEY_LOCAL_MACHINE\S
OFTWARE key in the registry of the local computer.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-childitem -name

Description
-----------
This command retrieves only the names of items in the current directory.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-childitem cert:\. -recurse -codesigningcert

Description
-----------
This command gets all of the certificates in the certificate store that hav
e code-signing authority.

The command uses the Get-ChildItem cmdlet. The path specifies the Cert: dri
ve exposed by the Windows PowerShell certificate provider. The backslash (\
) symbol specifies a subdirectory of the certificate store and the dot (.)
represents the current directory, which would be the root directory of the
certificate store. The Recurse parameter specifies a recursive search.

The CodeSigningCertificate parameter is a dynamic parameter that gets only
certificates with code-signing authority. For more information, type "get-h
elp certificate".




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-childitem * -include *.exe

Description
-----------
This command retrieves all of the items in the current directory with a ".e
xe" file name extension. The wildcard character (*) represents the contents
of the current directory (not the container). When using the Include param
eter without the Recurse parameter, the path must point to contents, not a
container.




REMARKS
To see the examples, type: "get-help Get-ChildItem -examples".
For more information, type: "get-help Get-ChildItem -detailed".
For technical information, type: "get-help Get-ChildItem -full".

NAME
Get-Command

SYNOPSIS
Gets basic information about cmdlets and other elements of Windows PowerShe
ll commands.


SYNTAX
Get-Command [[-Name] <string[]>] [-CommandType {Alias | Function | Filter |
Cmdlet | ExternalScript | Application | Script | All}] [[-ArgumentList] <O
bject[]>] [-Module <string[]>] [-Syntax] [-TotalCount <int>] [<CommonParame
ters>]

Get-Command [-Noun <string[]>] [-Verb <string[]>] [[-ArgumentList] <Object[
]>] [-Module <string[]>] [-Syntax] [-TotalCount <int>] [<CommonParameters>]


DESCRIPTION
The Get-Command cmdlet gets basic information about cmdlets and other eleme
nts of Windows PowerShell commands in the session, such as aliases, functio
ns, filters, scripts, and applications.

Get-Command gets its data directly from the code of a cmdlet, function, scr
ipt, or alias, unlike Get-Help, which gets its information from help topic
files.

Without parameters, "Get-Command" gets all of the cmdlets and functions in
the current session. "Get-Command *" gets all Windows PowerShell elements a
nd all of the non-Windows-PowerShell files in the Path environment variable
($env:path). It groups the files in the "Application" command type.

You can use the Module parameter of Get-Command to find the commands that w
ere added to the session by adding a Windows PowerShell snap-in or importin
g a module.

PARAMETERS
-ArgumentList <Object[]>
Gets information about a cmdlet or function when it is used with the sp
ecified parameters ("arguments"), such as a path. The alias for Argum
entList is Args.

To detect parameters that are added to a cmdlet when it is used with a
particular provider, set the value of ArgumentList to a path in the pro
vider drive, such as "HKML\Software" or "cert:\my".

-CommandType <CommandTypes>
Gets only the specified types of commands. Use "CommandType" or its ali
as, "Type". By default, Get-Command gets cmdlets and functions.

Valid values are:
-- Alias: All Windows PowerShell aliases in the current session.

-- All: All command types. It is the equivalent of "get-command *".

-- Application: All non-Windows-PowerShell files in paths listed in the
Path environment variable ($env:path), including .txt, .exe, and .dll
files.

-- Cmdlet: The cmdlets in the current session. "Cmdlet" is the default.

-- ExternalScript: All .ps1 files in the paths listed in the Path envir
onment variable ($env:path).

-- Filter and Function: All Windows PowerShell functions.

-- Script: Script blocks in the current session.

-Module <string[]>
Gets the commands that came from the specified modules or snap-ins. Ent
er the names of modules or snap-ins, or enter snap-in or module objects
.

You can refer to this parameter by its name, Module, or by its alias, P
SSnapin. The parameter name that you choose has no effect on the comman
d or its output.

This parameter takes string values, but you can also supply a PSModuleI
nfo or PSSnapinInfo object, such as the objects that Get-Module, Get-PS
Snapin, and Import-PSSession return.

-Name <string[]>
Gets information only about the cmdlets or command elements with the sp
ecified name. <String> represents all or part of the name of the cmdlet
or command element. Wildcards are permitted.

To list commands with the same name in execution order, type the comman
d name without wildcard characters. For more information, see the Notes
section.

-Noun <string[]>
Gets cmdlets and functions with names that include the specified noun.
<String> represents one or more nouns or noun patterns, such as "proces
s" or "*item*". Wildcards are permitted.

-Syntax [<SwitchParameter>]
Gets only specified data about the command element.
* For aliases, retrieves the standard name.
* For cmdlets, retrieves the syntax.
* For functions and filters, retrieves the function definiti
on.
* For scripts and applications (files), retrieves the path a
nd filename.

-TotalCount <int>
Gets only the specified number of command elements. You can use this pa
rameter to limit the output of a command.

-Verb <string[]>
Gets information about cmdlets and functions with names that include th
e specified verb. <String> represents one or more verbs or verb pattern
s, such as "remove" or *et". Wildcards are permitted.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-command

Description
-----------
This command gets information about all of the Windows PowerShell cmdlets a
nd functions.

The default display lists the command type ("Cmdlet" or "Function" or "Filt
er"), the name of the cmdlet or function, and the syntax or function defini
tion.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-command -verb set | format-list

Description
-----------
This command gets information about all of the cmdlets and functions with t
he verb "set", and it displays some of that information in a list.

The list format includes fields that are omitted from the table display, in
cluding the complete syntax. To display all fields (all properties of the o
bject), type "get-command -verb set | format-list *".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-command -type cmdlet | sort-object noun | format-table -group nou
n

Description
-----------
This command retrieves all of the cmdlets, sorts them alphabetically by the
noun in the cmdlet name, and then displays them in noun-based
groups. This display can help you find the cmdlets for a task.

By default, Get-Command displays items in the order in which the system dis
covers them, which is also the order in which they are selected to run when
a run command is ambiguous.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-command -module Microsoft.PowerShell.Security, TestModule

Description
-----------
This command gets the commands in the Microsoft.PowerShell.Security snap-in
and the Test-Module module.

The Module parameter gets commands that were added by importing modules or
adding Windows PowerShell snap-ins.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-command get-childitem -args cert: -syntax

Description
-----------
This command retrieves information about the Get-ChildItem cmdlet when Get-
ChildItem is used with the Windows PowerShell Certificate provider.

When you compare the syntax displayed in the output with the syntax that is
displayed when you omit the Args (ArgumentList) parameter, you'll see that
the Certificate provider dynamically adds a parameter, CodeSigningCert, to
the Get-ChildItem cmdlet.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>(get-command get-childitem -ArgumentList cert:).parametersets[0].para
meters | where-object { $_.IsDynamic }

Description
-----------
This command retrieves only parameters that are added to the Get-ChildItem
cmdlet dynamically when it is used with the Windows PowerShell Certificate
provider. This is an alternative to the method used in the previous example
.

In this command, the "get-command get-childitem -ArgumentList cert:" is pro
cessed first. It requests information from Get-Command about the Get-ChildI
tem cmdlet when it is used with the Certificate provider. The ".parameterse
ts[0]" selects the first parameter set (set 0) of "get-childitem -argumentL
ist cert:" and ".parameters" selects the parameters in that parameter set.
The resulting parameters are piped to the Where-Object cmdlet to test each
parameter ("$_.") by using the IsDynamic property. To find the properties o
f the objects in a command, use Get-Member.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-command *

Description
-----------
This command gets information about the Windows PowerShell cmdlets, functio
ns, filters, scripts, and aliases in the current console.

It also gets information about all of the files in the paths of the Path en
vironment variable ($env:path). It returns an ApplicationInfo object (Syste
m.Management.Automation.ApplicationInfo) for each file, not a FileInfo obje
ct (System.IO.FileInfo).




-------------------------- EXAMPLE 8 --------------------------

C:\PS>get-command | where-object {$_.definition -like "*first*"}

CommandType Name Definition
----------- ---- ---------
Cmdlet Select-Object Select-Object [[-Property]

Description
-----------
This command finds a cmdlet or function based on the name of one of its par
ameters. You can use this command to identify a cmdlet or function when all
that you can recall is the name of one of its parameters.

In this case, you recall that one of the cmdlets or functions has a First p
arameter that gets the first "n" objects in a list, but you cannot remember
which cmdlet it is.

This command uses the Get-Command cmdlet to get a CmdletInfo object represe
nting each of the cmdlets and functions in the session. The CmdletInfo obje
ct has a Definition property that contains the syntax of the cmdlet or func
tion, which includes its parameters.

The command uses a pipeline operator (|) to pass the CmdletInfo object to t
he Where-Object cmdlet, which examines the definition (syntax) of each obje
ct ($_) for a value that includes "first".

The result shows that the First parameter belongs to the Select-Object cmdl
et.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>get-command dir | format-list

Name : dir
CommandType : Alias
Definition : Get-ChildItem
ReferencedCommand : Get-ChildItem
ResolvedCommand : Get-ChildItem

Description
-----------
This example shows how to use the Get-Command cmdlet with an alias. Althoug
h it is typically used on cmdlets, Get-Command also displays information ab
out the code in scripts, functions, aliases, and executable files.

This command displays the "dir" alias in the current console. The command p
ipes the result to the Format-List cmdlets.




-------------------------- EXAMPLE 10 --------------------------

C:\PS>get-command notepad

CommandType Name Definition
----------- ---- ----------
Application notepad.exe C:\WINDOWS\system32\notepad.exe
Application NOTEPAD.EXE C:\WINDOWS\NOTEPAD.EXE

Description
-----------
This example shows how to use Get-Command to determine which command Window
s PowerShell runs when it has access to multiple commands with the same nam
e. When you use the Name parameter without wildcard characters, Get-Command
lists the commands with that name in execution precedence order.

This command shows which Notepad program Windows PowerShell runs when you t
ype "Notepad" without a fully qualified path. The command uses the Name par
ameter without wildcard characters.

The sample output shows the Notepad commands in the current console. It ind
icates that Windows PowerShell will run the instance of Notepad.exe in the
C:\Windows\System32 directory.




-------------------------- EXAMPLE 11 --------------------------

C:\PS>(get-command get-date).pssnapin

C:\PS> (get-command remove-gpo).module

Description
-----------
These commands show how to find the snap-in or module from which a particul
ar cmdlet originated.

The first command uses the PSSnapin property of the CmdletInfo object to fi
nd the snap-in that added the Get-Date cmdlet.

The second command uses the Module property of the CmdletInfo object to fin
d the module that added the Remove-GPO cmdlet.




REMARKS
To see the examples, type: "get-help Get-Command -examples".
For more information, type: "get-help Get-Command -detailed".
For technical information, type: "get-help Get-Command -full".

NAME
Get-ComputerRestorePoint

SYNOPSIS
Gets the restore points on the local computer.


SYNTAX
Get-ComputerRestorePoint [[-RestorePoint] <Int32[]>] [<CommonParameters>]

Get-ComputerRestorePoint -LastStatus [<CommonParameters>]


DESCRIPTION
The Get-ComputerRestorePoint cmdlet gets the restore points on the local co
mputer. This cmdlet can also display the status of the most recent attempt
to restore the computer.

You can use the information returned by Get-ComputerRestorePoint to select
a restore point, and you can use the sequence number to identify a restore
point for the Restore-Computer cmdlet.

PARAMETERS
-LastStatus [<SwitchParameter>]
Gets the status of the most recent system restore operation.

-RestorePoint <Int32[]>
Gets the restore points with the specified sequence numbers. Enter the
sequence numbers of one or more restore points. By default, Get-Compute
rRestorePoint gets all restore points on the local computer.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-computerrestorepoint

Description
-----------
This command gets all of the restore points on the local computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-computerrestorepoint -restorepoint 232, 240, 245

Description
-----------
This command gets the restore points with sequence numbers 232, 240, and 24
5.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-computerrestorepoint -laststatus

The last restore failed.

Description
-----------
This command displays the status of the most recent system restore operatio
n on the local computer.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-computerrestorepoint | format-table SequenceNumber, @{Label="Date
"; Expression={$_.ConvertToDateTime($_.CreationTime)}}, Description -auto


SequenceNumber Date Description
-------------- ---- -----------
253 8/5/2008 3:19:20 PM Windows Update
254 8/6/2008 1:53:24 AM Windows Update
255 8/7/2008 12:00:04 AM Scheduled Checkpoint
...

Description
-----------
This command displays the restore points in a table for easy reading.

The Format-Table command includes a calculated property that uses the Conve
rtToDateTime method to convert the value of the CreationTime property from
WMI format to a DateTime object.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>((get-computerrestorepoint)[-1]).sequencenumber

Description
-----------
This command gets the sequence number of the most recently created restore
point on the computer.

The command uses the -1 index to get the last item in the array that Get-Co
mputerRestorePoint returns.




REMARKS
To see the examples, type: "get-help Get-ComputerRestorePoint -examples".
For more information, type: "get-help Get-ComputerRestorePoint -detailed".
For technical information, type: "get-help Get-ComputerRestorePoint -full".

NAME
Get-Content

SYNOPSIS
Gets the content of the item at the specified location.


SYNTAX
Get-Content [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Exclud
e <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-ReadCount
<Int64>] [-TotalCount <Int64>] [-UseTransaction] [<CommonParameters>]

Get-Content [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <stri
ng[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-ReadCount <Int64
>] [-TotalCount <Int64>] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Get-Content cmdlet gets the content of the item at the location specifi
ed by the path, such as the text in a file. It reads the content one line a
t a time and returns an object for each line.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers that are installed wit
h Windows PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Overrides restrictions that prevent the command from succeeding, just s
o the changes do not compromise security. For example, Force will overr
ide the read-only attribute or create directories to complete a file pa
th, but it will not attempt to change file permissions.

-Include <string[]>
Retrieves only the specified items. The value of this parameter qualifi
es the Path parameter. Enter a path element or pattern, such as "*.txt"
. Wildcards are permitted.

-LiteralPath <string[]>
Specifies the path to an item. Unlike Path, the value of LiteralPath is
used exactly as it is typed. No characters are interpreted as wildcard
s. If the path includes escape characters, enclose it in single quotati
on marks. Single quotation marks tell Windows PowerShell not to interpr
et any characters as escape sequences.

-Path <string[]>
Specifies the path to an item. Get-Content retrieves the content of the
item. Wildcards are permitted. The parameter name ("Path" or "FilePath
") is optional.

-ReadCount <Int64>
Specifies how many lines of content are sent through the pipeline at a
time. The default value is 1. A value of 0 (zero) sends all of the cont
ent at one time.

This parameter does not change the content displayed, but it does affec
t the time it takes to display the content. As the value of ReadCount i
ncreases, the time it takes to return the first line increases, but the
total time for the operation decreases. This can make a perceptible di
fference in very large items.

-TotalCount <Int64>
Specifies how many lines of content are retrieved. The default is -1 (a
ll lines).

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-content -Path C:\Chapters\chapter1.txt

Description
-----------
This command displays the content of the Chapter1.txt file on the console.
It uses the Path parameter to specify the name of the item. Get-Content act
ually passes the content down the pipeline, but because there are no other
pipeline elements, the content is formatted and displayed on the console.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-content c:\Logs\Log060912.txt -totalcount 50 | set-content sample
.txt

Description
-----------
This command gets the first 50 lines of the Log060912.txt file and stores t
hem in the sample.txt file. The command uses the Get-Content cmdlet to get
the text in the file. (The name of Path parameter, which is optional, is om
itted.) The TotalCount parameter limits the retrieval to the first 50 lines
. The pipeline operator (|) sends the result to Set-Content, which places i
t in the sample.txt file.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>(get-content cmdlets.txt -totalcount 5)[-1]

Description
-----------
This command gets the fifth line of the Cmdlets.txt text file. It uses the
TotalCount parameter to get the first five lines and then uses array notati
on to get the last line (indicated by "-1") of the resulting set.




REMARKS
To see the examples, type: "get-help Get-Content -examples".
For more information, type: "get-help Get-Content -detailed".
For technical information, type: "get-help Get-Content -full".

NAME
Get-Counter

SYNOPSIS
Gets performance counter data from local and remote computers.


SYNTAX
Get-Counter [-Counter] <string[]> [-ComputerName <string[]>] [-Continuous]
[-MaxSamples <Int64>] [-SampleInterval <int>] [<CommonParameters>]

Get-Counter -ListSet <string[]> [-ComputerName <string[]>] [<CommonParamete
rs>]


DESCRIPTION
The Get-Counter cmdlet gets live, real-time performance counter data direct
ly from the performance monitoring instrumentation in Windows. You can use
it to get performance data from the local or remote computers at the sampl
e interval that you specify.

Without parameters, a "Get-Counter" command gets counter data for a set of
system counters.

You can use the parameters of Get-Counter to specify one or more computers,
to list the performance counter sets and the counters that they contain, a
nd to set the sample size and interval.

PARAMETERS
-ComputerName <string[]>
Gets data from the specified computers. Type the NetBIOS name, an Inter
net Protocol (IP) address, or the fully qualified domain names of the c
omputers. The default value is the local computer.

Note: Get-Counter does not rely on Windows PowerShell remoting. You ca
n use the ComputerName parameter of Get-Counter even if your computer i
s not configured for remoting in Windows PowerShell.

-Continuous [<SwitchParameter>]
Gets samples continuously until you press CTRL+C. By default, Get-Count
er gets only one counter sample. You can use the SampleInterval paramet
er to set the interval for continuous sampling.

-Counter <string[]>
Gets data from the specified performance counters. Enter one or more co
unter paths. Wildcards are permitted only in the Instance value. You ca
n also pipe counter path strings to Get-Counter.

Each counter path has the following format:
"[\\<ComputerName>]\<CounterSet>(<Instance>)\<CounterName>"

For example:
"\\Server01\Processor(2)\% User Time".

The <ComputerName> element is optional. If you omit it, Get-Counter use
s the value of the ComputerName parameter.

Note: To get correctly formatted counter paths, use the ListSet parame
ter to get a performance counter set. The Paths and PathsWithInstances
properties of each performance counter set contain the individual count
er paths formatted as a string. You can save the counter path strings i
n a variable or pipe the string directly to another Get-Counter command
. For a demonstration, see the examples.

-ListSet <string[]>
Gets the specified performance counter sets on the computers. Enter the
names of the counter sets. Wildcards are permitted. You can also pipe
counter set names to Get-Counter.

-MaxSamples <Int64>
Specifies the number of samples to get from each counter. The default i
s 1 sample. To get samples continuously (no maximum sample size), use t
he Continuous parameter.

To collect a very large data set, consider running a Get-Counter comman
d as a Windows PowerShell background job. For more information, see abo
ut_Jobs and Start-Job.

-SampleInterval <int>
Specifies the time between samples in seconds. The minimum value and th
e default value are 1 second.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS># Get-Counter

Description
-----------
This command gets all of the counter sets on the local computer.

C:\PS> get-counter -ListSet *

Because many of the counter sets are protected by access control lists (ACL
s), to see all counter sets, open Windows PowerShell with the "Run as admin
istrator" option before using the Get-Counter command.




-------------------------- EXAMPLE 2 --------------------------

C:\PS># Get-Counter

Description
-----------
This command gets the current "% Processor Time" combined values for all pr
ocessors on the local computer. It collects data every two seconds until it
has three values.

C:\PS> get-counter -Counter "\Processor(_Total)\% Processor Time" -SampleIn
terval 2 -MaxSamples 3




-------------------------- EXAMPLE 3 --------------------------

C:\PS># Get-Counter

Description
-----------
This command gets an alphabetically sorted list of the names of all of the
counter sets on the local computer.

C:\PS> get-counter -listset * | sort-object countersetname | format-table
countersetname




-------------------------- EXAMPLE 4 --------------------------

C:\PS># Get-Counter

Description
-----------
These commands use the Path property of a counter set to find the correctly
formatted path names for the performance counters. You can use a command l
ike this one to get the correct counter path names.

The first command gets the path names of the performance counters in the Me
mory counter set on the local computer.

C:\PS> (get-counter -listset memory).paths

\Memory\Page Faults/sec
\Memory\Available Bytes
\Memory\Committed Bytes
\Memory\Commit Limit
\Memory\Write Copies/sec
\Memory\Transition Faults/sec
\Memory\Cache Faults/sec
\Memory\Demand Zero Faults/sec
\Memory\Pages/sec
\Memory\Pages Input/sec
...

The second command gets the path names that include "cache".

C:\PS> (get-counter -listset memory).paths | where {$_ -like "*cache*"}

\Memory\Cache Faults/sec
\Memory\Cache Bytes
\Memory\Cache Bytes Peak
\Memory\System Cache Resident Bytes
\Memory\Standby Cache Reserve Bytes
\Memory\Standby Cache Normal Priority Bytes
\Memory\Standby Cache Core Bytes




-------------------------- EXAMPLE 5 --------------------------

C:\PS># Get-Counter

Description
-----------
These commands get the Disk Reads/sec counter data from the Server01 and Se
rver02 computers.

The first command saves the Disk Reads/sec counter path in the $diskreads v
ariable.

C:\PS> $diskreads = "\LogicalDisk(C:)\Disk Reads/sec"

The second command uses a pipeline operator (|) to send the counter path in
the $diskreads variable to the Get-Counter cmdlet. The command uses the Ma
xSamples parameter to limit the output to 10 samples.

C:\PS> $diskreads | get-counter -computer Server01, Server02 -maxsamples 10




-------------------------- EXAMPLE 6 --------------------------

C:\PS># Get-Counter

Description
-----------
This command gets the correctly formatted path names for the PhysicalDisk
performance counters, including the instance names.

C:\PS> (get-counter -list physicaldisk).pathswithinstances




-------------------------- EXAMPLE 7 --------------------------

C:\PS># Get-Counter

Description
-----------
These commands get the value of the "% DPC Time" performance counter on 50
randomly select computers in the enterprise.

The first command uses the Get-Content cmdlet to get the list of enterprise
servers from the Servers.txt file. It uses the Get-Random cmdlet to select
50 server names randomly from the Servers.txt file contents. The results a
re saved in the $servers variable.

C:\PS> $servers = get-random (get-content servers.txt) -count 50

The second command saves the counter path to the "% DPC Time" cmdlet in the
$Counter variable. The counter path includes a wildcard character in the i
nstance name to get the data on all of the processors on each of the comput
ers.

C:\PS> $counter = "\Processor(*)\% DPC Time"

The third command uses the Get-Counter cmdlet to get the counter values. It
uses the Counter parameter to specify the counters and the ComputerName pa
rameter to specify the computers saved in the $servers variable.

C:\PS> get-counter -Counter $counter -computername $servers




-------------------------- EXAMPLE 8 --------------------------

C:\PS># Get-Counter

Description
-----------
These commands get a single value for all of the performance counters in th
e memory counter set on the local computer.

The first command gets the counter paths and saves them in the $memCounters
variable.

C:\PS> $memCounters = (get-counter -list memory).paths

The second command uses the Get-Counter cmdlet to get the counter data for
each counter. It uses the Counter parameter to specify the counters in $mem
Counters.

C:\PS> get-counter -counter $memCounters




-------------------------- EXAMPLE 9 --------------------------

C:\PS># Get-Counter

Description
-----------
This example shows the property values in the PerformanceCounterSample obje
ct that represents each data sample.

The first command saves a counter path in the $counter variable.

C:\PS> $counter = "\\SERVER01\Process(Idle)\% Processor Time"

The second command uses the Get-Counter cmdlet to get one sample of the cou
nter values. It saves the results in the $data variable.

C:\PS> $data = get-counter $counter

The third command uses the Format-List cmdlet to display all the properties
of the CounterSamples property of the sample set object as a list.

C:\PS> $data.countersamples | format-list -property *

Path : \\SERVER01\process(idle)\% processor time
InstanceName : idle
CookedValue : 198.467899571389
RawValue : 14329160321003
SecondValue : 128606459528326201
MultipleCount : 1
CounterType : Timer100Ns
Timestamp : 7/15/2008 6:39:12 PM
Timestamp100NSec : 128606207528320000
Status : 0
DefaultScale : 0
TimeBase : 10000000

You can use the properties of the CounterSamples object to examine, select,
sort, and group the data.




-------------------------- EXAMPLE 10 --------------------------

C:\PS># Get-Counter

Description
-----------
The command runs a Get-Counter command as background job. For more informat
ion, see Start-Job.

C:\PS> $counters = "\LogicalDisk(_Total)\% Free Space"

C:\PS> start-job -scriptblock {get-counter -counter $counters -maxsamples 1
000)




-------------------------- EXAMPLE 11 --------------------------

C:\PS># Get-Counter

Description
-----------
This command uses the Get-Counter and Get-Random cmdlets to find the percen
tage of free disk space on 50 computers selected randomly from the Servers.
txt file.

C:\PS> get-counter -computername (get-random servers.txt -count 50) -counte
r "\LogicalDisk(*)\% Free Space"




-------------------------- EXAMPLE 12 --------------------------

C:\PS># Get-Counter

Description
-----------
This example shows how to associate counter data with the computer on which
it originated, and how to manipulate the data.


The first command uses the Get-Counter cmdlet to get the "LogicalDisk\% Fre
e Space" counter value from two remote computers, S1 and S2. It saves the r
esult in the $a variable.

$a = get-counter "\LogicalDisk(_Total)\% Free Space" -comp s1, s2



The second command displays the results in the $a variable. All of the data
is stored in the object, but it is not easy to see it in this form.

C:\PS> $a

Counter Paths: \\s1\\logicaldisk(c:)\% free space, \\s1\\logicaldisk(d:)\%
free space, \\s1\\logicaldisk(_total)\% free space, \\s2\\logicaldisk(c:)\%
free space, \\s2\\logicaldisk(_total)\% free space

Timestamp : 7/15/2008 5:09:08 PM
Cooked Values : "0.327058823529412", "17.8952248493278", "12.9994033060778"
, "75.0754805595626", "75.0754805595626"



The third command displays in a table the value of the CounterSamples prope
rty of the PerformanceCounterSampleSet object that Get-Counter returns. (To
see all of the properties and methods of the object, pipe it to the Get-Me
mber cmdlet.)

C:\PS> $a.countersamples | format-table -auto

Path InstanceName CookedValue
---- ------------ -----------
\\s1\\logicaldisk(c:)\% free space c: 0.327058823529412
\\s1\\logicaldisk(d:)\% free space d: 17.8952248493278
\\s1\\logicaldisk(_total)\% free space _total 12.9994033060778
\\s2\\logicaldisk(c:)\% free space c: 75.0754805595626
\\s2\\logicaldisk(_total)\% free space _total 75.0754805595626

The CounterSamples property contains a PerformanceCounterSample object with
its own properties and methods. The fourth command uses array notation to
get the first counter sample and a pipeline operator to send the counter sa
mple object to the Format-List cmdlet, which displays all of its properties
and methods in a list. This display shows the richness of the data in each
counter sample object.



The fourth command shows how to select data from the counter samples. It us
es the Where-Object cmdlet to get only the counter samples with a CookedVal
ue of less than 15.

C:\PS> $a.countersamples | where {$_.cookedvalue -lt 15}

Path InstanceName CookedValue
---- ------------ -----------
\\s1\\logicaldisk(c:)\% free space c: 0.327058823529412
\\s1\\logicaldisk(_total)\% free space _total 12.9994033060778




-------------------------- EXAMPLE 13 --------------------------

C:\PS># Get-Counter

Description
-----------
This example shows how to sort the performance counter data that you retrie
ve. The example finds the processes on the computer that are using the most
processor time during the sampling.

The first command gets the "Process\% Processor Time" counter for all the p
rocesses on the computer. The command saves the results in the $p variable.

C:\PS> $p = get-counter '\Process(*)\% Processor Time'


The second command gets the CounterSamples property of the sample set objec
t in $p and it sorts the samples in descending order based on the cooked va
lue of the sample. The command uses the Format-Table cmdlet and its AutoFor
mat parameter to position the columns in the table.

C:\PS> $p.CounterSamples | sort-object -property CookedValue -Descending |
format-table -auto

Path InstanceName CookedV
alue
---- ------------ -------
----
\\server01\process(_total)\% processor time _total 200.006410
42078
\\server01\process(idle)\% processor time idle 200.006410
42078
\\server01\process(explorer#1)\% processor time explorer
0
\\server01\process(dwm#1)\% processor time dwm
0
\\server01\process(taskeng#1)\% processor time taskeng
0
\\server01\process(taskhost#1)\% processor time taskhost
0
\\server01\process(winlogon)\% processor time winlogon
0
\\server01\process(csrss)\% processor time csrss
0




-------------------------- EXAMPLE 14 --------------------------

C:\PS># Get-Counter

Description
-----------
These commands find the processes on the computer with the largest working
sets. They list the processes in descending order based on their working se
t size.

The first command gets one sample of the "Process\Working Set - Private" co
unter for each process. The command saves the counter data in the $ws varia
ble.

C:\PS> $ws = get-counter "\Process(*)\Working Set - Private"

The second command uses a pipeline operator (|) to send the data in the Cou
nterSamples property of the $ws variable to the Sort-Object cmdlet, where t
he process data is sorted in descending order by the value of the CookedVal
ue property. Another pipeline sends the sorted data to the Format-Table cmd
let, where the data is formatted as a table with InstanceName and CookedVal
ue columns.

C:\PS> $ws.countersamples | sort-object -property cookedvalue -descending |
format-table -property InstanceName, CookedValue -auto

InstanceName CookedValue
------------ -----------
_total 162983936
svchost 40370176
powershell 15110144
explorer 14135296
svchost 10928128
svchost 9027584
...




-------------------------- EXAMPLE 15 --------------------------

C:\PS># Get-Counter

Description
-----------
This command gets a series of samples of the Processor\% Processor Time cou
nter at the default one second interval. To stop the command, press CTRL +
C.

C:\PS> get-counter -counter "\processor(_total)\% processor time" -continuo
us




REMARKS
To see the examples, type: "get-help Get-Counter -examples".
For more information, type: "get-help Get-Counter -detailed".
For technical information, type: "get-help Get-Counter -full".

NAME
Get-Credential

SYNOPSIS
Gets a credential object based on a user name and password.


SYNTAX
Get-Credential [-Credential] <PSCredential> [<CommonParameters>]


DESCRIPTION
The Get-Credential cmdlet creates a credential object for a specified user
name and password. You can use the credential object in security operations
.

The cmdlet prompts the user for a password or user name and password. Users
are prompted through a dialog box or at the command line, depending on the
system registry setting.

PARAMETERS
-Credential <PSCredential>
Specifies a user name for the credential, such as "User01" or "Domain01
\User01". The parameter name ("Credential") is optional.

When you submit the command, you will be prompted for a password.

If you enter a user name without a domain, Get-Credential inserts a bac
kslash before the name.

If you omit this parameter, you will be prompted for a user name and a
password.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$c = Get-Credential

Description
-----------
This command gets a credential object and saves it in the $c variable.

When you enter the command, a dialog box appears requesting a user name and
password. When you enter the requested information, the cmdlet creates a P
SCredential object representing the credentials of the user and saves it in
the $c variable.

You can use the object as input to cmdlets that request user authentication
, such as those with a Credential parameter. However, the providers that ar
e installed with Windows PowerShell do not support the Credential parameter
.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$c = Get-Credential

C:\PS>Get-WmiObject Win32_DiskDrive -ComputerName Server01 -Credential $c

Description
-----------
These commands use a credential object from Get-Credential to authenticate
a user on a remote computer so they can use Windows Management Instrumentat
ion (WMI) to manage the computer.

The first command gets a credential object and saves it in the $c variable.
The second command uses the credential object in a Get-WmiObject command.
This command gets information about the disk drives on the Server01 compute
r.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>C:\PS>Get-WmiObject Win32_BIOS -ComputerName Server01 '
-Credential (get-credential Domain01\User01)

Description
-----------
This command shows how to include a Get-Credential command in a Get-WmiObje
ct command.

This command uses the Get-WmiObject cmdlet to get information about the BIO
S on the Server01 computer. It uses the Credential parameter to authenticat
e the user, Domain01\User01, and a Get-Credential command as the value of t
he Credential parameter.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$c = Get-Credential -credential User01

C:\PS>$c.Username

\User01

Description
-----------
This example creates a credential that includes a user name without a domai
n name. It demonstrates that Get-Credential inserts a backslash before the
user name.

The first command gets a credential with the user name User01 and stores it
in the $c variable.

The second command displays the value of the Username property of the resul
ting credential object.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>$credential = $host.ui.PromptForCredential("Need credentials", "Pleas
e enter your user name and password.", "", "NetBiosUserName")

Description
-----------
This command uses the PromptForCredential method to prompt the user for the
ir user name and password. The command saves the resulting credentials in t
he $credential variable.

PromptForCredential is an alternative to using Get-Credential. When you use
PromptForCredential, you can specify the caption, messages, and user name
that appear in the message box.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>Set-ItemProperty 'HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds' Con
solePrompting $true

Description
-----------
When requiring a user name and password, as a default, a dialog box appears
to prompt the user. To be prompted at the command line, modify the registr
y by running this command in Windows PowerShell Run as administrator.

Use the same command with "ConsolePrompting $false" to be prompted with a d
ialog box.




REMARKS
To see the examples, type: "get-help Get-Credential -examples".
For more information, type: "get-help Get-Credential -detailed".
For technical information, type: "get-help Get-Credential -full".

NAME
Get-Culture

SYNOPSIS
Gets the current culture set in the operating system.


SYNTAX
Get-Culture [<CommonParameters>]


DESCRIPTION
The Get-Culture cmdlet gets information about the current culture settings.
This includes information about the current language settings on the syste
m, such as the keyboard layout, and the display format of items such as num
bers, currency, and dates.

You can also use the Get-UICulture cmdlet, which gets the current user inte
rface culture on the system. The user-interface (UI) culture determines whi
ch text strings are used for user interface elements, such as menus and mes
sages.

PARAMETERS
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-culture

Description
-----------
This command displays information about the regional settings on the comput
er.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$c = get-culture

C:\PS> $c | format-list -property *

Parent : en
LCID : 1033
KeyboardLayoutId : 1033
Name : en-US
IetfLanguageTag : en-US
DisplayName : English (United States)
NativeName : English (United States)
EnglishName : English (United States)
TwoLetterISOLanguageName : en
ThreeLetterISOLanguageName : eng
ThreeLetterWindowsLanguageName : ENU
CompareInfo : CompareInfo - 1033
TextInfo : TextInfo - 1033
IsNeutralCulture : False
CultureTypes : SpecificCultures, InstalledWin32Cultures,
FrameworkCultures
NumberFormat : System.Globalization.NumberFormatInfo
DateTimeFormat : System.Globalization.DateTimeFormatInfo
Calendar : System.Globalization.GregorianCalendar
OptionalCalendars : {System.Globalization.GregorianCalendar, S
ystem.Globalization.GregorianCalendar}
UseUserOverride : True
IsReadOnly : False


C:\PS> $c.calendar

MinSupportedDateTime : 1/1/0001 12:00:00 AM
MaxSupportedDateTime : 12/31/9999 11:59:59 PM
AlgorithmType : SolarCalendar
CalendarType : Localized
Eras : {1}
TwoDigitYearMax : 2029
IsReadOnly : False


C:\PS> $c.datetimeformat

AMDesignator : AM
Calendar : System.Globalization.GregorianCalendar
DateSeparator : /
FirstDayOfWeek : Sunday
CalendarWeekRule : FirstDay
FullDateTimePattern : dddd, MMMM dd, yyyy h:mm:ss tt
LongDatePattern : dddd, MMMM dd, yyyy
LongTimePattern : h:mm:ss tt
MonthDayPattern : MMMM dd
PMDesignator : PM
RFC1123Pattern : ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
ShortDatePattern : M/d/yyyy
ShortTimePattern : h:mm tt
SortableDateTimePattern : yyyy'-'MM'-'dd'T'HH':'mm':'ss
TimeSeparator : :
UniversalSortableDateTimePattern : yyyy'-'MM'-'dd HH':'mm':'ss'Z'
YearMonthPattern : MMMM, yyyy
AbbreviatedDayNames : {Sun, Mon, Tue, Wed...}
ShortestDayNames : {Su, Mo, Tu, We...}
DayNames : {Sunday, Monday, Tuesday, Wednesday...}
AbbreviatedMonthNames : {Jan, Feb, Mar, Apr...}
MonthNames : {January, February, March, April...}
IsReadOnly : False
NativeCalendarName : Gregorian Calendar
AbbreviatedMonthGenitiveNames : {Jan, Feb, Mar, Apr...}
MonthGenitiveNames : {January, February, March, April...}



C:\PS> $c.datetimeformat.firstdayofweek
Sunday

Description
-----------
This example demonstrates the vast amount of data in the culture object. It
shows how to display the properties and sub-properties of the object.

The first command uses the Get-Culture cmdlet to get the current culture se
ttings on the computer. It stores the resulting culture object in the $c va
riable.

The second command displays all of the properties of the culture object. It
uses a pipeline operator (|) to send the culture object in $c to the Forma
t-List cmdlet. It uses the Property parameter to display all (*) properties
of the object. (This command can be abbreviated as "$c | fl *".)

The remaining commands explore the properties of the culture object by usin
g dot notation to display the values of the object properties. You can use
this notation to display the value of any property of the object.

The third command uses dot notation to display the value of the Calendar pr
operty of the culture object.

The fourth command uses dot notation to display the value of the DataTimeFo
rmat property of the culture object.

Many object properties have properties. The fifth command uses dot notation
to display the value of the FirstDayOfWeek property of the DateTimeFormat
property.




REMARKS
To see the examples, type: "get-help Get-Culture -examples".
For more information, type: "get-help Get-Culture -detailed".
For technical information, type: "get-help Get-Culture -full".

NAME
Get-Date

SYNOPSIS
Gets the current date and time.


SYNTAX
Get-Date [-Format <string>] [[-Date] <DateTime>] [-Day <int>] [-DisplayHint
{Date | Time | DateTime}] [-Hour <int>] [-Minute <int>] [-Month <int>] [-S
econd <int>] [-Year <int>] [<CommonParameters>]

Get-Date [-UFormat <string>] [[-Date] <DateTime>] [-Day <int>] [-DisplayHin
t {Date | Time | DateTime}] [-Hour <int>] [-Minute <int>] [-Month <int>] [-
Second <int>] [-Year <int>] [<CommonParameters>]


DESCRIPTION
The Get-Date cmdlet gets a DateTime object that represents the current date
or a date that you specify. It can format the date and time in several Win
dows and UNIX formats. You can use Get-Date to generate a date or time char
acter string, and then send the string to other cmdlets or programs.

PARAMETERS
-Date <DateTime>
Specifies a date and time. By default, Get-Date gets the current system
date and time.

Type the date in a format that is standard for the system locale, such
as dd-MM-yyyy (German [Germany]) or MM/dd/yyyy (English [United States]
).

-Day <int>
Specifies the day of the month that is displayed. Enter a value from 1
to 31. This value is displayed instead of the current day.

If you specify a value that is greater than the number of days in the m
onth, Windows PowerShell adds the number of days to the month and displ
ays the result. For example, "get-date -month 2 -day 31" displays "Marc
h 3", not "February 31".

-DisplayHint <DisplayHintType>
Determines which elements of the date and time are displayed.
Valid values are:

-- Date: displays only the date
-- Time: displays only the time
-- DateTime: displays the date and time

DateTime is the default.

This parameter does not affect the DateTime object that Get-Date retrie
ves.

-Format <string>
Displays the date and time in the Microsoft .NET Framework format indic
ated by the format specifier. Enter a format specifier. For a list of a
vailable format specifiers, see "DateTimeFormatInfo Class" in the MSDN
(Microsoft Developer Network) library at http://go.microsoft.com/fwlink
/?LinkId=143638.

When you use the Format parameter, Windows PowerShell retrieves only th
e properties of the DateTime object that it needs to display the date i
n the format that you specify. As a result, some of the properties and
methods of DateTime objects might not be available.

-Hour <int>
Specifies the hour that is displayed. Enter a value from 1 to 23. This
value is displayed instead of the current hour.

-Minute <int>
Specifies the minute that is displayed. Enter a value from 1 to 59. Thi
s value is displayed instead of the current minute.

-Month <int>
Specifies the month that is displayed. Enter a value from 1 to 12. This
value is displayed instead of the current month.

-Second <int>
Specifies the second that is displayed. Enter a value from 1 to 59. Thi
s value is displayed instead of the current second.

-UFormat <string>
Displays the date and time in UNIX format. For a list of the format spe
cifiers, see the Notes section.

When you use the UFormat parameter, Windows PowerShell retrieves only t
he properties of the DateTime object that it needs to display the date
in the format that you specify. As a result, some of the properties and
methods of DateTime objects might not be available.

-Year <int>
Specifies the year that is displayed. Enter a value from 1 to 9999. Thi
s value is displayed instead of the current year.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-date -DisplayHint date

Tuesday, June 13, 2006

Description
-----------
This command retrieves a DateTime object, but it displays only the date. It
uses the DisplayHint parameter to indicate that only the date is to be dis
played.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-date -format g

6/13/2006 12:43 PM

Description
-----------
This command retrieves the current date and time and formats it in short-da
te and short-time format. It uses the .NET Framework "g" format specifier (
General [short date and short time]) to specify the format.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-date -uformat "%Y / %m / %d / %A / %Z"

2006 / 06 / 13 / Tuesday / -07

Description
-----------
This command retrieves the current date and time and formats it as specifie
d by the command. In this case, the format includes the full year (%Y), the
two-digit numeric month (%m), the date (%d), the full day of the week (%A)
, and the offset from UTC ("Zulu").




-------------------------- EXAMPLE 4 --------------------------

C:\PS>(get-date -year 2000 -month 12 -day 31).dayofyear

366

Description
-----------
This command displays the day of the year for the current date. For example
, December 31 is the 365th day of 2006, but it is the 366th day of 2000.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>$a = get-date

C:\PS> $a.IsDaylightSavingTime()

True

Description
-----------
These commands tell you whether the current date and time are adjusted for
daylight savings time in the current locale.

The first command creates a variable named $a and then assigns the object r
etrieved by Get-Date to the $a variable. Then, it uses the IsDaylightSaving
Time method on the object in $a.

To see the properties and methods of the DateTime object, type:
"get-date | get-member".




-------------------------- EXAMPLE 6 --------------------------

C:\PS>$a = get-date

C:\PS> $a.ToUniversalTime()

Tuesday, June 13, 2006 8:09:19 PM

Description
-----------
These commands convert the current date and time to UTC time.

The first command creates a variable named $a and then assigns the object r
etrieved by Get-Date to the $a variable. Then, it uses the ToUniversalTime
method on the object in $a.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>$a = get-wmiobject win32_bios -computer server01

$a | format-list -property Name, @{Label="BIOS Age"; `
Expression={(get-date) - $_.ConvertToDateTime($_.ReleaseDate)}}

Name : Default System BIOS
BIOS Age : 1345.17:31:07.1091047

Description
-----------
Windows Management Instrumentation (WMI) uses a different date-time object
than the .NET Framework date-time object that Get-Date returns. To use date
-time information from WMI in a command with date-time information from Get
-Date, you have to use the ConvertToDateTime method to convert WMI CIM_DATE
TIME objects to .NET Framework DateTime objects.

The commands in this example display the name and age of the BIOS on a remo
te computer, Server01.

The first command uses the Get-WmiObject cmdlet to get an instance of the W
in32_BIOS class on Server01 and then stores it in the $a variable.

The second command uses the pipeline operator (|) to send the WMI object st
ored in $a to the Format-List cmdlet. The Property parameter of Format-List
is used to specify two properties to display in the list, "Name" and "BIOS
Age". The "BIOS Age" property is specified in a hash table. The table incl
udes the Label key, which specifies the name of the property, and the Expre
ssion key, which contains the expression that calculates the BIOS age. The
expression uses the ConvertToDateTime method to convert each instance of Re
leaseDate to a .NET Framework DateTime object. Then, the value is subtracte
d from the value of the Get-Date cmdlet, which, without parameters, gets th
e current date.

The backtick character (`) is the line continuation character in Windows Po
werShell.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>get-date

Tuesday, June 13, 2006 12:43:42 PM

Description
-----------
This command gets a DateTime object and displays the current date and time
in the long date and long time formats for the system locale, as though you
typed "get-date -format F".




-------------------------- EXAMPLE 9 --------------------------

C:\PS>get-date

C:\PS> Tuesday, September 26, 2006 11:25:31 AM

c:\PS>(get-date).ToString()
9/26/2006 11:25:31 AM

C:\PS>get-date | add-content test.txt
# Adds 9/26/2006 11:25:31 AM

C:\PS>get-date -format F | add-content test.txt
# Adds Tuesday, September 26, 2006 11:25:31 AM

Description
-----------
These commands demonstrate how to use Get-Date with Add-Content and other c
mdlets that convert the DateTime object that Get-Date generates to a string
.

The first command shows that the default display from a "get-date" command
is in long-date and long-time format.

The second command shows that the default display from the ToString() metho
d of the DateTime object is in short-date and short-time format.

The third command uses a pipeline operator to send the DateTime object to t
he Add-Content cmdlet, which adds the content to the Test.txt file. Because
Add-Content uses the ToString() method of the DateTime object, the date th
at is added is in short-date and short-time format.

The fourth command uses the Format parameter of Get-Date to specify the for
mat. When you use the Format or UFormat parameters, Get-Date generates a st
ring, not a DateTime object. Then, when you send the string to Add-Content,
it adds the string to the Test.txt file without changing it.




REMARKS
To see the examples, type: "get-help Get-Date -examples".
For more information, type: "get-help Get-Date -detailed".
For technical information, type: "get-help Get-Date -full".

NAME
Get-Event

SYNOPSIS
Gets the events in the event queue.


SYNTAX
Get-Event [-EventIdentifier] <int> [<CommonParameters>]

Get-Event [[-SourceIdentifier] <string>] [<CommonParameters>]


DESCRIPTION
The Get-Event cmdlet gets events in the Windows PowerShell event queue for
the current session. You can get all events or use the EventIdentifier or S
ourceIdentifier parameters to specify the events.

When an event occurs, it is added to the event queue. The event queue inclu
des events for which you have registered, events created by using the New-E
vent cmdlet, and the event that is raised when Windows PowerShell exits. Yo
u can use Get-Event or Wait-Event to get the events.

This cmdlet does not get events from the Event Viewer logs. To get those ev
ents, use Get-WinEvent or Get-EventLog.

PARAMETERS
-EventIdentifier <int>
Gets only the events with the specified event identifier.

-SourceIdentifier <string>
Gets only events with the specified source identifier. The default is a
ll events in the event queue. Wildcards are not permitted.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-event

Description
-----------
This command gets all events in the event queue.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-event -sourceIdentifier "PowerShell.ProcessCreated"

Description
-----------
This command gets events in which the value of the SourceIdentifier propert
y is "PowerShell.ProcessCreated".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$events = get-event

C:\PS> $events[0] | format-list -property *

ComputerName :
RunspaceId : c2153740-256d-46c0-a57c-b805917d1b7b
EventIdentifier : 1
Sender : System.Management.ManagementEventWatcher
SourceEventArgs : System.Management.EventArrivedEventArgs
SourceArgs : {System.Management.ManagementEventWatcher, System.Manage
ment.EventArrivedEventArgs}
SourceIdentifier : ProcessStarted
TimeGenerated : 11/13/2008 12:09:32 PM
MessageData :


C:\PS> get-event | where {$_.TimeGenerated -ge "11/13/2008 12:15:00 PM"}

ComputerName :
RunspaceId : c2153740-256d-46c0-a57c-b8059325d1a0
EventIdentifier : 1
Sender : System.Management.ManagementEventWatcher
SourceEventArgs : System.Management.EventArrivedEventArgs
SourceArgs : {System.Management.ManagementEventWatcher, System.Manage
ment.EventArrivedEventArgs}
SourceIdentifier : ProcessStarted
TimeGenerated : 11/13/2008 12:15:00 PM
MessageData :

Description
-----------
This example shows how to get events by using properties other than SourceI
dentifier.

The first command gets all events in the event queue and saves them in the
$events variable.

The second command uses array notation to get the first (0-index) event in
the array in the $events variable. The command uses a pipeline operator (|)
to send the event to the Format-List command, which displays all propertie
s of the event in a list. This allows you to examine the properties of the
event object.

The third command shows how to use the Where-Object cmdlet to get an event
based on the time that it was generated.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-event -eventIdentifier 2

Description
-----------
This command gets the event with an event identifier of 2.




REMARKS
To see the examples, type: "get-help Get-Event -examples".
For more information, type: "get-help Get-Event -detailed".
For technical information, type: "get-help Get-Event -full".

NAME
Get-EventLog

SYNOPSIS
Gets the events in an event log, or a list of the event logs, on the local
or remote computers.


SYNTAX
Get-EventLog [-AsString] [-ComputerName <string[]>] [-List] [<CommonParamet
ers>]

Get-EventLog [-LogName] <string> [[-InstanceId] <Int64[]>] [-After <DateTim
e>] [-AsBaseObject] [-Before <DateTime>] [-ComputerName <string[]>] [-Entry
Type <string[]>] [-Index <Int32[]>] [-Message <string>] [-Newest <int>] [-S
ource <string[]>] [-UserName <string[]>] [<CommonParameters>]


DESCRIPTION
The Get-EventLog cmdlet gets events and event logs on the local and remote
computers.

Use the parameters of Get-EventLog to search for events by using their prop
erty values. Get-EventLog gets only the events that match all of the specif
ied property values.

The cmdlets that contain the EventLog noun (the EventLog cmdlets) work only
on classic event logs. To get events from logs that use the Windows Event
Log technology in Windows Vista and later versions of Windows, use Get-WinE
vent.

PARAMETERS
-After <DateTime>
Gets only the events that occur after the specified date and time. Ente
r a DateTime object, such as the one returned by the Get-Date cmdlet.

-AsBaseObject [<SwitchParameter>]
Returns a standard System.Diagnostics.EventLogEntry object for each eve
nt. Without this parameter, Get-EventLog returns an extended PSObject o
bject with additional EventLogName, Source, and InstanceId properties.

To see the effect of this parameter, pipe the events to the Get-Member
cmdlet and examine the TypeName value in the result.

-AsString [<SwitchParameter>]
Returns the output as strings, instead of objects.

-Before <DateTime>
Gets only the events that occur before the specified date and time. Ent
er a DateTime object, such as the one returned by the Get-Date cmdlet.

-ComputerName <string[]>
Specifies a remote computer. The default is the local computer.

Type the NetBIOS name, an Internet Protocol (IP) address, or a fully qu
alified domain name of a remote computer. To specify the local computer
, type the computer name, a dot (.), or "localhost".

This parameter does not rely on Windows PowerShell remoting. You can us
e the ComputerName parameter of Get-EventLog even if your computer is n
ot configured to run remote commands.

-EntryType <string[]>
Gets only events with the specified entry type. Valid values are Error,
Information, FailureAudit, SuccessAudit, and Warning. The default is a
ll events.

-Index <Int32[]>
Gets only events with the specified index values.

-InstanceId <Int64[]>
Gets only events with the specified instance IDs.

-List [<SwitchParameter>]
Gets a list of event logs on the computer.

-LogName <string>
Specifies the event log. Enter the log name (the value of the Log prop
erty; not the LogDisplayName) of one event log. Wildcard characters are
not permitted. This parameter is required.

-Message <string>
Gets events that have the specified string in their messages. You can u
se this property to search for messages that contain certain words or p
hrases. Wildcards are permitted.

-Newest <int>
Specifies the maximum number of events retrieved. Get-EventLog gets the
specified number of events, beginning with the newest event in the log
.

-Source <string[]>
Gets events that were written to the log by the specified sources. Wild
cards are permitted.

-UserName <string[]>
Gets only the events that are associated with the specified user names.
Enter names or name patterns, such as User01, User*, or Domain01\User*
. Wildcards are permitted.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-eventlog -list

Description
-----------
This command displays information about the event logs on the computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-eventlog -newest 5 -logname application

Description
-----------
This command displays the five most recent entries in the Application event
log.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$events = get-eventlog -logname system -newest 1000

C:\PS> $events | group-object -property source -noelement | sort-object -pr
operty count -descending

Count Name
----- ----
75 Service Control Manager
12 Print
6 UmrdpService
2 DnsApi
2 DCOM
1 Dhcp
1 TermDD
1 volsnap

Description
-----------
This example shows how to find all of the sources that are represented in t
he 1000 most recent entries in the System event log.

The first command gets the 1,000 most recent entries from the System event
log and stores them in the $events variable.

The second command uses a pipeline operator (|) to send the events in $even
ts to the Group-Object cmdlet, which groups the entries by the value of the
Source property. The command uses a second pipeline operator to send the g
rouped events to the Sort-Object cmdlet, which sorts them in descending ord
er, so the most frequently appearing source is listed first.

Source is just property of event log entries. To see all of the properties
of an event log entry, pipe the events to the Get-Member cmdlet.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-eventlog -logname System -EntryType Error

Description
-----------
This command gets only error events from the System event log.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-eventlog -logname System -instanceID 3221235481 -Source "DCOM"

Description
-----------
This command gets events from the System log that have an InstanceID of 322
1235481 and a Source value of "DCOM."




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-eventlog -logname "Windows PowerShell" -computername localhost, S
erver01, Server02

Description
-----------
This command gets the events from the "Windows PowerShell" event log on thr
ee computers, Server01, Server02, and the local computer, known as "localho
st".




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-eventlog -logname "Windows PowerShell" -message "*failed*"

Description
-----------
This command gets all the events in the Windows PowerShell event log that h
ave a message value that includes the word "failed".




-------------------------- EXAMPLE 8 --------------------------

C:\PS>$a = get-eventlog -log System -newest 1

C:\PS> $a | format-list -property *

EventID : 7036
MachineName : Server01
Data : {}
Index : 10238
Category : (0)
CategoryNumber : 0
EntryType : Information
Message : The description for Event ID
Source : Service Control Manager
ReplacementStrings : {WinHTTP Web Proxy Auto-Disco
InstanceId : 1073748860
TimeGenerated : 4/11/2008 9:56:05 PM
TimeWritten : 4/11/2008 9:56:05 PM
UserName :
Site :
Container :

Description
-----------
This example shows how to display all of the property values of an event.

The first command gets the newest event from the System event log and saves
it in the $a variable.

The second command uses a pipeline operator (|) to send the event in $a to
the Format-List command, which displays all (*) of the event properties.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>get-eventlog -log application -source outlook | where {$_.eventID -eq
34}

Description
-----------
This command gets events in the Application event log where the source is O
utlook and the event ID is 34. Even though Get-EventLog does not have an Ev
entID parameter, you can use the Where-Object cmdlet to select events based
on the value of any event property.




-------------------------- EXAMPLE 10 --------------------------

C:\PS>get-eventlog -log system -username NT* | group-object -property usern
ame -noelement | format-table Count, Name -auto

Count Name
----- ----
6031 NT AUTHORITY\SYSTEM
42 NT AUTHORITY\LOCAL SERVICE
4 NT AUTHORITY\NETWORK SERVICE

Description
-----------
This command returns the events in the system log grouped by the value of
their UserName property. The Get-EventLog command uses the UserName paramet
er to get only events in which the user name begins with "NT*".




-------------------------- EXAMPLE 11 --------------------------

C:\PS>$May31 = get-date 5/31/08

C:\PS> $July1 = get-date 7/01/08

C:\PS> get-eventlog -log "Windows PowerShell" -entrytype Error -after $may3
1 -before $july1

Description
-----------
This command gets all of the errors in the Windows PowerShell event log tha
t occurred in June 2008.




REMARKS
To see the examples, type: "get-help Get-EventLog -examples".
For more information, type: "get-help Get-EventLog -detailed".
For technical information, type: "get-help Get-EventLog -full".

NAME
Get-EventSubscriber

SYNOPSIS
Gets the event subscribers in the current session.


SYNTAX
Get-EventSubscriber [-SubscriptionId] <int> [[-Force]] [<CommonParameters>]

Get-EventSubscriber [[-SourceIdentifier] <string>] [[-Force]] [<CommonParam
eters>]


DESCRIPTION
The Get-EventSubscriber cmdlet gets the event subscribers in the current se
ssion.

When you subscribe to an event by using a Register event cmdlet, an event s
ubscriber is added to your Windows PowerShell session, and the events to wh
ich you subscribed are added to your event queue whenever they are raised.
To cancel an event subscription, delete the event subscriber by using the U
nregister-Event cmdlet.

PARAMETERS
-Force [<SwitchParameter>]
Gets all event subscribers, including subscribers for events that are h
idden by using the SupportEvent parameter of Register-ObjectEvent, Regi
ster-WmiEvent, and Register-EngineEvent.

-SourceIdentifier <string>
Gets only the event subscribers with the specified SourceIdentifier pro
perty value. By default, Get-EventSubscriber gets all event subscribers
in the session. Wildcards are not permitted. This parameter is case-se
nsitive.

-SubscriptionId <int>
Gets only the specified subscription identifier. By default, Get-EventS
ubscriber gets all event subscribers in the session.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$timer = New-Object Timers.Timer

C:\PS> $timer | Get-Member -Type Event

C:\PS> Register-ObjectEvent -inputObject $timer -EventName Elapsed -SourceI
dentifier Timer.Elapsed

C:\PS> Get-EventSubscriber

C:\PS> $timer = New-Object Timers.Timer

C:\PS> $timer | Get-Member -Type Event

TypeName: System.Timers.Timer

Name MemberType Definition
---- ---------- ----------
Disposed Event System.EventHandler Disposed(System.Object, System.Even
tArgs)
Elapsed Event System.Timers.ElapsedEventHandler Elapsed(System.Object
, System.Timers.ElapsedEventArgs)

C:\PS> Register-ObjectEvent -InputObject $timer -EventName Elapsed -SourceI
dentifier Timer.Elapsed

C:\PS> Get-EventSubscriber

SubscriptionId : 4
SourceObject : System.Timers.Timer
EventName : Elapsed
SourceIdentifier : Timer.Elapsed
Action :
HandlerDelegate :
SupportEvent : False
ForwardEvent : False

Description
-----------
This example uses a Get-EventSubscriber command to get the event subscriber
for a timer event.

The first command uses the New-Object cmdlet to create an instance of a tim
er object. It saves the new timer object in the $timer variable.

The second command uses the Get-Member cmdlet to display the events that ar
e available for timer objects. The command uses the Type parameter of the G
et-Member cmdlet with a value of Event.

The third command uses the Register-ObjectEvent cmdlet to register for the
Elapsed event on the timer object.

The fourth command uses the Get-EventSubscriber cmdlet to get the event sub
scriber for the Elapsed event.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$timer = New-Object Timers.Timer

C:\PS> $timer.Interval = 500

C:\PS> Register-ObjectEvent -inputObject $timer -eventName Elapsed -sourceI
dentifier Timer.Random -Action { $random = Get-Random -Min 0 -Max 100 }

Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
3 Timer.Random NotStarted False $random = Get-Random .
..


C:\PS> $timer.Enabled = $true

C:\PS> $subscriber = Get-EventSubcriber -sourceIdentifer Timer.Random

C:\PS> ($subscriber.action).gettype().fullname
PSEventJob

C:\PS> $subscriber.action | format-list -property *

State : Running
Module : __DynamicModule_6b5cbe82-d634-41d1-ae5e-ad7fe8d57fe0
StatusMessage :
HasMoreData : True
Location :
Command : $random = Get-Random -Min 0 -Max 100
JobStateInfo : Running
Finished : System.Threading.ManualResetEvent
InstanceId : 88944290-133d-4b44-8752-f901bd8012e2
Id : 1
Name : Timer.Random
ChildJobs : {}
...

C:\PS> & $subscriber.action.module {$random}
96

C:\PS> & $subscriber.action.module {$random}
23

Description
-----------
This example shows how to use the dynamic module in the PSEventJob object i
n the Action property of the event subscriber.

The first command uses the New-Object cmdlet to create a timer object. The
second command sets the interval of the timer to 500 (milliseconds).

The third command uses the Register-ObjectEvent cmdlet to register the Elap
sed event of the timer object. The command includes an action that handles
the event. Whenever the timer interval elapses, an event is raised and the
commands in the action run. In this case, the Get-Random cmdlet generates a
random number between 0 and 100 and saves it in the $random variable. The
source identifier of the event is Timer.Random.

When you use an Action parameter in a Register-ObjectEvent command, the com
mand returns a PSEventJob object that represents the action.

The fourth command enables the timer.

The fifth command uses the Get-EventSubscriber cmdlet to get the event subs
criber of the Timer.Random event. It saves the event subscriber object in t
he $subscriber variable.

The sixth command shows that the Action property of the event subscriber ob
ject contains a PSEventJob object. In fact, it contains the same PSEventJob
object that the Register-ObjectEvent command returned.

The seventh command uses the Format-List cmdlet to display all of the prope
rties of the PSEventJob object in the Action property in a list. The result
reveal that the PSEventJob object has a Module property that contains a dy
namic script module that implements the action.

The remaining commands use the call operator (&) to invoke the command in t
he module and display the value of the $random variable. You can use the ca
ll operator to invoke any command in a module, including commands that are
not exported. In this case, the commands show the random number that is bei
ng generated when the Elapsed event occurs.

For more information about modules, see about_Modules.




REMARKS
To see the examples, type: "get-help Get-EventSubscriber -examples".
For more information, type: "get-help Get-EventSubscriber -detailed".
For technical information, type: "get-help Get-EventSubscriber -full".

NAME
Get-ExecutionPolicy

SYNOPSIS
Gets the execution policies for the current session.


SYNTAX
Get-ExecutionPolicy [[-Scope] {Process | CurrentUser | LocalMachine | UserP
olicy | MachinePolicy}] [-List] [<CommonParameters>]


DESCRIPTION
The Get-ExecutionPolicy cmdlet gets the execution policies for the current
session.

The execution policy is determined by execution policies that you set by us
ing Set-ExecutionPolicy and the Group Policy settings for the Windows Power
Shell execution policy. The default value is "Restricted."

Without parameters, Get-ExecutionPolicy gets the execution policy that is e
ffective in the session. You can use the List parameter to get all executio
n policies that affect the session or the Scope parameter to get the execut
ion policy for a particular scope.

For more information, see about_Execution_Policies.

PARAMETERS
-List [<SwitchParameter>]
Gets all execution policy values for the session listed in precedence o
rder. By default, Get-ExecutionPolicy gets only the effective executio
n policy.

-Scope <ExecutionPolicyScope>
Gets the execution policy in the specified scope. By default, Get-Exec
utionPolicy gets the effective execution policy for the current session
.

Valid values are:

-- MachinePolicy: The execution policy set by a Group Policy for all us
ers of the computer.
-- UserPolicy: The execution policy set by a Group Policy for the curre
nt user of the computer.
-- Process: The execution policy that is set for the current Windows Po
werShell process.
-- CurrentUser: The execution policy that is set for the current user.
-- LocalMachine: The execution policy that is set for all users of the
computer.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-executionpolicy

Restricted

Description
-----------
This command gets the current execution policy for the shell.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>set-executionpolicy RemoteSigned; get-executionPolicy

RemoteSigned

Description
-----------
These commands set a new user preference for the shell execution policy and
then display the effective execution policy. The commands are separated by
a semicolon (;). In this example, because there is no Group Policy setting
, the user preference is the effective policy for the shell.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-executionpolicy -list

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser AllSigned
LocalMachine RemoteSigned

C:\PS> get-executionpolicy
AllSigned

Description
-----------
These commands get all execution policies in the current session and the ef
fective execution policy.

The first command gets all execution policies that affect the current sessi
on. The policies are listed in precedence order.

The second command gets only the effective execution policy, which is the o
ne set in the CurrentUser scope.




REMARKS
To see the examples, type: "get-help Get-ExecutionPolicy -examples".
For more information, type: "get-help Get-ExecutionPolicy -detailed".
For technical information, type: "get-help Get-ExecutionPolicy -full".

NAME
Get-FormatData

SYNOPSIS
Gets the formatting data in the current session.


SYNTAX
Get-FormatData [[-TypeName] <string[]>] [<CommonParameters>]


DESCRIPTION
The Get-FormatData cmdlet gets the formatting data in the current session.


The formatting data in the session includes formatting data from Format.ps1
xml formatting files (such as those in the $pshome directory), formatting d
ata for modules that you import into the session, and formatting data for c
ommands that you import into your session by using the Import-PSSession cmd
let.

You can use this cmdlet to examine the formatting data. Then, you can use t
he Export-FormatData cmdlet to serialize the objects (convert them to XML)
and save them in Format.ps1xml files.

For more information about formatting files in Windows PowerShell, see abou
t_Format.ps1xml.

PARAMETERS
-TypeName <string[]>
Gets only the formatting data with the specified type names. Enter the
type names. Wildcards are permitted.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-formatdata

Description
-----------
This command gets all the formatting data in the session.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-formatdata -typename Microsoft.Wsman*

Description
-----------
This command gets the formatting data items whose names begin with "Microso
ft.Wsman".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$f = get-formatdata -typename helpinfoshort

C:\PS> $f

TypeName FormatViewDefinition
-------- --------------------
HelpInfoShort {help , TableControl}

C:\PS> $f.FormatViewDefinition[0].control

Headers
Rows
-------
----
{System.Management.Automation.TableControlColumnHeader, System.Manageme...
{System.Management.Automation.TableControlRow}


C:\PS> $f.FormatViewDefinition[0].control.headers

Label Alignment Width
----- --------- -----
Name Left 33
Category Left 9
Undefined 0

Description
-----------
This example shows how to get a formatting data object and examine its prop
erties.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$a = get-formatdata

C:\PS> import-module bitstransfer
C:\PS> $b = get-formatdata
C:\PS> compare-object $a $b

InputObject SideIndicator
----------- -------------
Microsoft.BackgroundIntelligentTransfer.Management.BitsJob =>


C:\PS> get-formatdata *bits* | export-formatdata -filepath c:\test\bits.for
mat.ps1xml

C:\PS> get-content c:\test\bits.format.ps1xml

<?xml version="1.0" encoding="utf-8"?><Configuration><ViewDefinitions>
<View><Name>Microsoft.BackgroundIntelligentTransfer.Management.BitsJob</Nam
e>
...

Description
-----------
This example shows how to use Get-FormatData and Export-FormatData to expor
t the formatting data that is added by a module.

The first four commands use the Get-FormatData, Import-Module, and Compare-
Object cmdlets to identify the format type that the BitsTransfer module add
s to the session.

The fifth command uses the Get-FormatData cmdlet to get the format type tha
t the BitsTransfer module adds. It uses a pipeline operator (|) to send the
format type object to the Export-FormatData cmdlet, which converts it back
to XML and saves it in the specified format.ps1xml file.

The final command shows an excerpt of the format.ps1xml file content.




REMARKS
To see the examples, type: "get-help Get-FormatData -examples".
For more information, type: "get-help Get-FormatData -detailed".
For technical information, type: "get-help Get-FormatData -full".

NAME
Get-Help

SYNOPSIS
Displays information about Windows PowerShell commands and concepts.


SYNTAX
Get-Help [-Full] [[-Name] <string>] [-Category <string[]>] [-Component <str
ing[]>] [-Functionality <string[]>] [-Online] [-Path <string>] [-Role <stri
ng[]>] [<CommonParameters>]

Get-Help [-Detailed] [[-Name] <string>] [-Category <string[]>] [-Component
<string[]>] [-Functionality <string[]>] [-Online] [-Path <string>] [-Role <
string[]>] [<CommonParameters>]

Get-Help [-Examples] [[-Name] <string>] [-Category <string[]>] [-Component
<string[]>] [-Functionality <string[]>] [-Online] [-Path <string>] [-Role <
string[]>] [<CommonParameters>]

Get-Help [-Parameter <string>] [[-Name] <string>] [-Category <string[]>] [-
Component <string[]>] [-Functionality <string[]>] [-Online] [-Path <string>
] [-Role <string[]>] [<CommonParameters>]


DESCRIPTION
The Get-Help cmdlet displays information about Windows PowerShell concepts
and commands, including cmdlets, providers, functions and scripts. To get a
list of all cmdlet help topic titles, type "get-help *".

If you type "Get-Help" followed by the exact name of a help topic, or by a
word unique to a help topic, Get-Help displays the topic contents. If you e
nter a word or word pattern that appears in several help topic titles, Get-
Help displays a list of the matching titles. If you enter a word that does
not appear in any help topic titles, Get-Help displays a list of topics tha
t include that word in their contents.

In addition to "get-help", you can also type "help" or "man", which display
s one screen of text at a time, or "<cmdlet-name> -?", which is identical t
o Get-Help but works only for cmdlets.

You can display the entire help file or selected parts of the file, such as
the syntax, parameters, or examples. You can also use the Online parameter
to display an online version of a help file in your Internet browser. Thes
e parameters have no effect on conceptual help topics.

Conceptual help topics in Windows PowerShell begin with "about_", such as "
about_Comparison_Operators". To see all "about_" topics, type "get-help abo
ut_*". To see a particular topic, type "get-help about_<topic-name>", such
as "get-help about_Comparison_Operators".

PARAMETERS
-Category <string[]>
Displays help for items in the specified category. Valid values are Ali
as, Cmdlet, Provider, and HelpFile. Conceptual topics are in the HelpFi
le category.

Category is a property of the MamlCommandHelpInfo object that Get-Help
returns. This parameter has no effect on displays of conceptual ("about
_") help.

-Component <string[]>
Displays a list of tools with the specified component value, such as "E
xchange." Enter a component name. Wildcards are permitted.

Component is a property of the MamlCommandHelpInfo object that Get-Help
returns. This parameter has no effect on displays of conceptual ("Abou
t_") help.

-Detailed [<SwitchParameter>]
Adds parameter descriptions and examples to the basic help display.

This parameter has no effect on displays of conceptual ("About_") help.

-Examples [<SwitchParameter>]
Displays only the name, synopsis, and examples. To display only the exa
mples, type "(get-help <cmdlet-name>).examples".

This parameter has no effect on displays of conceptual ("About_") help.

-Full [<SwitchParameter>]
Displays the entire help file for a cmdlet, including parameter descrip
tions and attributes, examples, input and output object types, and addi
tional notes.

This parameter has no effect on displays of conceptual ("About_") help.

-Functionality <string[]>
Displays help for items with the specified functionality. Enter the fun
ctionality. Wildcards are permitted.

Functionality is a property of the MamlCommandHelpInfo object that Get-
Help returns. This parameter has no effect on displays of conceptual ("
About_") help.

-Name <string>
Requests help about the specified tool or conceptual topic. Enter a cmd
let, provider, script, or function name, such as Get-Member, a conceptu
al topic name, such as "about_Objects", or an alias, such as "ls". Wild
cards are permitted in cmdlet and provider names, but you cannot use wi
ldcards to find the names of function help and script help topics.

To get help for a script that is not located in a path that is listed i
n the Path environment variable, type the path and file name of the scr
ipt .

If you enter the exact name of a help topic, Get-Help displays the topi
c contents. If you enter a word or word pattern that appears in several
help topic titles, Get-Help displays a list of the matching titles. If
you enter a word that does not match any help topic titles, Get-Help d
isplays a list of topics that include that word in their contents.

The names of conceptual topics, such as about_Objects, must be entered
in English, even in non-English versions of Windows PowerShell.

-Online [<SwitchParameter>]
Displays the online version of a help topic in the default Internet bro
wser. This parameter is valid only for cmdlet, function, and script hel
p topics.

Get-Help uses the Internet address (Uniform Resource Identifier [URI])
that appears in the first item of the Related Links section of a cmdlet
, function, or script help topic. This parameter works only when the he
lp topic includes a URI that begins with "Http" or "Https" and an Inter
net browser is installed on the system.

For information about supporting this feature in help topics that you w
rite, see about_Comment_Based_Help, and see "How to Write Cmdlet Help"
in the MSDN (Microsoft Developer Network) library at http://go.microsof
t.com/fwlink/?LinkID=123415.

-Parameter <string>
Displays only the detailed descriptions of the specified parameters. Wi
ldcards are permitted.

This parameter has no effect on displays of conceptual ("About_") help.

-Path <string>
Gets help that explains how the cmdlet works in the specified provider
path. Enter a Windows PowerShell provider path.

This parameter gets a customized version of a cmdlet help topic that ex
plains how the cmdlet works in the specified Windows PowerShell provide
r path. This parameter is effective only for help about a provider cmdl
et and only when the provider includes a custom version of the provider
cmdlet help topic.

To see the custom cmdlet help for a provider path, go to the provider p
ath location and enter a Get-Help command or, from any path location, u
se the Path parameter of Get-Help to specify the provider path. For mor
e information, see about_Providers.

-Role <string[]>
Displays help customized for the specified user role. Enter a role. Wil
dcards are permitted.

Enter the role that the user plays in an organization. Some cmdlets dis
play different text in their help files based on the value of this para
meter. This parameter has no effect on help for the core cmdlets.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-help

Description
-----------
This command displays help about the Windows PowerShell help system.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-help *

Description
-----------
This command displays a list of all help files in the Windows PowerShell he
lp system.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-help get-alias

C:\PS>help get-alias

C:\PS>get-alias -?

Description
-----------
These commands display basic information about the get-alias cmdlet. The "G
et-Help" and "-?" commands display the information on a single page. The "H
elp" command displays the information one page at a time.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-help about_*

Description
-----------
This command displays a list of the conceptual topics included in Windows P
owerShell help. All of these topics begin with the characters "about_". To
display a particular help file, type "get-help <topic-name>, for example, "
get-help about_signing".




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-help ls -detailed

Description
-----------
This command displays detailed help for the Get-ChildItem cmdlet by specify
ing one of its aliases, "ls." The Detailed parameter requests the detailed
view of the help file, which includes parameter descriptions and examples.
To see the complete help file for a cmdlet, use the Full parameter.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-help format-string -full

Description
-----------
This command displays the full view help for the Format-String cmdlet. The
full view of help includes parameter descriptions, examples, and a table of
technical details about the parameters.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-help start-service -examples

Description
-----------
This command displays examples of using start-service in Windows PowerShell
commands.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>get-help get-childitem -parameter f*

Description
-----------
This command displays descriptions of the parameters of the Get-ChildItem c
mdlet that begin with "f" (filter and force). For descriptions of all param
eters, type "get-help get-childitem parameter*".




-------------------------- EXAMPLE 9 --------------------------

C:\PS>(get-help write-output).syntax

Description
-----------
This command displays only the syntax of the Write-Output cmdlet.

Syntax is one of many properties of help objects; others are description, d
etails, examples, and parameters. To find all properties and methods of hel
p objects, type "get-help <cmdlet-name> | get-member"; for example, "get-he
lp start-service | get member".




-------------------------- EXAMPLE 10 --------------------------

C:\PS>(get-help trace-command).alertset

Description
-----------
This command displays the notes about the cmdlet. The notes are stored in t
he alertSet property of the help object.

The notes include conceptual information and tips for using the cmdlet. By
default, the notes are displayed only when you use the Full parameter of Ge
t-Help, but you can also display them by using the alertSet property.




-------------------------- EXAMPLE 11 --------------------------

C:\PS>get-help add-member -full | out-string -stream | select-string -patte
rn clixml

Description
-----------
This example shows how to search for a word in particular cmdlet help topic
. This command searches for the word "clixml" in the full version of the he
lp topic for the Add-Member cmdlet.

Because the Get-Help cmdlet generates a MamlCommandHelpInfo object, not a s
tring, you need to use a command that transforms the help topic content int
o a string, such as Out-String or Out-File.




-------------------------- EXAMPLE 12 --------------------------

C:\PS>get-help get-member -online

Description
-----------
This command displays the online version of the help topic for the Get-Memb
er cmdlet.




-------------------------- EXAMPLE 13 --------------------------

C:\PS>get-help remoting

Description
-----------
This command displays a list of topics that include the word "remoting" in
their contents.

When you enter a word that does not appear in any topic title, Get-Help dis
plays a list of topics that include that word.




-------------------------- EXAMPLE 14 --------------------------

C:\PS>get-help get-item -path SQLSERVER:\DataCollection

NAME
Get-Item

SYNOPSIS
Gets a collection of Server objects for the local computer and any comp
uters to which you have made a SQL Server PowerShell connection.
...

C:\PS> cd SQLSERVER:\DataCollection
C:\PS> SQLSERVER:\DataCollection> get-help get-item


NAME
Get-Item

SYNOPSIS
Gets a collection of Server objects for the local computer and any comp
uters to which you have made a SQL Server PowerShell connection.
...


C:\PS> Get-Item

NAME
Get-Item

SYNOPSIS
Gets the item at the specified location.

...

Description
-----------
This example shows how to get help for the Get-Item cmdlet that explains ho
w to use the cmdlet in the DataCollection node of the Windows PowerShell SQ
L Server provider.

The example shows two ways of getting the custom help for Get-Item.

The first command uses the Path parameter of Get-Help to specify the provid
er path. This command can be entered at any path location.

The second command uses the Set-Location cmdlet (alias = "cd") to go to the
provider path. From that location, even without the Path parameter, the Ge
t-Help command gets the custom help for the provider path.

The third command shows that a Get-Help command in a file system path, and
without the Path parameter, gets the standard help for the Get-Item cmdlet.




-------------------------- EXAMPLE 15 --------------------------

C:\PS>get-help c:\ps-test\MyScript.ps1

Description
-----------
This command gets help for the MyScript.ps1 script. For information about w
riting help for your functions and scripts, see about_Comment_Based_Help.




REMARKS
To see the examples, type: "get-help Get-Help -examples".
For more information, type: "get-help Get-Help -detailed".
For technical information, type: "get-help Get-Help -full".

NAME
Get-History

SYNOPSIS
Gets a list of the commands entered during the current session.


SYNTAX
Get-History [[-Id] <Int64[]>] [[-Count] <int>] [<CommonParameters>]


DESCRIPTION
The Get-History cmdlet gets the session history, that is, the list of comma
nds entered during the current session. Windows PowerShell automatically ma
intains a history of each session. You can save the session history in XML
or CSV format. By default, history files are saved in the home directory, b
ut you can save the file in any location.

PARAMETERS
-Count <int>
Displays the specified number of the most recent history entries. The d
efault is 32. If you use both the Count and Id parameters in a command,
the display ends with the command specified by the Id parameter.

-Id <Int64[]>
Specifies the ID number of a command in the session history. Get-Histor
y gets only the specified command. If you use Id and Count, Get-History
gets the most recent commands ending with the command specified by the
Id parameter.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-history

Description
-----------
This command gets the 32 most recently submitted commands. The default disp
lay shows each command and its ID, which indicates the order of execution.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-history | where-object {$_.commandLine -like "*service*"}

Description
-----------
This command gets entries from the command history that include the word, "
service". The first command gets the 32 most recent entries in the session
history. The pipeline operator (|) passes the results to the Where-Object c
mdlet, which selects only the commands that include "service".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-history -id 7 -count 5 | export-csv history.csv

Description
-----------
This command gets the five most recent history entries ending with entry 7.
The pipeline operator (|) passes the result to the Export-Csv cmdlet, whic
h formats the history as comma-separated text and saves it in the History.c
sv file. The file includes the data that is displayed when you format the h
istory as a list, including the status and start and end times of the comma
nd.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-history -count 1

Description
-----------
This command gets the last (most recently entered) command in the command h
istory. It uses the Count parameter to display just one command. By default
, Get-History displays the most recent commands. This command can be abbrev
iated to "h -c 1" and is equivalent to pressing the up-arrow key.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-history -count $MaximumHistoryCount

Description
-----------
This command displays all of the commands saved in the session history. By
default, $MaximumHistoryCount is 64, so this command can be abbreviated as
"h -c 64".




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-history | format-list

Description
-----------
This command displays all of the properties of entries in the session histo
ry. The pipeline operator (|) passes the result to the Format-List cmdlet,
which displays all of the properties of each history entry, including the I
D, status, and start and end times of the command.




REMARKS
To see the examples, type: "get-help Get-History -examples".
For more information, type: "get-help Get-History -detailed".
For technical information, type: "get-help Get-History -full".

NAME
Get-Host

SYNOPSIS
Gets an object that represents the current host program. And, displays Wind
ows PowerShell version and regional information by default.


SYNTAX
Get-Host [<CommonParameters>]


DESCRIPTION
The Get-Host cmdlet gets an object that represents the program that is host
ing Windows PowerShell.

The default display includes the Windows PowerShell version number and the
current region and language settings that the host is using, but the host o
bject contains a wealth of information, including detailed information abou
t the version of Windows PowerShell that is currently running and the curre
nt culture and UI culture of Windows PowerShell. You can also use this cmd
let to customize features of the host program user interface, such as the t
ext and background colors.

PARAMETERS
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-host

Name : ConsoleHost
Version : 2.0
InstanceId : e4e0ab54-cc5e-4261-9117-4081f20ce7a2
UI : System.Management.Automation.Internal.Host.InternalHostU
serInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace

Description
-----------
This command displays information about the Windows PowerShell console, whi
ch is the current host program for Windows PowerShell in this example. It i
ncludes the name of the host, the version of Windows PowerShell that is run
ning in the host, and current culture and UI culture.

The Version, UI, CurrentCulture, CurrentUICulture, PrivateData, and Runspac
e properties each contain an object with very useful properties. Later exam
ples examine these properties.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$h = get-host

C:\PS> $win = $h.ui.rawui.windowsize

C:\PS> $win.height = 10

C:\PS> $win.width = 10

C:\PS> $h.ui.rawui.set_windowsize($win)

Description
-----------
This command resizes the Windows PowerShell window to 10 pixels by 10 pixel
s.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>(get-host).version | format-list -property *

Major : 2
Minor : 0
Build : -1
Revision : -1
MajorRevision : -1
MinorRevision : -1

Description
-----------
This command gets detailed information about the version of Windows PowerSh
ell running in the host. You can view, but not change, these values.

The Version property of Get-Host contains a System.Version object. This com
mand uses a pipeline operator (|) to send the version object to the Format-
List cmdlet. The Format-List command uses the Property parameter with a val
ue of all (*) to display all of the properties and property values of the v
ersion object.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>(get-host).currentculture | format-list -property *

Parent : en
LCID : 1033
KeyboardLayoutId : 1033
Name : en-US
IetfLanguageTag : en-US
DisplayName : English (United States)
NativeName : English (United States)
EnglishName : English (United States)
TwoLetterISOLanguageName : en
ThreeLetterISOLanguageName : eng
ThreeLetterWindowsLanguageName : ENU
CompareInfo : CompareInfo - 1033
TextInfo : TextInfo - 1033
IsNeutralCulture : False
CultureTypes : SpecificCultures, InstalledWin32Cultures,
FrameworkCultures
NumberFormat : System.Globalization.NumberFormatInfo
DateTimeFormat : System.Globalization.DateTimeFormatInfo
Calendar : System.Globalization.GregorianCalendar
OptionalCalendars : {System.Globalization.GregorianCalendar, S
ystem.Globalization.GregorianCalendar}
UseUserOverride : True
IsReadOnly : False

Description
-----------
This command gets detailed information about the current culture set for Wi
ndows PowerShell running in the host. This is the same information that is
returned by the Get-Culture cmdlet.

(Similarly, the CurrentUICulture property returns the same object that Get-
UICulture returns.)

The CurrentCulture property of the host object contains a System.Globaliza
tion.CultureInfo object. This command uses a pipeline operator (|) to send
the CultureInfo object to the Format-List cmdlet. The Format-List command u
ses the Property parameter with a value of all (*) to display all of the pr
operties and property values of the CultureInfo object.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>(get-host).currentculture.DateTimeFormat | format-list -property *

AMDesignator : AM
Calendar : System.Globalization.GregorianCalendar
DateSeparator : /
FirstDayOfWeek : Sunday
CalendarWeekRule : FirstDay
FullDateTimePattern : dddd, MMMM dd, yyyy h:mm:ss tt
LongDatePattern : dddd, MMMM dd, yyyy
LongTimePattern : h:mm:ss tt
MonthDayPattern : MMMM dd
PMDesignator : PM
RFC1123Pattern : ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
ShortDatePattern : M/d/yyyy
ShortTimePattern : h:mm tt
SortableDateTimePattern : yyyy'-'MM'-'dd'T'HH':'mm':'ss
TimeSeparator : :
UniversalSortableDateTimePattern : yyyy'-'MM'-'dd HH':'mm':'ss'Z'
YearMonthPattern : MMMM, yyyy
AbbreviatedDayNames : {Sun, Mon, Tue, Wed...}
ShortestDayNames : {Su, Mo, Tu, We...}
DayNames : {Sunday, Monday, Tuesday, Wednesday...}
AbbreviatedMonthNames : {Jan, Feb, Mar, Apr...}
MonthNames : {January, February, March, April...}
IsReadOnly : False
NativeCalendarName : Gregorian Calendar
AbbreviatedMonthGenitiveNames : {Jan, Feb, Mar, Apr...}
MonthGenitiveNames : {January, February, March, April...}

Description
-----------
This command returns detailed information about the DateTimeFormat of the c
urrent culture that is being used for Windows PowerShell.

The CurrentCulture property of the host object contains a CultureInfo objec
t that, in turn, has many useful properties. Among them, the DateTimeFormat
property contains a DateTimeFormatInfo object with many useful properties.


To find the type of an object that is stored in an object property, use the
Get-Member cmdlet. To display the property values of the object, use the F
ormat-List cmdlet.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>(get-host).ui.rawui | format-list -property *

ForegroundColor : DarkYellow
BackgroundColor : DarkBlue
CursorPosition : 0,390
WindowPosition : 0,341
CursorSize : 25
BufferSize : 120,3000
WindowSize : 120,50
MaxWindowSize : 120,81
MaxPhysicalWindowSize : 182,81
KeyAvailable : False
WindowTitle : Windows PowerShell 2.0 (04/11/2008 00:08:14)

Description
-----------
This command displays the properties of the RawUI property of the host obje
ct. By changing these values, you can change the appearance of the host pro
gram.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>(get-host).ui.rawui.backgroundcolor = "Black"

C:\PS> cls

Description
-----------
These commands change the background color of the Windows PowerShell consol
e to black. The "cls" command is an alias for the Clear-Host function, whic
h clears the screen and changes the whole screen to the new color.

This change is effective only in the current session. To change the backgro
und color of the console for all sessions, add the command to your Windows
PowerShell profile.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>$host.privatedata.errorbackgroundcolor = "white"

Description
-----------
This command changes the background color of error messages to white.

This command uses the $host automatic variable, which contains the host obj
ect for the current host program. Get-Host returns the same object that $ho
st contains, so you can use them interchangeably.

This command uses the PrivateData property of $host as its ErrorBackgroundC
olor property. To see all of the properties of the object in the $host.priv
atedata property, type "$host.privatedata | format-list * ".




REMARKS
To see the examples, type: "get-help Get-Host -examples".
For more information, type: "get-help Get-Host -detailed".
For technical information, type: "get-help Get-Host -full".

NAME
Get-HotFix

SYNOPSIS
Gets the hotfixes that have been applied to the local and remote computers.


SYNTAX
Get-HotFix [[-Id] <string[]>] [-ComputerName <string[]>] [-Credential <PSCr
edential>] [<CommonParameters>]

Get-HotFix [-Description <string[]>] [-ComputerName <string[]>] [-Credentia
l <PSCredential>] [<CommonParameters>]


DESCRIPTION
The Get-Hotfix cmdlet gets the hotfixes that have been applied to the local
computer or to remote computers by Component-Based Servicing.

PARAMETERS
-ComputerName <string[]>
Specifies a remote computer. The default is the local computer.

Type the NetBIOS name, an Internet Protocol (IP) address, or a fully qu
alified domain name of a remote computer.

This parameter does not rely on Windows PowerShell remoting. You can us
e the ComputerName parameter of Get-Hotfix even if your computer is not
configured to run remote commands.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

-Description <string[]>
Gets only hotfixes with the specified descriptions. Wildcards are permi
tted. The default is all hotfixes on the computer.

-Id <string[]>
Gets only hotfixes with the specified hotfix IDs. The default is all ho
tfixes on the computer.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-hotfix

Description
-----------
This command gets all hotfixes on the local computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-hotfix -description Security* -computername Server01, Server02 -c
red Server01\admin01

Description
-----------
This command gets all hotfixes on the Server01 and Server02 computers that
have a description that begins with "Security".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$a = get-content servers.txt

C:\PS> $a | foreach { if (!(get-hotfix -id KB957095 -computername $_)) { ad
d-content $_ -path Missing-kb953631.txt }}

Description
-----------
The commands in this example create a text file listing the names of comput
ers that are missing a security update.

The commands use the Get-Hotfix cmdlet to get the KB957095 security update
on all of the computers whose names are listed in the Servers.txt file.

If a computer does not have the update, the Add-Content cmdlet writes the c
omputer name in the Missing-KB953631.txt file.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>(get-hotfix | sort installedon)[-1]

Description
-----------
This command gets the most recent hotfix on the computer.

It gets the hotfixes, sorts them by the value of the InstalledOn property,
and then it uses array notation to select the last item in the array.




REMARKS
To see the examples, type: "get-help Get-HotFix -examples".
For more information, type: "get-help Get-HotFix -detailed".
For technical information, type: "get-help Get-HotFix -full".

NAME
Get-Item

SYNOPSIS
Gets the item at the specified location.


SYNTAX
Get-Item [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Exclude <
string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-UseTransacti
on] [<CommonParameters>]

Get-Item [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <string[
]>] [-Filter <string>] [-Force] [-Include <string[]>] [-UseTransaction] [<C
ommonParameters>]


DESCRIPTION
The Get-Item cmdlet gets the item at the specified location. It does not ge
t the contents of the item at the location unless you use a wildcard charac
ter (*) to request all the contents of the item.

The Get-Item cmdlet is used by Windows PowerShell providers to enable you t
o navigate through different types of data stores.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user-name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

The Exclude parameter is effective only when the command includes the c
ontents of an item, such as C:\Windows\*, where the wildcard character
specifies the contents of the C:\Windows directory.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to get items that cannot otherwise be accessed, such
as hidden items. Implementation varies from provider to provider. For m
ore information, see about_Providers. Even using the Force parameter, t
he cmdlet cannot override security restrictions.

-Include <string[]>
Retrieves only the specified items. The value of this parameter qualifi
es the Path parameter. Enter a path element or pattern, such as "*.txt"
. Wildcards are permitted.

The Include parameter is effective only when the command includes the c
ontents of an item, such as C:\Windows\*, where the wildcard character
specifies the contents of the C:\Windows directory.

-LiteralPath <string[]>
Specifies a path to the item. Unlike Path, the value of LiteralPath is
used exactly as it is typed. No characters are interpreted as wildcards
. If the path includes escape characters, enclose it in single quotatio
n marks. Single quotation marks tell Windows PowerShell not to interpre
t any characters as escape sequences.

-Path <string[]>
Specifies the path to an item. Get-Item gets the item at the specified
location. Wildcards are permitted. This parameter is required, but the
parameter name ("Path") is optional.

Use a dot (.) to specify the current location. Use the wildcard charact
er (*) to specify all the items in the current location.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-item .

Directory: C:\

Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 7/26/2006 10:01 AM ps-test

Description
-----------
This command gets the current directory. The dot (.) represents the item at
the current location (not its contents).




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-item *

Directory: C:\ps-test

Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 7/26/2006 9:29 AM Logs
d---- 7/26/2006 9:26 AM Recs
-a--- 7/26/2006 9:28 AM 80 date.csv
-a--- 7/26/2006 10:01 AM 30 filenoext
-a--- 7/26/2006 9:30 AM 11472 process.doc
-a--- 7/14/2006 10:47 AM 30 test.txt

Description
-----------
This command gets all the items in the current directory. The wildcard char
acter (*) represents all the contents of the current item.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-item C:\

Description
-----------
This command gets the current directory of the C: drive. The object that is
retrieved represents only the directory, not its contents.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-item C:\*

Description
-----------
This command gets the items in the C: drive. The wildcard character (*) rep
resents all the items in the container, not just the container.

In Windows PowerShell, use a single asterisk (*) to get contents, instead o
f the traditional "*.*". The format is interpreted literally, so "*.*" woul
d not retrieve directories or file names without a dot.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>(get-item C:\Windows).LastAccessTime

Description
-----------
This command gets the LastAccessTime property of the C:\Windows directory.
LastAccessTime is just one property of file system directories. To see all
of the properties of a directory, type "(Get-Item <directory-name>) | Get-M
ember".




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-item hklm:\software\microsoft\powershell\1\shellids\microsoft.pow
ershell\*

Description
-----------
This command shows the contents of the Microsoft.PowerShell registry key. Y
ou can use Get-Item with the Windows PowerShell Registry provider to get re
gistry keys and subkeys, but you must use Get-ItemProperty to get the regis
try values and data.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-item c:\Windows\* -include *.* -exclude w*

Description
-----------
This command gets items in the Windows directory with names that include a
dot (.), but do not begin with w*. This command works only when the path in
cludes a wildcard character (*) to specify the contents of the item.




REMARKS
To see the examples, type: "get-help Get-Item -examples".
For more information, type: "get-help Get-Item -detailed".
For technical information, type: "get-help Get-Item -full".

NAME
Get-ItemProperty

SYNOPSIS
Gets the properties of a specified item.


SYNTAX
Get-ItemProperty [-LiteralPath] <string[]> [[-Name] <string[]>] [-Credentia
l <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Include <strin
g[]>] [-UseTransaction] [<CommonParameters>]

Get-ItemProperty [-Path] <string[]> [[-Name] <string[]>] [-Credential <PSCr
edential>] [-Exclude <string[]>] [-Filter <string>] [-Include <string[]>] [
-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Get-ItemProperty cmdlet gets the properties of the specified items. For
example, you can use Get-ItemProperty to get the value of the LastAccessTi
me property of a file object. You can also use Get-ItemProperty to view reg
istry entries and their values.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. Wildcards are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects rather than having Windows PowerShell filter
the objects after they are retrieved.

-Include <string[]>
Includes the specified items.

-LiteralPath <string[]>
Specifies a path to the item property. The value of LiteralPath is used
exactly as it is typed. No characters are interpreted as wildcards. If
the path includes escape characters, enclose it in single quotation ma
rks. Single quotation marks tell Windows PowerShell not to interpret an
y characters as escape sequences.

-Name <string[]>
Specifies the name of the property or properties to retrieve.

-Path <string[]>
Specifies the path to the item or items.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-itemproperty C:\Windows

Description
-----------
This command gets information about the C:\Windows directory.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-itemproperty C:\Test\Weather.xls | format-list

Description
-----------
This command gets the properties of the C:\Test\Weather.xls file. The resul
t is piped to the Format-List cmdlet to display the output as a list.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-itemproperty -path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersio
n

Description
-----------
This command displays the value name and data of each of the registry entri
es contained in the CurrentVersion registry subkey. Note that the command r
equires that there is a Windows PowerShell drive named HKLM: that is mapped
to the HKEY_LOCAL_MACHINE hive of the registry. A drive with that name and
mapping is available in Windows PowerShell by default. Alternatively, the
path to this registry subkey can be specified by using the following altern
ative path that begins with the provider name followed by two colons:
Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-itemproperty -path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersio
n `
-name "ProgramFilesDir"

Description
-----------
This command gets the value name and data of the ProgramFilesDir registry e
ntry in the CurrentVersion registry subkey. The command uses the Path param
eter to specify the subkey and the Name parameter to specify the value name
of the entry.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-itemproperty -path HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShe
llEngine

ApplicationBase : C:\Windows\system32\WindowsPowerShell\v1.0\
ConsoleHostAssemblyName : Microsoft.PowerShell.ConsoleHost, Version=1.0.0.0
, Culture=neutral, PublicKeyToken=31bf3856ad
364e35, ProcessorArchitecture=msil
PowerShellVersion : 2.0
RuntimeVersion : v2.0.50727
CTPVersion : 5
PSCompatibleVersion : 1.0,2.0

Description
-----------
This command gets the value names and data of the registry entries in the
PowerShellEngine registry key. The results are shown in the following sampl
e output.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-itemproperty -path HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds
\Microsoft.PowerShell

Path ExecutionPolicy
---- ---------------
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe RemoteSigned


C:\PS>get-itemproperty -path HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds
\Microsoft.PowerShell | format-list -property *

PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\So
ftware\Microsoft\PowerShell\1\ShellIds\Micro
soft.PowerShell
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\So
ftware\Microsoft\PowerShell\1\ShellIds
PSChildName : Microsoft.PowerShell
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
Path : C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
ExecutionPolicy : RemoteSigned

Description
-----------
This example shows how to format the output of a Get-ItemProperty command i
n a list to make it easy to see the registry values and data and to make it
easy to interpret the results.

The first command uses the Get-ItemProperty cmdlet to get the registry entr
ies in the Microsoft.PowerShell subkey. This subkey stores options for the
default shell for Windows PowerShell. The results are shown in the followin
g sample output.

The output shows that there are two registry entries, Path and ExecutionPol
icy. When a registry key contains fewer than five entries, by default it is
displayed in a table, but it is often easier to view in a list.

The second command uses the same Get-ItemProperty command. However, this ti
me, the command uses a pipeline operator (|) to send the results of the com
mand to the Format-List cmdlet. The Format-List command uses the Property p
arameter with a value of * (all) to display all of the properties of the ob
jects in a list. The results are shown in the following sample output.

The resulting display shows the Path and ExecutionPolicy registry entries,
along with several less familiar properties of the registry key object. The
other properties, prefixed with "PS", are properties of Windows PowerShell
custom objects, such as the objects that represent the registry keys.




REMARKS
To see the examples, type: "get-help Get-ItemProperty -examples".
For more information, type: "get-help Get-ItemProperty -detailed".
For technical information, type: "get-help Get-ItemProperty -full".

NAME
Get-Job

SYNOPSIS
Gets Windows PowerShell background jobs that are running in the current ses
sion.


SYNTAX
Get-Job [-Command <string[]>] [<CommonParameters>]

Get-Job [[-InstanceId] <Guid[]>] [<CommonParameters>]

Get-Job [[-Name] <string[]>] [<CommonParameters>]

Get-Job [[-Id] <Int32[]>] [<CommonParameters>]

Get-Job [-State {NotStarted | Running | Completed | Failed | Stopped | Bloc
ked}] [<CommonParameters>]


DESCRIPTION
The Get-Job cmdlet gets objects that represent the background jobs that wer
e started in the current session. You can use Get-Job to get jobs that were
started by using Start-Job, or by using the AsJob parameter of any cmdlet.


Without parameters, a "Get-Job" command gets all jobs in the current sessio
n. You can use the parameters of Get-Job to get particular jobs.

The job object that Get-Job returns contains useful information about the j
ob, but it does not contain the job results. To get the results, use the Re
ceive-Job cmdlet.

A Windows PowerShell background job is a command that runs "in the backgrou
nd" without interacting with the current session. Typically, you use a back
ground job to run a complex command that takes a long time to complete. For
more information about background jobs in Windows PowerShell, see about_Jo
bs.

PARAMETERS
-Command <string[]>
Gets the jobs that include the specified command. The default is all jo
bs. Enter a command (as a string). You can use wildcards to specify a c
ommand pattern.

-Id <Int32[]>
Gets only jobs with the specified IDs.

The ID is an integer that uniquely identifies the job within the curren
t session. It is easier to remember and to type than the instance ID, b
ut it is unique only within the current session. You can type one or mo
re IDs (separated by commas). To find the ID of a job, type "Get-Job" w
ithout parameters.

-InstanceId <Guid[]>
Gets jobs with the specified instance IDs. The default is all jobs.

An instance ID is a GUID that uniquely identifies the job on the comput
er. To find the instance ID of a job, use Get-Job.

-Name <string[]>
Gets the job with the specified friendly names. Enter a job name, or us
e wildcard characters to enter a job name pattern. By default, Get-Job
gets all jobs in the current session.

-State <JobState>
Gets only jobs in the specified state. Valid values are NotStarted, Run
ning, Completed, Stopped, Failed, and Blocked. By default, Get-Job gets
all the jobs in the current session.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-job

Description
-----------
This command gets all background jobs started in the current session. It do
es not include jobs created in other sessions, even if the jobs run on the
local computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$j = get-job -name Job1

C:\PS> $ID = $j.InstanceID

C:\PS> $ID

Guid
----
03c3232e-1d23-453b-a6f4-ed73c9e29d55

C:\PS> stop-job -instanceid $ID

Description
-----------
These commands show how to get the instance ID of a job and then use it to
stop a job. Unlike the name of a job, which is not unique, the instance ID
is unique.

The first command uses the Get-Job cmdlet to get a job. It uses the Name pa
rameter to identify the job. The command stores the job object that Get-Job
returns in the $j variable. In this example, there is only one job with th
e specified name.

The second command gets the InstanceId property of the object in the $j var
iable and stores it in the $ID variable.

The third command displays the value of the $ID variable.

The fourth command uses Stop-Job cmdlet to stop the job. It uses the Instan
ceId parameter to identify the job and $ID variable to represent the instan
ce ID of the job.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-job -command "*get-process*"

Description
-----------
This command gets the jobs on the system that include a Get-Process command
. The command uses the Command parameter of Get-Job to limit the jobs retri
eved. The command uses wildcard characters (*) to get jobs that include a G
et-Process command anywhere within the command string.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>"*get-process*" | get-job

Description
-----------
Like the command in the previous example, this command gets the jobs on th
e system that include a Get-Process command. The command uses a pipeline op
erator (|) to send a string (in double quotation marks) to the Get-Job cmdl
et. It is the equivalent of the previous command.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-job -state NotStarted

Description
-----------
This command gets only those jobs that have been created but have not yet b
een started. This includes jobs that are scheduled to run in the future and
those not yet scheduled.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-job -name job*

Description
-----------
This command gets all jobs that have job names beginning with "job". Becaus
e "job<number>" is the default name for a job, this command gets all jobs t
hat do not have an explicitly assigned name.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>start-job -scriptblock {get-process} -name MyJob

C:\PS> $j = get-job -name MyJob

C:\PS> $j

Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
1 myjob Completed True localhost get-process

C:\PS> receive-job -job $j

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
124 4 13572 12080 59 1140 audiodg
783 16 11428 13636 100 548 CcmExec
96 4 4252 3764 59 3856 ccmsetup
...

Description
-----------
This example shows how to use Get-Job to get a job object, and then it show
s how to use the job object to represent the job in a command.

The first command uses the Start-Job cmdlet to start a background job that
runs a Get-Process command on the local computer. The command uses the Name
parameter of Start-Job to assign a friendly name to the job.

The second command uses Get-Job to get the job. It uses the Name parameter
of Get-Job to identify the job. The command saves the resulting job object
in the $j variable.

The third command displays the value of the job object in the $j variable.
The value of the State property shows that the job is complete. The value o
f the HasMoreData property shows that there are results available from the
job that have not yet been retrieved.

The fourth command uses the Receive-Job cmdlet to get the results of the jo
b. It uses the job object in the $j variable to represent the job. You can
also use a pipeline operator to send a job object to Receive-Job.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>start-job -scriptblock {get-eventlog system}

C:\PS> invoke-command -computername S1 -scriptblock {get-eventlog system} -
AsJob

C:\PS> invoke-command -computername S2 -scriptblock {start-job -scriptblock
{get-eventlog system}}

C:\PS> get-job

Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
1 Job1 Running True localhost get-eventlog system
2 Job2 Running True S1 get-eventlog system

C:\PS> invoke-command -computername S2 -scriptblock {get-job}

Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
4 Job4 Running True localhost get-eventlog system

Description
-----------
This example demonstrates that the Get-Job cmdlet can get all of the jobs t
hat were started in the current session, even if they were started by using
different methods.

The first command uses the Start-Job cmdlet to start a job on the local com
puter.

The second command uses the AsJob parameter of Invoke-Command to start a jo
b on the S1 computer. Even though the commands in the job run on the remote
computer, the job object is created on the local computer, so you use loca
l commands to manage the job.

The third command uses the Invoke-Command cmdlet to run a Start-Job command
on the S2 computer. With this method, the job object is created on the rem
ote computer, so you use remote commands to manage the job.

The fourth command uses Get-Job to get the jobs stored on the local compute
r.

The fifth command uses Invoke-Command to run a Get-Job command on the S2 co
mputer.

The sample output shows the results of the Get-Job commands.

For more information about running background jobs on remote computers, see
about_Remote_Jobs.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>start-job -scriptblock {get-process}

Id Name State HasMoreData Location Co
mmand
-- ---- ----- ----------- -------- --
-----
1 Job1 Failed False localhost ge
t-process

C:\PS> (get-job).jobstateinfo | format-list -property *

State : Failed
Reason :


C:\PS> get-job | format-list *

HasMoreData : False
StatusMessage :
Location : localhost
Command : get-process
JobStateInfo : Failed
Finished : System.Threading.ManualResetEvent
InstanceId : fb792295-1318-4f5d-8ac8-8a89c5261507
Id : 1
Name : Job1
ChildJobs : {Job2}
Output : {}
Error : {}
Progress : {}
Verbose : {}
Debug : {}
Warning : {}
StateChanged :


C:\PS> (get-job -name job2).jobstateinfo.reason
Connecting to remote server using WSManCreateShellEx api failed. The async
callback gave the following error message :
Access is denied.

Description
-----------
This command shows how to use the job object that Get-Job returns to invest
igate why a job failed. It also shows how to get the child jobs of each job
.

The first command uses the Start-Job cmdlet to start a job on the local com
puter. The job object that Start-Job returns shows that the job failed. The
value of the State property is "Failed".

The second command uses Get-Job to get the job object. The command uses the
dot method to get the value of the JobStateInfo property of the object. It
uses a pipeline operator to send the object in the JobStateInfo property t
o the Format-List cmdlet, which formats all of the properties of the object
(*) in a list.

The result of the Format-List command shows that the value of the Reason pr
operty of the job is blank.

The third command investigates further. It uses a Get-Job command to get th
e job and then uses a pipeline operator to send the entire job object to th
e Format-List cmdlet, which displays all of the properties of the job in a
list.

The display of all properties in the job object shows that the job contains
a child job named "Job2".

The fourth command uses Get-Job to get the job object that represents the J
ob2 child job. This is the job in which the command actually ran. It uses t
he dot method to get the Reason property of the JobStateInfo property.

The result shows that the job failed because of an "access denied" error. I
n this case, the user forgot to use the "Run as administrator" option when
opening Windows PowerShell.

Because background jobs use the remoting features of Windows PowerShell, th
e computer must be configured for remoting to run a job, even when the job
runs on the local computer.

For information about requirements for remoting in Windows PowerShell, see
about_Remote_Requirements. For troubleshooting tips, see about_Remote_Troub
leshooting.




REMARKS
To see the examples, type: "get-help Get-Job -examples".
For more information, type: "get-help Get-Job -detailed".
For technical information, type: "get-help Get-Job -full".

NAME
Get-Location

SYNOPSIS
Gets information about the current working location.


SYNTAX
Get-Location [-PSDrive <string[]>] [-PSProvider <string[]>] [-UseTransactio
n] [<CommonParameters>]

Get-Location [-Stack] [-StackName <string[]>] [-UseTransaction] [<CommonPar
ameters>]


DESCRIPTION
The Get-Location cmdlet gets an object that represents the current director
y, much like the pwd (print working directory) command.

When you move between Windows PowerShell drives, Windows PowerShell retains
your location in each drive. You can use Get-Location to find your locatio
n in each drive.

You can also use Get-Location to get the current directory at run time and
use it in functions and scripts, such as in a function that displays the cu
rrent directory in the Windows PowerShell prompt.

If you use the Push-Location cmdlet to add locations to a path stack, you c
an use the Stack parameter of Get-Location to display the current stack.

PARAMETERS
-PSDrive <string[]>
Gets the current location in the specified Windows PowerShell drive.

For example, if you are in the Certificate: drive, you can use this par
ameter to find your current location in the C: drive.

-PSProvider <string[]>
Gets the current location in the drive supported by the specified Windo
ws PowerShell provider.

If the specified provider supports more than one drive, Get-Location re
turns the location on the most recently accessed drive.

For example, if you are in the C: drive, you can use this parameter to
find your current location in the drives of the Windows PowerShell Regi
stry provider.

-Stack [<SwitchParameter>]
Displays the locations in the default path stack.

To add paths to the default stack, use the Push-Location cmdlet.

-StackName <string[]>
Displays the locations in the specified path stacks.

To create path stacks, use the Push-Location cmdlet.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-location

Path
----
C:\WINDOWS

Description
-----------
This command displays your location in the current Windows PowerShell drive
.

For example, if you are in the Windows directory of the C: drive, it displa
ys the path to that directory.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>set-location

Description
-----------
These commands demonstrate the use of Get-Location to display your current
location in different Windows PowerShell drives.

The first command uses the Set-Location cmdlet to set the current location
to the Windows subdirectory of the C: drive.

C:\PS> set-location C:\Windows

The second command uses the Set-Location cmdlet to change the location to t
he HKLM:\Software\Microsoft registry key. When you change to a location in
the HKLM: drive, Windows PowerShell retains your location in the C: drive.

PS C:\WINDOWS> set-location HKLM:\Software\Microsoft
PS HKLM:\Software\Microsoft>

The third command uses the Set-Location cmdlet to change the location to th
e "HKCU:\Control Panel\Input Method" registry key.

PS HKLM:\Software\Microsoft> set-location 'HKCU:\Control Panel\Input Me
thod'
PS HKCU:\Control Panel\Input Method>

The fourth command uses the Get-Location cmdlet to find the current locatio
n on the C: drive. It uses the PSDrive parameter to specify the drive.

PS HKCU:\Control Panel\Input Method> get-location -psdrive c
Path
----
C:\WINDOWS

The fifth command uses the Set-Location cmdlet to return to the C: drive. E
ven though the command does not specify a subdirectory, Windows PowerShell
returns you to the saved location.

PS HKCU:\Control Panel\Input Method> set-location C:
PS C:\WINDOWS>

The sixth command uses the Get-Location cmdlet to find the current location
in the drives supported by the Windows PowerShell registry provider. Get-L
ocation returns the location of the most recently accessed registry drive,
HKCU:.

PS C:\WINDOWS> get-location -psprovider registry
Path
----
HKCU:\Control Panel\Input Method

To see the current location in the HKLM: drive, you need to use the PSDrive
parameter to specify the drive. The seventh command does just this:

PS C:\WINDOWS> get-location -psdrive HKLM
Path
----
HKLM:\Software\Microsoft




-------------------------- EXAMPLE 3 --------------------------

C:\PS>set-location

Description
-----------
These commands show how to use the Stack and StackName parameters of Get-Lo
cation to list the paths in the default and alternate path stacks.

The first command sets the current location to the Windows directory on the
C: drive.

C:\PS> set-location C:\Windows

The second command uses the Push-Location cmdlet to push the current locati
on (C:\Windows) onto the path stack and change to the System32 subdirectory
. Because no stack is specified, the current location is pushed onto the de
fault stack.
C:\WINDOWS>push-location System32

The third command pushes the current location (C:\Windows\System32) onto th
e Stack2 stack and changes the location to the WindowsPowerShell subirector
y.

C:\Windows\System32>push-location WindowsPowerShell -stack Stack2

The fourth command uses the Get-Location cmdlet to get the paths on the def
ault path stack.

C:\WINDOWS\system32\WindowsPowerShell>get-location -stack

Path
----
C:\WINDOWS

The last command uses the StackName parameter of Get-Location to get the pa
ths on the Stack2 stack.

C:\WINDOWS\system32\WindowsPowerShell>get-location -stackname Stack2

Path
----
C:\WINDOWS\system32




-------------------------- EXAMPLE 4 --------------------------

C:\PS>function prompt { 'PowerShell: ' + (get-location) + '> '}

PowerShell: C:\WINDOWS>

Description
-----------
This example shows how to customize the Windows PowerShell prompt. The func
tion that defines the prompt includes a Get-Location command, which is run
whenever the prompt appears in the console.

The format of the default Windows PowerShell prompt is defined by a special
function called "prompt". You can change the prompt in your console by cre
ating a new function called "prompt".

To see the current prompt function, type the following command:

get-content function:prompt

The command begins with the "function" keyword followed by the function nam
e, "prompt". The function body appears within braces ( {} ).

This command defines a new prompt that begins with the string "PowerShell:
". To append the current location, it uses a Get-Location command, which ru
ns when the prompt function is called. The prompt ends with the string "> "
.




REMARKS
To see the examples, type: "get-help Get-Location -examples".
For more information, type: "get-help Get-Location -detailed".
For technical information, type: "get-help Get-Location -full".

NAME
Get-Member

SYNOPSIS
Gets the properties and methods of objects.


SYNTAX
Get-Member [[-Name] <string[]>] [-Force] [-InputObject <psobject>] [-Member
Type {AliasProperty | CodeProperty | Property | NoteProperty | ScriptProper
ty | Properties | PropertySet | Method | CodeMethod | ScriptMethod | Method
s | ParameterizedProperty | MemberSet | Event | All}] [-Static] [-View {Ext
ended | Adapted | Base | All}] [<CommonParameters>]


DESCRIPTION
The Get-Member cmdlet gets the "members" (properties and methods) of object
s.

To specify the object, use the InputObject parameter or pipe an object to G
et-Member. To retrieve information about static members (members of the cla
ss, not of the instance), use the Static parameter. To get only certain typ
es of members, such as NoteProperties, use the MemberType parameter.

PARAMETERS
-Force [<SwitchParameter>]
Adds the intrinsic members (PSBase, PSAdapted, PSObject, PSTypeNames) a
nd the compiler-generated get_ and set_ methods to the display. By defa
ult, Get-Member gets these properties in all views other than "Base" an
d "Adapted," but it does not display them.

The following list describes the properties that are added when you use
the Force parameter:

-- PSBase: The original properties of the .NET Framework object withou
t extension or adaptation. These are the properties defined for the obj
ect class and listed in MSDN.
-- PSAdapted: The properties and methods defined in the Windows PowerSh
ell extended type system.
-- PSExtended: The properties and methods that were added in the Types.
ps1xml files or by using the Add-Member cmdlet.
-- PSObject: The adapter that converts the base object to a Windows Pow
erShell PSObject object.
-- PSTypeNames: A list of object types that describe the object, in ord
er of specificity. When formatting the object, Windows PowerShell searc
hes for the types in the Format.ps1xml files in the Windows PowerShell
installation directory ($pshome). It uses the formatting definition for
the first type that it finds.

-InputObject <psobject>
Specifies the object whose members are retrieved.

Using the InputObject parameter is not the same as piping an object to
Get-Member. The differences are as follows:

-- When you pipe a collection of objects to Get-Member, Get-Member gets
the members of the individual objects in the collection, such as the p
roperties of the integers in an array of integers.

-- When you use InputObject to submit a collection of objects, Get-Memb
er gets the members of the collection, such as the properties of the ar
ray in an array of integers.

-MemberType <PSMemberTypes>
Gets only members with the specified member type. The default is All.

The valid values for this parameter are:

-- AliasProperty: A property that defines a new name for an existing pr
operty.
-- CodeMethod: A method that references a static method of a .NET Frame
work class.
-- CodeProperty: A property that references a static property of a .NET
Framework class.
-- Event: Indicates that the object sends a message to indicate an act
ion or a change in state.
-- MemberSet: A predefined collection of properties and methods, such a
s PSBase, PSObject, and PSTypeNames.
-- Method: A method of the underlying .NET Framework object.
-- NoteProperty: A property with a static value.
-- ParameterizedProperty: A property that takes parameters and paramete
r values.
-- Property: A property of the underlying .NET Framework object.
-- PropertySet: A predefined collection of object properties.
-- ScriptMethod: A method whose value is the output of a script.
-- ScriptProperty: A property whose value is the output of a script.

-- All: Gets all member types.
-- Methods: Gets all types of methods of the object (for example, Metho
d, CodeMethod, ScriptMethod).
-- Properties: Gets all types of properties of the object (for example,
Property, CodeProperty, AliasProperty, ScriptProperty).

Not all objects have every type of member. If you specify a member type
that the object does not have, Windows PowerShell returns a null value
.

To get related types of members, such as all extended members, use the
View parameter. If you use the MemberType parameter with the Static or
View parameters, Get-Member gets the members that belong to both sets.

-Name <string[]>
Specifies the names of one or more properties or methods of the object.
Get-Member gets only the specified properties and methods.

If you use the Name parameter with the MemberType, View, or Static para
meters, Get-Member gets only the members that satisfy the criteria of a
ll parameters.

To get a static member by name, use the Static parameter with the Name
parameter.

-Static [<SwitchParameter>]
Gets only the static properties and methods of the object.

Static properties and methods are defined on the class of objects, not
on any particular instance of the class.

If you use the Static parameter with the View parameter, the View param
eter is ignored. If you use the Static parameter with the MemberType pa
rameter, Get-Member gets only the members that belong to both sets.

-View <PSMemberViewTypes>
Gets only particular types of members (properties and methods). Specify
one or more of the values. The default is "Adapted, Extended".

Valid values are:
-- Base: Gets only the original properties and methods of the .NET Fra
mework object (without extension or adaptation).
-- Adapted: Gets only the properties and methods defined in the Window
s PowerShell extended type system.
-- Extended: Gets only the properties and methods that were added in th
e Types.ps1xml files or by using the Add-Member cmdlet.
-- All: Gets the members in the Base, Adapted, and Extended views.

The View parameter determines the members retrieved, not just the displ
ay of those members.

To get particular member types, such as script properties, use the Memb
erType parameter. If you use the MemberType and View parameters in the
same command, Get-Member gets the members that belong to both sets. If
you use the Static and View parameters in the same command, the View pa
rameter is ignored.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-service | get-member


TypeName: System.ServiceProcess.ServiceController

Name MemberType Definition
---- ---------- ----------
Name AliasProperty Name = ServiceName
Close Method System.Void Close()
Continue Method System.Void Continue()
CreateObjRef Method System.Runtime.Remoting.ObjRef Crea
teObjRef(Type requestedType)
Dispose Method System.Void Dispose()
Equals Method System.Boolean Equals(Object obj)
ExecuteCommand Method System.Void ExecuteCommand(Int32 co
mmand)
GetHashCode Method System.Int32 GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetType Method System.Type GetType()
InitializeLifetimeService Method System.Object InitializeLifetimeSer
vice()
Pause Method System.Void Pause()
Refresh Method System.Void Refresh()
Start Method System.Void Start(), System.Void St
art(String[] args)
Stop Method System.Void Stop()
ToString Method System.String ToString()
WaitForStatus Method System.Void WaitForStatus(ServiceCo
ntrollerStatus desiredStatus), System.Voi...
CanPauseAndContinue Property System.Boolean CanPauseAndContinue
{get;}
CanShutdown Property System.Boolean CanShutdown {get;}
CanStop Property System.Boolean CanStop {get;}
Container Property System.ComponentModel.IContainer Co
ntainer {get;}
DependentServices Property System.ServiceProcess.ServiceContro
ller[] DependentServices {get;}
DisplayName Property System.String DisplayName {get;set;
}
MachineName Property System.String MachineName {get;set;
}
ServiceHandle Property System.Runtime.InteropServices.Safe
Handle ServiceHandle {get;}
ServiceName Property System.String ServiceName {get;set;
}
ServicesDependedOn Property System.ServiceProcess.ServiceContro
ller[] ServicesDependedOn {get;}
ServiceType Property System.ServiceProcess.ServiceType S
erviceType {get;}
Site Property System.ComponentModel.ISite Site {g
et;set;}
Status Property System.ServiceProcess.ServiceContro
llerStatus Status {get;}

Description
-----------
This command displays the properties and methods of the process objects (Sy
stem.ServiceProcess.ServiceController) that are generated by the Get-Servic
e cmdlet.

The command uses the pipeline operator (|) to send the output of a Get-Serv
ice command to Get-Member.

Because the Get-Member part of the command does not have any parameters, it
uses all of the default values. As such, it gets all member types, but it
does not get static members and does not display intrinsic members.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-service | get-member -force

C:\PS> (get-service -schedule).psbase

Description
-----------
This example gets all of the members (properties and methods) of the servic
e objects (System.ServiceProcess.ServiceController) retrieved by the Get-Se
rvice cmdlet, including the intrinsic members, such as PSBase and PSObject,
and the get_ and set_ methods.

The first command uses the Get-Service cmdlet to get objects that represent
the services on the system. It uses a pipeline operator (|) to pass the se
rvice objects to the Get-Member cmdlet.

The Get-Member command uses the Force parameter to add the intrinsic member
s and compiler-generated members of the objects to the display. Get-Member
gets these members, but it hides them by default.

You can use these properties and methods in the same way that you would use
an adapted method of the object. The second command shows how to display t
he value of the PSBase property of the Schedule service.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-service | get-member -view extended

TypeName: System.ServiceProcess.ServiceController

Name MemberType Definition
---- ---------- ----------
Name AliasProperty Name = ServiceName

Description
-----------
This command gets the methods and properties of service objects that were e
xtended by using the Types.ps1xml file or the Add-Member cmdlet.


The Get-Member command uses the View parameter to get only the extended mem
bers of the service objects. In this case, the extended member is the Name
property, which is an alias property of the ServiceName property.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-eventlog -log system | gm -membertype scriptproperty

TypeName: System.Diagnostics.EventLogEntry

Name MemberType Definition
---- ---------- ----------
EventID ScriptProperty System.Object EventID {get=$this.get_EventID() -band
0xFFFF;}

Description
-----------
This command gets the script properties of event log objects in the System
log in Event Viewer. In this case, the only script property is the EventID.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-eventlog -log system | get-member -membertype scriptproperty


TypeName: System.Diagnostics.EventLogEntry

Name MemberType Definition
---- ---------- ----------
EventID ScriptProperty System.Object EventID {get=$this.get_EventID() -band
0xFFFF;}

Description
-----------
This command gets the script properties of event log objects in the System
log in Event Viewer.

The command uses the MemberType parameter to get only objects with a value
of AliasProperty for their MemberType property.

The command returns the EventID property of the EventLog object.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>$a = "get-process", "get-service", "get-culture", "get-psdrive", "get
-executionpolicy"

C:\PS> foreach ($cmdlet in $a) {invoke-expression $cmdlet | get-member -nam
e machinename}

TypeName: System.Diagnostics.Process

Name MemberType Definition
---- ---------- ----------
MachineName Property System.String MachineName {get;}


TypeName: System.ServiceProcess.ServiceController

Name MemberType Definition
---- ---------- ----------
MachineName Property System.String MachineName {get;set;}

Description
-----------
This command gets objects that have a MachineName property from a list of c
mdlets.

The first command stores the names of several cmdlets in the $a variable.

The second command uses a ForEach statement to invoke each command, send th
e results to Get-Member, and limit the results from Get-Member to members t
hat have the name "MachineName."

The results show that only process objects (System.Diagnostics.Process) and
service objects (System.ServiceProcess.ServiceController) have a MachineNa
me property.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>$a = get-member -inputobject @(1)

C:\PS>$a.count

1

C:\PS> $a = get-member -inputobject 1,2,3

TypeName: System.Object[]
Name MemberType Definition
---- ---------- ----------
Count AliasProperty Count = Length
Address Method System.Object& Address(Int32 )
Clone Method System.Object Clone()
...

C:\PS>$a.count
1

Description
-----------
This example demonstrates how to find the properties and methods of an arra
y of objects when you have only one object of the given type.

Because the goal of the command is to find the properties of an array, the
first command uses the InputObject parameter. It uses the "at" symbol (@) t
o indicate an array. In this case, the array contains only one object, the
integer 1.

The third command uses the Get-Member cmdlet to get the properties and meth
ods of an array of integers, and the command saves them in the $a variable.

The fourth command uses the Count property of the array to find the number
of objects in the $a variable.




REMARKS
To see the examples, type: "get-help Get-Member -examples".
For more information, type: "get-help Get-Member -detailed".
For technical information, type: "get-help Get-Member -full".

NAME
Get-Module

SYNOPSIS
Gets the modules that have been imported or that can be imported into the c
urrent session.


SYNTAX
Get-Module [-All] [-ListAvailable] [-Name <string[]>] [<CommonParameters>]

Get-Module [[-Name] <string[]>] [<CommonParameters>]


DESCRIPTION
The Get-Module cmdlet gets the modules that have been imported, or that can
be imported, into the session.

Get-Module only gets modules; it does not import them. To import the module
s into your session, use Import-Module.

PARAMETERS
-All [<SwitchParameter>]
Gets module objects for all module files.

Without the All parameter, Get-Module gets only the module object for t
he default module file. The cmdlet selects file types in the following
order: manifest (.psd1) files, script module (.psm1) files, and binary
module (.dll) files.

-ListAvailable [<SwitchParameter>]
Gets all of the modules that can be imported into the session. Get-Modu
le gets the modules in the paths specified by the $env:PSModulePath env
ironment variable.

Without this parameter, Get-Module gets only the modules that have been
imported into the session.

-Name <string[]>
Gets only modules with the specified names or name patterns. Wildcards
are permitted. You can also pipe the names to Get-Module.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-module

Description
-----------
This command gets the modules that have been imported into the current sess
ion.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-module -listAvailable

Description
-----------
This command gets the modules that can be imported into the current session
.

Get-Module looks for available modules in the path specified by the $env:PS
ModulePath environment variable. For more information about PSModulePath, s
ee about_Modules and about_Environment_Variables.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-module -listAvailable -all

Description
-----------
This command gets all of the exported files for all available modules.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-module | get-member -type property

TypeName: System.Management.Automation.PSModuleInfo

Name MemberType Definition
---- ---------- ----------
AccessMode Property System.Management.Automation.ModuleAcc
Description Property System.String Description {get;set;}
ExportedAliases Property System.Collections.Generic.Dictionary`
ExportedCmdlets Property System.Collections.Generic.Dictionary`
ExportedFunctions Property System.Collections.Generic.Dictionary`
ExportedVariables Property System.Collections.Generic.Dictionary`
Guid Property System.Guid Guid {get;}
ModuleBase Property System.String ModuleBase {get;}
ModuleType Property System.Management.Automation.ModuleTyp
Name Property System.String Name {get;}
NestedModules Property System.Collections.ObjectModel.ReadOnl
OnRemove Property System.Management.Automation.ScriptBlo
Path Property System.String Path {get;}
PrivateData Property System.Object PrivateData {get;set;}
SessionState Property System.Management.Automation.SessionSt
Version Property System.Version Version {get;}

Description
-----------
This command get the properties of the PSModuleInfo object that Get-Module
returns. There is one object for each module file.

You can use the properties to format and filter the module objects. For mor
e information about the properties, see "PSModule Properties" in the MSDN (
Microsoft Developer Network) library at http://go.microsoft.com/fwlink/?Lin
kId=143624.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-module -listAvailable -all | format-table -property name, modulet
ype, path -groupby name -auto

Name: MyTestCmdlets

Name ModuleType Path
---- ---------- ----
MyTestCmdlets Script C:\Windows\system32\WindowsPowerShell\v1.0\Modules
\TestCmdlets\TestCmdlets.dll


Name: PSDiagnostics

Name ModuleType Path
---- ---------- ----
PSDiagnostics Manifest C:\Windows\system32\WindowsPowerShell\v1.0\Modules
\PSDiagnostics\PSDiagnostics.psd1
PSDiagnostics Script C:\Windows\system32\WindowsPowerShell\v1.0\Modules
\PSDiagnostics\PSDiagnostics.psm1


Name: FileTransfer

Name ModuleType Path
---- ---------- ----
FileTransfer Manifest C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
FileTransfer\FileTransfer.psd1

Description
-----------
This command gets all module files (imported and available) and groups them
by module name. This lets you see the module files that each script is exp
orting.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>$m = get-module -list -name FileTransfer | where {$_.moduletype -eq "
Manifest"}

C:\PS> get-content $m.path

@{
GUID="{8FA5064B-8479-4c5c-86EA-0D311FE48875}"
Author="Microsoft Corporation"
CompanyName="Microsoft Corporation"
Copyright="© Microsoft Corporation. All rights reserved."
ModuleVersion="1.0.0.0"
Description="Windows Powershell File Transfer Module"
PowerShellVersion="2.0"
CLRVersion="2.0"
NestedModules="Microsoft.BackgroundIntelligentTransfer.Management"
FormatsToProcess="FileTransfer.Format.ps1xml"
RequiredAssemblies=Join-Path $psScriptRoot "Microsoft.BackgroundIntelligent
Transfer.Management.Interop.dll"
}

Description
-----------
These commands display the contents of the module manifest for the Windows
PowerShell File Transfer module.

The first command gets the PSModuleInfo object that represent the module ma
nifest for the File Transfer module. It saves the object in the $m variable
.

The second command uses dot notation to get the path to the manifest file,
which is stored in the Path property of the object. Then, it uses the Get-C
ontent cmdlet to get the content of the manifest file in the specified path
.

Modules are not required to have manifest files. When they do have a manife
st file, a manifest is required only to include a version number. However,
manifest files often provide useful information about a module, its require
ments, and its contents.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-module -listAvailable -name FileTransfer | format-list -property
*

Name : FileTransfer
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\File
Transfer\FileTransfer.psd1
Description : Powershell File Transfer Module
Guid : 8fa5064b-8479-4c5c-86ea-0d311fe48875
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\File
Transfer
PrivateData :
Version : 1.0.0.0
ModuleType : Manifest
AccessMode : ReadWrite
ExportedFunctions : {}
ExportedCmdlets : {}
NestedModules : {}
ExportedVariables : {}
ExportedAliases : {}
SessionState : System.Management.Automation.SessionState
OnRemove :

Description
-----------
This command displays all of the properties of the FileTransfer module in a
list.

Because the module has not yet been imported into the session, the Exported
* properties and the NestedModules property are not yet populated. These pr
operties are populated only after the elements have been exported and the n
ested modules have been instantiated.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>dir (get-module -listavailable FileTransfer).modulebase

Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FileTrans
fer


Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/16/2008 12:36 PM en-US
-a--- 11/19/2008 11:30 PM 16184 FileTransfer.Format.ps1xml
-a--- 11/20/2008 11:30 PM 1044 FileTransfer.psd1
-a--- 12/16/2008 12:20 AM 108544 Microsoft.BackgroundIntelligen
tTransfer.Management.Interop.dll

Description
-----------
This command lists the files in the module's directory. This is another way
to determine what is in a module before you import it. Some modules might
have help files or ReadMe files that describe the module.




REMARKS
To see the examples, type: "get-help Get-Module -examples".
For more information, type: "get-help Get-Module -detailed".
For technical information, type: "get-help Get-Module -full".

NAME
Get-PfxCertificate

SYNOPSIS
Gets information about .pfx certificate files on the computer.


SYNTAX
Get-PfxCertificate [-FilePath] <string[]> [<CommonParameters>]


DESCRIPTION
The Get-PfxCertificate cmdlet gets an object representing each specified .p
fx certificate file. A .pfx file includes both the certificate and a privat
e key.

PARAMETERS
-FilePath <string[]>
The full path to the .pfx file of the secured file. The parameter name
("FilePath") is optional.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-pfxcertificate -filepath C:\windows\system32\Test.pfx

Password: ******
Signer Certificate: Matt Berg (Self Certificate)
Time Certificate:
Time Stamp:
Path: C:\windows\system32\zap.pfx

Description
-----------
This command gets information about the Test.pfx certificate on the system.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>invoke-command -computername Server01 -scriptblock {get-pfxcertificat
e -filepath C:\Text\TestNoPassword.pfx} -authentication CredSSP

Description
-----------
This command gets a .pfx certificate file from the Server01 remote computer
. It uses the Invoke-Command to run a Get-PfxCertificate command remotely.

When the .pfx certificate file is not password-protected, the value of the
Authentication parameter of Invoke-Command must be "CredSSP".




REMARKS
To see the examples, type: "get-help Get-PfxCertificate -examples".
For more information, type: "get-help Get-PfxCertificate -detailed".
For technical information, type: "get-help Get-PfxCertificate -full".

NAME
Get-Process

SYNOPSIS
Gets the processes that are running on the local computer or a remote compu
ter.


SYNTAX
Get-Process [[-Name] <string[]>] [-ComputerName <string[]>] [-FileVersionIn
fo] [-Module] [<CommonParameters>]

Get-Process -Id <Int32[]> [-ComputerName <string[]>] [-FileVersionInfo] [-M
odule] [<CommonParameters>]

Get-Process -InputObject <Process[]> [-ComputerName <string[]>] [-FileVersi
onInfo] [-Module] [<CommonParameters>]


DESCRIPTION
The Get-Process cmdlet gets the processes on a local or remote computer.

Without parameters, Get-Process gets all of the processes on the local comp
uter. You can also specify a particular process by process name or process
ID (PID) or pass a process object through the pipeline to Get-Process.

By default, Get-Process returns a process object that has detailed informat
ion about the process and supports methods that let you start and stop the
process. You can also use the parameters of Get-Process to get file version
information for the program that runs in the process and to get the module
s that the process loaded.

PARAMETERS
-ComputerName <string[]>
Gets the processes running on the specified computers. The default is t
he local computer.

Type the NetBIOS name, an IP address, or a fully qualified domain name
of one or more computers. To specify the local computer, type the compu
ter name, a dot (.), or "localhost".

This parameter does not rely on Windows PowerShell remoting. You can us
e the ComputerName parameter of Get-Process even if your computer is no
t configured to run remote commands.

-FileVersionInfo [<SwitchParameter>]
Gets the file version information for the program that runs in the proc
ess.

On Windows Vista and later versions of Windows, you must open Windows P
owerShell with the "Run as administrator" option to use this parameter
on processes that you do not own.

Using this parameter is equivalent to getting the MainModule.FileVersio
nInfo property of each process object. When you use this parameter, Get
-Process returns a FileVersionInfo object (System.Diagnostics.FileVersi
onInfo), not a process object. So, you cannot pipe the output of the co
mmand to a cmdlet that expects a process object, such as Stop-Process.

-Id <Int32[]>
Specifies one or more processes by process ID (PID). To specify multipl
e IDs, use commas to separate the IDs. To find the PID of a process, ty
pe "get-process".

-InputObject <Process[]>
Specifies one or more process objects. Enter a variable that contains t
he objects, or type a command or expression that gets the objects.

-Module [<SwitchParameter>]
Gets the modules that have been loaded by the processes.

On Windows Vista and later versions of Windows, you must open Windows P
owerShell with the "Run as administrator" option to use this parameter
on processes that you do not own.

This parameter is equivalent to getting the Modules property of each pr
ocess object. When you use this parameter, Get-Process returns a Proces
sModule object (System.Diagnostics.ProcessModule), not a process object
. So, you cannot pipe the output of the command to a cmdlet that expect
s a process object, such as Stop-Process.

When you use both the Module and FileVersionInfo parameters in the same
command, Get-Process returns a FileVersionInfo object with information
about the file version of all modules.

-Name <string[]>
Specifies one or more processes by process name. You can type multiple
process names (separated by commas) or use wildcard characters. The par
ameter name ("Name") is optional.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>Get-Process

Description
-----------
This command gets a list of all of the running processes running on the loc
al computer. For a definition of each column, see the "Additional Notes" se
ction of the Help topic for Get-Help.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>Get-Process winword, explorer | format-list *

Description
-----------
This command gets all available data about the Winword and Explorer process
es on the computer. It uses the Name parameter to specify the processes, bu
t it omits the optional parameter name. The pipeline operator (|) passes th
e data to the Format-List cmdlet, which displays all available properties (
*) of the Winword and Explorer process objects.

You can also identify the processes by their process IDs. For example, "get
-process -id 664, 2060".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-process | where-object {$_.WorkingSet -gt 20000000}

Description
-----------
This command gets all processes that have a working set greater than 20 MB.
It uses the Get-Process cmdlet to get all running processes. The pipeline
operator (|) passes the process objects to the Where-Object cmdlet, which s
elects only the object with a value greater than 20,000,000 bytes for the W
orkingSet property.

WorkingSet is one of many properties of process objects. To see all of the
properties, type "Get-Process | Get-Member". By default, the values of all
amount properties are in bytes, even though the default display lists them
in kilobytes and megabytes.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$a = get-process

C:\PS> get-process -inputobject $a | format-table -view priority

Description
-----------
These commands list the processes on the computer in groups based on their
priority class.

The first command gets all the processes on the computer and then stores th
em in the $a variable.

The second command uses the InputObject parameter to pass the process objec
ts that are stored in the $a variable to the Get-Process cmdlet. The pipel
ine operator passes the objects to the Format-Table cmdlet, which formats t
he processes by using the Priority view.

The priority view, and other views, are defined in the PS1XML format files
in the Windows PowerShell home directory ($pshome).




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-process powershell -computername S1, localhost | ft @{Label="NPM(
K)";Expression={[int]($_.NPM/1024)}}, @{Label="PM(K)";Expression={[int]($_.
PM/1024)}},@{Label="WS(K)";Expression={[int]($_.WS/1024)}},@{Label="VM(M)";
Expression={[int]($_.VM/1MB)}}, @{Label="CPU(s)";Expression={if ($_.CPU -ne
$()) { $_.CPU.ToString("N")}}}, Id, MachineName, ProcessName -auto


NPM(K) PM(K) WS(K) VM(M) CPU(s) Id MachineName ProcessName
------ ----- ----- ----- ------ -- ----------- -----------
6 23500 31340 142 1980 S1 powershell
6 23500 31348 142 4016 S1 powershell
27 54572 54520 576 4428 localhost powershell

Description
-----------
This example provides a Format-Table (alias = ft) command that adds the Mac
hineName property to the standard Get-Process output display.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-process powershell -fileversioninfo

ProductVersion FileVersion FileName
-------------- ----------- --------
6.1.6713.1 6.1.6713.1 (f... C:\WINDOWS\system32\WindowsPowerShell\v1.
0\powershell.exe

Description
-----------
This command uses the FileVersionInfo parameter to get the version informat
ion for the PowerShell.exe file that is the main module for the PowerShell
process.

To run this command with processes that you do not own on Windows Vista and
later versions of Windows, you must open Windows PowerShell with the "Run
as administrator" option.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-process sql* -module

Description
-----------
This command uses the Module parameter to get the modules that have been lo
aded by the process. This command gets the modules for the processes that h
ave names that begin with "sql".

To run this command on Windows Vista (and later versions of Windows) with p
rocesses that you do not own, you must start Windows PowerShell with the "R
un as administrator" option.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>$p = get-wmiobject win32_process -filter "name='powershell.exe'"

C:\PS> $p.getowner()

__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 3
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
Domain : DOMAIN01
ReturnValue : 0
User : user01

Description
-----------
This command shows how to find the owner of a process. Because the System.D
iagnostics.Process object that Get-Process returns does not have a property
or method that returns the process owner, the command uses
the Get-WmiObject cmdlet to get a Win32_Process object that represents the
same process.

The first command uses Get-WmiObject to get the PowerShell process. It save
s it in the $p variable.

The second command uses the GetOwner method to get the owner of the process
in $p. The command reveals that the owner is Domain01\user01.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>get-process powershell

C:\PS> get-process -id $pid

C:\PS> get-process powershell

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
308 26 52308 61780 567 3.18 5632 powershell
377 26 62676 63384 575 3.88 5888 powershell


C:\PS> get-process -id $pid

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
396 26 56488 57236 575 3.90 5888 powershell

Description
-----------
These commands show how to use the $pid automatic variable to identify the
process that is hosting the current Windows PowerShell session. You can use
this method to distinguish the host process from other PowerShell processe
s that you might want to stop or close.

The first command gets all of the PowerShell processes in the current sessi
on.

The second command gets the PowerShell process that is hosting the current
session.




REMARKS
To see the examples, type: "get-help Get-Process -examples".
For more information, type: "get-help Get-Process -detailed".
For technical information, type: "get-help Get-Process -full".

NAME
Get-PSBreakpoint

SYNOPSIS
Gets the breakpoints that are set in the current session.


SYNTAX
Get-PSBreakpoint [[-Script] <string[]>] [<CommonParameters>]

Get-PSBreakpoint -Command <string[]> [-Script <string[]>] [<CommonParameter
s>]

Get-PSBreakpoint [-Id] <Int32[]> [<CommonParameters>]

Get-PSBreakpoint [-Type] <BreakpointType[]> [-Script <string[]>] [<CommonPa
rameters>]

Get-PSBreakpoint -Variable <string[]> [-Script <string[]>] [<CommonParamete
rs>]


DESCRIPTION
The Get-PSBreakPoint cmdlet gets the breakpoints that are set in the curren
t session. You can use the cmdlet parameters to get particular breakpoints.

A breakpoint is a point in a command or script where execution stops tempor
arily so that you can examine the instructions. Get-PSBreakpoint is one of
several cmdlets designed for debugging Windows PowerShell scripts and comma
nds. For more information about the Windows PowerShell debugger, see about_
Debuggers.

PARAMETERS
-Command <string[]>
Gets command breakpoints that are set on the specified command names. E
nter the command names, such as the name of a cmdlet or function.

-Id <Int32[]>
Gets the breakpoints with the specified breakpoint IDs. Enter the IDs i
n a comma-separated list. You can also pipe breakpoint IDs to Get-PSBre
akpoint.

-Script <string[]>
Gets only the breakpoints in the specified scripts. Enter the path (op
tional) and names of one or more script files. The default location is
the current directory.

-Type <BreakpointType[]>
Gets only breakpoints of the specified types. Enter one or more types.
Valid values are Line, Command, and Variable. You can also pipe breakpo
int types to Get-PSBreakpoint.

-Variable <string[]>
Gets variable breakpoints that are set on the specified variable names.
Enter the variable names without dollar signs.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-psbreakpoint

Description
-----------
This command gets all breakpoints set on all scripts and functions in the c
urrent session.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-psbreakpoint -Id 2

Function : Increment
Action :
Enabled : True
HitCount : 0
Id : 2
Script : C:\ps-test\sample.ps1
ScriptName : C:\ps-test\sample.ps1

Description
-----------
This command gets the breakpoint with breakpoint ID 2.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$b = set-psbreakpoint -script sample.ps1 -function increment

C:\PS> $b.Id | get-psbreakpoint

Description
-----------
These commands show how to get a breakpoint by piping a breakpoint ID to Ge
t-PSBreakpoint.

The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint o
n the Increment function in the Sample.ps1 script. It saves the breakpoint
object in the $b variable.

The second command uses the dot operator (.) to get the Id property of the
breakpoint object in the $b variable. It uses a pipeline operator (|) to se
nd the ID to the Get-PSBreakpoint cmdlet.

As a result, Get-PSBreakpoint gets the breakpoint with the specified ID.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-psbreakpoint -script Sample.ps1, SupportScript.ps1

Description
-----------
This command gets all of the breakpoints in the Sample.ps1 and SupportScrip
t.ps1 files.

This command does not get other breakpointS that might be set in other scri
pts or on functions in the session.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-psbreakpoint -command Read-Host, Write-Host -script Sample.ps1

Description
-----------
This command gets all Command breakpoints that are set on Read-Host or Writ
e-Host commands in the Sample.ps1 file.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-psbreakpoint -type Command -script Sample.ps1

Description
-----------
This command gets all Command breakpoints in the Sample.ps1 file.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-psbreakpoint -variable Index, Swap

Description
-----------
This command gets breakpoints that are set on the $index and $swap variable
s in the current session.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>get-psbreakpoint -type line, variable -script Sample.ps1

Description
-----------
This command gets all line and variable breakpoints in the Sample.ps1 scrip
t.




REMARKS
To see the examples, type: "get-help Get-PSBreakpoint -examples".
For more information, type: "get-help Get-PSBreakpoint -detailed".
For technical information, type: "get-help Get-PSBreakpoint -full".

NAME
Get-PSCallStack

SYNOPSIS
Displays the current call stack.


SYNTAX
Get-PSCallStack [<CommonParameters>]


DESCRIPTION
The Get-PSCallStack cmdlet displays the current call stack.

Although it is designed to be used with the Windows PowerShell debugger, yo
u can use this cmdlet to display the call stack in a script or function out
side of the debugger.

To run a Get-PSCallStack command while in the debugger, type "k" or "get-p
scallstack".

PARAMETERS
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>function my-alias {
$p = $args[0]
get-alias | where {$_.definition -like "*$p"} | ft definition, name -aut
o
}

PS C:\ps-test> set-psbreakpoint -command my-alias

Command : my-alias
Action :
Enabled : True
HitCount : 0
Id : 0
Script : prompt


PS C:\ps-test> my-alias get-content
Entering debug mode. Use h or ? for help.

Hit Command breakpoint on 'prompt:my-alias'

my-alias get-content

[DBG]: PS C:\ps-test> s
$p = $args[0]

DEBUG: Stepped to ': $p = $args[0] '

[DBG]: PS C:\ps-test> s
get-alias | Where {$_.Definition -like "*$p*"} | ft Definition,

[DBG]: PS C:\ps-test>get-pscallstack

Name CommandLineParameters UnboundArguments Loc
ation
---- --------------------- ---------------- ---
-----
prompt {} {} pro
mpt
my-alias {} {get-content} pro
mpt
prompt {} {} pro
mpt


[DBG]: PS C:\ps-test> o

Definition Name
---------- ----
Get-Content gc
Get-Content cat
Get-Content type

Description
-----------
This command uses the Get-PSCallStack cmdlet to display the call stack for
My-Alias, a simple function that gets the aliases for a cmdlet name.

The first command enters the function at the Windows PowerShell prompt. The
second command uses the Set-PSBreakpoint cmdlet to set a breakpoint on the
My-Alias function. The third command uses the My-Alias function to get all
of the aliases in the current session for the Get-Content cmdlet.

The debugger breaks in at the function call. Two consecutive step-into (s)
commands begin executing the function line by line. Then, a Get-PSCallStack
command is used to retrieve the call stack.

The final command is a Step-Out command (o) that exits the debugger and con
tinues executing the script to completion.




REMARKS
To see the examples, type: "get-help Get-PSCallStack -examples".
For more information, type: "get-help Get-PSCallStack -detailed".
For technical information, type: "get-help Get-PSCallStack -full".

NAME
Get-PSDrive

SYNOPSIS
Gets the Windows PowerShell drives in the current session.


SYNTAX
Get-PSDrive [-LiteralName] <string[]> [-PSProvider <string[]>] [-Scope <str
ing>] [-UseTransaction] [<CommonParameters>]

Get-PSDrive [[-Name] <string[]>] [-PSProvider <string[]>] [-Scope <string>]
[-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Get-PSDrive cmdlet gets the Windows PowerShell drives in the current se
ssion. You can get a particular drive or all drives in the console.

Get-PSDrive gets the following drives:

-- Windows logical drives on the computer, including drives mapped to netwo
rk shares.

-- Drives exposed by Windows PowerShell providers (such as the Certificate:
, Function:, and Alias: drives) and the HKLM: and HKCU: drives that are exp
osed by the Windows PowerShell Registry provider.

-- Drives that you create by using New-PSDrive.

Get-PSDrive does not get Windows mapped drives that are added or created af
ter the Windows PowerShell console is opened.

PARAMETERS
-LiteralName <string[]>
Specifies the name of the Windows PowerShell drive.

The value of LiteralName is used exactly as it is typed. No characters
are interpreted as wildcards. If the name includes escape characters, e
nclose it in single quotation marks. Single quotation marks tell Window
s PowerShell not to interpret any characters as escape sequences.

-Name <string[]>
Gets only the specified drives. Type the drive name or letter without a
colon (:).

-PSProvider <string[]>
Gets only the drives supported by the specified Windows PowerShell prov
ider. Type the name of a provider, such as FileSystem, Registry, or Cer
tificate.

-Scope <string>
Gets only the Windows PowerShell drives in the specified scope. Valid v
alues are "Global", "Local", or "Script", or a number relative to the c
urrent scope (0 through the number of scopes, where 0 is the current sc
ope and 1 is its parent). "Local" is the default. For more information,
see about_Scopes.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-psdrive

Name Provider Root
---- -------- ----
Alias Alias
C FileSystem C:\
cert Certificate \
D FileSystem D:\
Env Environment
Function Function
HKCU Registry HKEY_CURRENT_USER
HKLM Registry HKEY_LOCAL_MACHINE
Variable Variable
X FileSystem X:\

Description
-----------
This command gets the Windows PowerShell drives in the current session.

The output shows the hard drive (C:) and CD-ROM drive (D:) on the computer,
the drives exposed by the Windows PowerShell providers (Alias:, Cert:, Env
:, Function:, HKCU:, HKLM:, and Variable:), and a drive mapped to a network
share (X:).




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-psdrive d

Name Provider Root
---- -------- ----
D FileSystem D:\

Description
-----------
This command displays the D: drive on the computer. Note that the drive let
ter is not followed by a colon.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-psdrive -psprovider filesystem

Name Provider Root
---- -------- ----
C FileSystem C:\
D FileSystem D:\
X FileSystem X:\
Y FileSystem \\Server01\Public
Z FileSystem C:\Windows\System32

Description
-----------
This command displays all of the drives that are supported by the Windows P
owerShell FileSystem provider. This includes fixed drives, logical partitio
ns, mapped network drives, and drives that you create by using New-PSDrive
that are mapped to the file system drives.

This example shows that drives created by New-PSDrive have the name of the
mapped location in the value of the Root property. Windows drives just have
the root of the drive letter.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>if (!(get-psdrive X)) {
new-psdrive -name X -psprovider Registry -root HKLM:\Network
}
else { write-host "The X: drive is already in use." }

Description
-----------
This command checks to see whether the X drive is already in use as the Win
dows PowerShell drive name. If it is not, the command uses the New-PSDrive
cmdlet to create a Windows PowerShell drive that is mapped to the HKLM:\Net
work registry key.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-psdrive -provider filesystem

C:\PS> get-psdrive -provider filesystem

Name Provider Root
---- -------- ----
C FileSystem C:\
D FileSystem D:\
X FileSystem X:\
Y FileSystem \\Server01\Public
Z FileSystem C:\Windows\System32

C:\PS> net use
New connections will be remembered.

Status Local Remote Network
---------------------------------------------------------------------------
----
X: \\Server01\Public Microsoft Windows Network


C:\PS> [System.IO.DriveInfo]::getdrives()

Name : C:\
DriveType : Fixed
DriveFormat : NTFS
IsReady : True
AvailableFreeSpace : 39831498752
TotalFreeSpace : 39831498752
TotalSize : 79900368896
RootDirectory : C:\
VolumeLabel :
Name : D:\
DriveType : CDRom
DriveFormat :
IsReady : False
AvailableFreeSpace :
TotalFreeSpace :
TotalSize :
RootDirectory : D:\
VolumeLabel :
Name : X:\
DriveType : Network
DriveFormat : NTFS
IsReady : True
AvailableFreeSpace : 36340559872
TotalFreeSpace : 36340559872
TotalSize : 36413280256
RootDirectory : X:\
VolumeLabel : D_Drive


C:\PS> get-wmiobject win32_logicaldisk

DeviceID : C:
DriveType : 3
ProviderName :
FreeSpace : 39831252992
Size : 79900368896
VolumeName :
DeviceID : D:
DriveType : 5
ProviderName :
FreeSpace :
Size :
VolumeName :
DeviceID : X:
DriveType : 4
ProviderName : \\server01\public
FreeSpace : 36340559872
Size : 36413280256
VolumeName : D_Drive


C:\PS> get-wmiobject win32_networkconnection
LocalName RemoteName
-------------- ------------
x: \\server01\public

Description
-----------
This example compares the types of file system drives that are displayed by
Get-PSDrive to those displayed by using other methods. This example demons
trates different ways to display drives in Windows PowerShell, and it shows
that the drives created by using New-PSDrive are accessible only in Window
s PowerShell.

The first command uses Get-PSDrive to get all of the file system drives in
the Windows PowerShell console. This includes the fixed drives (C: and D:),
the mapped network drive (X:), and two Windows PowerShell drives (Y: and Z
:) that were created by using New-PsDrive.

A "net use" command, which displays Windows mapped network drives, displays
only the X drive. It does not display drives that are created by New-PSDri
ve. It shows that the X: drive is also mapped to \\Server01\Public.

The third command uses the GetDrives method of the Microsoft .NET Framework
System.IO.DriveInfo class. This command gets the Windows file system drive
s, including drive X:, but it does not get the drives created by New-PSDriv
e.

The fourth command uses the Get-WmiObject cmdlet to display the instances o
f the Win32_LogicalDisk class. It returns the C:, D:, and X: drives, but no
t the drives created by New-PSDrive.

The last command uses the Get-WmiObject cmdlet to display the instances of
the Win32_NetworkConnection class. Like "net use", it returns only the X: d
rive.




REMARKS
To see the examples, type: "get-help Get-PSDrive -examples".
For more information, type: "get-help Get-PSDrive -detailed".
For technical information, type: "get-help Get-PSDrive -full".

NAME
Get-PSProvider

SYNOPSIS
Gets information about the specified Windows PowerShell provider.


SYNTAX
Get-PSProvider [[-PSProvider] <string[]>] [<CommonParameters>]


DESCRIPTION
The Get-PSProvider cmdlet gets the Windows PowerShell providers in the curr
ent session. You can get a particular drive or all drives in the session.

Windows PowerShell providers let you access a variety of data stores as tho
ugh they were file system drives. For information about Windows PowerShell
providers, see about_Providers.

PARAMETERS
-PSProvider <string[]>
Specifies the name or names of the Windows PowerShell providers about w
hich to retrieve information.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-psprovider

Description
-----------
This command displays a list of all available Windows PowerShell providers.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-psprovider f*, r* | format-list

Description
-----------
This command displays a list of all Windows PowerShell providers with names
that begin with the letter "f" or "r".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-psprovider | format-table name, module, pssnapin -auto


Name Module PSSnapIn
---- ------ --------
Test TestModule
WSMan Microsoft.WSMan.Management
Alias Microsoft.PowerShell.Core
Environment Microsoft.PowerShell.Core
FileSystem Microsoft.PowerShell.Core
Function Microsoft.PowerShell.Core
Registry Microsoft.PowerShell.Core
Variable Microsoft.PowerShell.Core
Certificate Microsoft.PowerShell.Security

C:\PS> get-psprovider | where {$_.pssnapin -eq "Microsoft.PowerShell.Securi
ty"}

Name Capabilities Drives
---- ------------ ------
Certificate ShouldProcess {cert}

Description
-----------
These commands find the Windows PowerShell snap-ins or modules that added p
roviders to your session. All Windows PowerShell elements, including provid
ers, originate in a snap-in or in a module.

These commands use the PSSnapin and Module properties of the ProviderInfo o
bject that Get-PSProvider returns. The values of these properties contain t
he name of the snap-in or module that adds the provider.

The first command gets all of the providers in the session and formats them
in a table with the values of their Name, Module, and PSSnapin properties.

The second command uses the Where-Object cmdlet to get the providers that c
ome from the Microsoft.PowerShell.Security snap-in.




REMARKS
To see the examples, type: "get-help Get-PSProvider -examples".
For more information, type: "get-help Get-PSProvider -detailed".
For technical information, type: "get-help Get-PSProvider -full".

NAME
Get-PSSession

SYNOPSIS
Gets the Windows PowerShell sessions (PSSessions) in the current session.


SYNTAX
Get-PSSession [[-ComputerName] <string[]>] [<CommonParameters>]

Get-PSSession [-Id] <Int32[]> [<CommonParameters>]

Get-PSSession [-InstanceId <Guid[]>] [<CommonParameters>]

Get-PSSession [-Name <string[]>] [<CommonParameters>]


DESCRIPTION
The Get-PSSession cmdlet gets the Windows PowerShell sessions (PSSessions)
that were created in the current session.

Without parameters, Get-PSSession gets all of the PSSessions created in the
current session. You can use the parameters of Get-PSSession to get the se
ssions that are connected to particular computers, or you can identify sess
ions by their names, IDs, or instance IDs.

For more information about Windows PowerShell sessions, see about_PSSession
s.

PARAMETERS
-ComputerName <string[]>
Gets only the PSSessions that are connected to the specified computers.
Wildcards are permitted.

Type the NetBIOS name, an IP address, or a fully-qualified domain name
of one or more computers. To specify the local computer, type the compu
ter name, "localhost", or a dot (.).

-Id <Int32[]>
Gets only the PSSessions with the specified IDs. Type one or more IDs (
separated by commas), or use the range operator (..) to specify a range
of IDs.

An ID is an integer that uniquely identifies the PSSession in the curre
nt session. It is easier to remember and type than the InstanceId, but
it is unique only within the current session. To find the ID of a PSSe
ssion, use Get-PSSession without parameters.

-InstanceId <Guid[]>
Gets only the PSSessions with the specified instance IDs.

The instance ID is a GUID that uniquely identifies a PSSession on a loc
al or remote computer. The InstanceID is unique, even when you have mul
tiple sessions running in Windows PowerShell.

The InstanceID is stored in the InstanceID property of the object that
represents a PSSession. To find the InstanceID of the PSSessions in the
current session, type "get-pssession | format-table Name, ComputerName
, InstanceId".

-Name <string[]>
Gets only the PSSessions with the specified friendly names. Wildcards a
re permitted.

To find the names of the PSSessions in the current session, type "get-p
ssession" without parameters.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-pssession

Description
-----------
This command gets all of the PSSessions that were created in the current se
ssion.

It does not get PSSessions that were created in other sessions or on other
computers, even if they connect to this computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$s = get-pssession -computername Server02

Description
-----------
This command gets the PSSessions that are connected to the Server02 compute
r and saves them in the $p variable.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>new-pssession -computername Server01, Server02, Server03

C:\PS> $s1, $s2, $s3 = get-pssession

Description
-----------
This example shows how to save the results of a Get-PSSession command in mu
ltiple variables.

The first command uses the New-PSSession cmdlet to create PSSessions on thr
ee remote computers.

The second command uses a Get-PSSession cmdlet to get the three PSSessions.
It then saves each of the PSSessions in a separate variable.

When Windows PowerShell assigns an array of objects to an array of variable
s, it assigns the first object to the first variable, the second object to
the second variable, and so on. If there are more objects than variables, i
t assigns all remaining objects to the last variable in the array. If there
are more variables than objects, the extra variables are not used.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-pssession | format-table -property computername, InstanceID

C:\PS> $s = get-pssession -InstanceID a786be29-a6bb-40da-80fb-782c67f7db0f

C:\PS> remove-pssession -session $s

Description
-----------
This example shows how to get a PSSession by using its instance ID, and the
n to delete the PSSession.

The first command gets all of the PSSessions on the local computer. It send
s the PSSessions to the Format-Table cmdlet, which displays the ComputerNam
e and InstanceID properties of each PSSession.

The second command uses the Get-PSSession cmdlet to get a particular PSSess
ion and to save it in the $s variable. The command uses the InstanceID para
meter to identify the PSSession.

The third command uses the Remove-PSSession cmdlet to delete the PSSession
in the $s variable.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-pssession -computername Serv*

Description
-----------
This command gets all the PSSessions that connect to computers that have co
mputer names that begin with "Serv".




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-pssession -name Test*, Ux*

Description
-----------
This command gets PSSessions that have names that begin with "Test" or "Ux"
.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-pssession 2

Description
-----------
This command gets the PSSession with ID 2.




REMARKS
To see the examples, type: "get-help Get-PSSession -examples".
For more information, type: "get-help Get-PSSession -detailed".
For technical information, type: "get-help Get-PSSession -full".

NAME
Get-PSSessionConfiguration

SYNOPSIS
Gets the registered session configurations on the computer.


SYNTAX
Get-PSSessionConfiguration [[-Name] <string[]>] [<CommonParameters>]


DESCRIPTION
The Get-PSSessionConfiguration cmdlet gets the session configurations that
have been registered on the local computer. This is an advanced cmdlet that
is designed to be used by system administrators to manage customized sessi
on configurations for their users.

To create and register a session configuration, use the Register-PSSessionC
onfiguration cmdlet.

PARAMETERS
-Name <string[]>
Gets only the session configurations with the specified name or name pa
ttern. Enter one or more session configuration names. Wildcards are per
mitted.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-pssessionconfiguration

Description
-----------
This command gets the session configurations on the computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-pssessionconfiguration -name Microsoft*

Name PSVersion StartupScript Permission
---- --------- ------------- ----------
microsoft.powershell 2.0 BUILTIN\Administr
ators AccessAll...
microsoft.powershell32 2.0 BUILTIN\Administr
ators AccessAll...

Description
-----------
This command uses the Name parameter of Get-PSSessionConfiguration to get o
nly the session configurations with names that begin with "Microsoft".

This command gets the two default session configurations that come with Win
dows PowerShell.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>Get-PSSessionConfiguration -name microsoft.powershell | get-member



TypeName: Microsoft.PowerShell.Commands.PSSessionConfigurationCommands#P
SSessionConfiguration

Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Capability NoteProperty System.Object[] Capability=System.Obj
ect[]
ExactMatch NoteProperty System.String ExactMatch=False
Filename NoteProperty System.String Filename=%windir%\syste
m32\pwrshplugin.dll
lang NoteProperty System.String lang=en-US
Name NoteProperty System.String Name=microsoft.powershe
ll
PSVersion NoteProperty System.String PSVersion=2.0
ResourceUri NoteProperty System.String ResourceUri=http://sche
mas.microsoft.com/powershell/microsoft.powershell
SDKVersion NoteProperty System.String SDKVersion=1
SecurityDescriptorSddl NoteProperty System.String SecurityDescriptorSddl=
O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)
SupportsOptions NoteProperty System.String SupportsOptions=true
Uri NoteProperty System.String Uri=http://schemas.micr
osoft.com/powershell/microsoft.powershell
xmlns NoteProperty System.String xmlns=http://schemas.mi
crosoft.com/wbem/wsman/1/config/PluginConfiguration
XmlRenderingType NoteProperty System.String XmlRenderingType=text
Permission ScriptProperty System.Object Permission {get=trap {
continue; }...


C:\PS> Get-PSSessionConfiguration -name microsoft.powershell | format-list
-property *


Name : microsoft.powershell
Filename : %windir%\system32\pwrshplugin.dll
SDKVersion : 1
XmlRenderingType : text
lang : en-US
PSVersion : 2.0
ResourceUri : http://schemas.microsoft.com/powershell/microsoft.
powershell
SupportsOptions : true
Capability : {Shell}
Uri : http://schemas.microsoft.com/powershell/microsoft.
powershell
SecurityDescriptorSddl : O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GX
GW;;;WD)
ExactMatch : False
xmlns : http://schemas.microsoft.com/wbem/wsman/1/config/P
luginConfiguration
Permission : BUILTIN\Administrators AccessAllowed

Description
-----------
These commands examine the PSSessionConfiguration object that Get-PSSession
Configuration returns.

The first command uses the Get-PSSessionConfiguration cmdlet to get the Mic
rosoft.PowerShell default configuration.

The second command uses a pipeline operator (|) to send the object that Get
-PSSessionConfiguration returns to the Get-Member cmdlet. The output shows
the properties and methods of the object.

The third command sends the same object to the Format-List cmdlet. The Prop
erty parameter with a value of * (all) directs Format-List to display all o
f the properties and property values of the object in a list.

The output of this command has very useful information, including the locat
ion of the .dll that implements the configuration type, the resource Unifor
m Resource Identifier (URI) for the endpoint that is created, and the Secur
ity Descriptor Definition Language (SDDL) for the configuration.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>dir wsman:\localhost\plugin

WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Plugin

Name Type Keys
---- ---- ----
Event Forwarding Plugin Container {Name=Event Forwarding Plugi
n}
MaintenanceShell Container {Name=MaintenanceShell}
microsoft.powershell Container {Name=microsoft.powershell}
microsoft.powershell32 Container {Name=microsoft.powershell32
}
WMI Provider Container {Name=WMI Provider}

Description
-----------
This command uses the Get-ChildItem cmdlet (alias = dir) in the WSMan: prov
ider drive to look at the content of the Plugin node.

This is another way to look at the session configurations on the computer.

The PlugIn node contains ContainerElement objects (Microsoft.WSMan.Manageme
nt.WSManConfigContainerElement) that represent the registered Windows Power
Shell session configurations, along with other plug-ins for WS-Management.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>enable-wsmanCredSSP -delegate server02

C:\PS> connect-wsman server02

C:\PS> set-item wsman:\server02*\service\auth\credSSP -value $true

C:\PS> invoke-command -scriptblock {Get-PSSessionConfiguration} -computerna
me Server02 -authentication CredSSP -credential Domain01\Admin01

Name PSVersion StartupScript Permission
PSComputerName
---- --------- ------------- ----------
--------------
microsoft.powershell 2.0 BUILTIN\Administr
ators AccessAll... server02.corp.fabrikam.com
microsoft.powershell32 2.0 BUILTIN\Administr
ators AccessAll... server02.corp.fabrikam.com
MyX86Shell 2.0 c:\test\x86Shell.ps1 BUILTIN\Administr
ators AccessAll... server02.corp.fabrikam.com

Description
-----------
This example shows how to run a Get-PSSessionConfiguration command on a rem
ote computer. The command requires that CredSSP delegation be enabled in th
e client settings on the local computer and in the service settings on the
remote computer. To run the commands in this example, you must be a member
of the Administrators group on the local computer and the remote computer.

The first command uses the Enable-WSManCredSSP cmdlet to enable CredSSP del
egation from the Server01 local computer to the Server02 remote computer. T
his configures the CredSSP client setting on the local computer.

The second command uses the Connect-WSMan cmdlet to connect to the Server02
computer. This action adds a node for the Server02 computer to the WSMan:
drive on the local computer, allowing you to view and change the WS-Managem
ent settings on the Server02 computer.

The third command uses the Set-Item cmdlet to change the value of the CredS
SP item in the Service node of the Server02 computer to True. This configur
es the service settings on the remote computer.

The fourth command uses the Invoke-Command cmdlet to run a Get-PSSessionCon
figuration command on the Server02 computer. The command uses the Credentia
l parameter, and it uses the Authentication parameter with a value of CredS
SP.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>(get-PSSessionConfiguration -name CustomShell).resourceURI

http://schemas.microsoft.com/powershell/microsoft.CustomShell

Description
-----------
This command uses the Get-PSSessionConfiguration cmdlet to get the resource
URI of a session configuration.

This command is useful when setting the value of the $PSSessionConfiguratio
nName preference variable, which takes a resource URI.

The $PSSessionConfiguationName variable specifies the default configuration
that is used when you create a session. This variable is set on the local
computer, but it specifies a configuration on the remote computer. For more
information about the $PSSessionConfiguration variable, see about_Preferen
ce_Variables.




REMARKS
To see the examples, type: "get-help Get-PSSessionConfiguration -examples".
For more information, type: "get-help Get-PSSessionConfiguration -detailed"
.
For technical information, type: "get-help Get-PSSessionConfiguration -full
".

NAME
Get-PSSnapin

SYNOPSIS
Gets the Windows PowerShell snap-ins on the computer.


SYNTAX
Get-PSSnapin [[-Name] <string[]>] [-Registered] [<CommonParameters>]


DESCRIPTION
The Get-PSSnapin cmdlet gets the Windows PowerShell snap-ins that have been
added to the current session or that have been registered on the system. T
he snap-ins are listed in the order in which they are detected.

Get-PSSnapin gets only registered snap-ins. To register a Windows PowerShel
l snap-in, use the InstallUtil tool included with the Microsoft .NET Framew
ork 2.0. For more information, see "How to Register Cmdlets, Providers, and
Host Applications" in the MSDN (Microsoft Developer Network) library at ht
tp://go.microsoft.com/fwlink/?LinkId=143619.

PARAMETERS
-Name <string[]>
Gets only the specified Windows PowerShell snap-ins. Enter the names of
one or more Windows PowerShell snap-ins. Wildcards are permitted.

The parameter name ("Name") is optional.

-Registered [<SwitchParameter>]
Gets the Windows PowerShell snap-ins that have been registered on the s
ystem (even if they have not yet been added to the session).

The snap-ins that are installed with Windows PowerShell do not appear i
n this list.

Without this parameter, Get-PSSnapin gets the Windows PowerShell snap-i
ns that have been added to the session.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-PSSnapIn

Description
-----------
This command gets the Windows PowerShell snap-ins that are currently loaded
in the session. This includes the snap-ins that are installed with Windows
PowerShell and those that have been added to the session.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-PSSnapIn -registered

Description
-----------
This command gets the Windows PowerShell snap-ins that have been registered
on the computer, including those that have already been added to the sessi
on. The output does not include snap-ins that are installed with Windows Po
werShell or Windows PowerShell snap-in dynamic-link libraries (DLLs) that h
ave not yet been registered on the system.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-PSSnapIn smp*

Description
-----------
This command gets the Windows PowerShell snap-ins in the current session th
at have names that begin with "smp".




REMARKS
To see the examples, type: "get-help Get-PSSnapin -examples".
For more information, type: "get-help Get-PSSnapin -detailed".
For technical information, type: "get-help Get-PSSnapin -full".

NAME
Get-Random

SYNOPSIS
Gets a random number, or selects objects randomly from a collection.


SYNTAX
Get-Random [-InputObject] <Object[]> [-Count <int>] [-SetSeed <int>] [<Comm
onParameters>]

Get-Random [[-Maximum] <Object>] [-Minimum <Object>] [-SetSeed <int>] [<Com
monParameters>]


DESCRIPTION
The Get-Random cmdlet gets a randomly selected number. If you submit a coll
ection of objects to Get-Random, it gets one or more randomly selected obje
cts from the collection.

Without parameters or input, a Get-Random command returns a randomly select
ed 32-bit unsigned integer between 0 (zero) and Int32.MaxValue (0x7FFFFFFF,
2,147,483,647).

You can use the parameters of Get-Random to specify a seed number, minimum
and maximum values, and the number of objects returned from a submitted col
lection.

PARAMETERS
-Count <int>
Determines how many objects are returned. The default is 1. If the valu
e of Count exceeds the number of objects in the collection, Get-Random
returns all of the objects in random order.

-InputObject <Object[]>
Specifies a collection of objects. Get-Random gets randomly selected ob
jects in random order from the collection. Enter the objects, a variabl
e that contains the objects, or a command or expression that gets the o
bjects. You can also pipe a collection of objects to Get-Random.

-Maximum <Object>
Specifies a maximum value for the random number. Get-Random returns a v
alue that is less than the maximum (not equal). Enter a 32-bit integer
or a double-precision floating-point number, or an object that can be c
onverted to an integer or double, such as a numeric string ("100"). The
value of Maximum must be greater than (not equal to) the value of Mini
mum.

If the value of Maximum or Minimum is a floating-point number, Get-Rand
om returns a randomly selected floating-point number.

If the value of Minimum is a double (a floating-point number), the defa
ult value of Maximum is Double.MaxValue. Otherwise, the default value i
s Int32.MaxValue (2,147,483,647 or 0x7FFFFFFF).

-Minimum <Object>
Specifies a minimum value for the random number. Enter a 32-bit integer
or a double-precision floating-point number, or an object that can be
converted to an integer or double, such as a numeric string ("100"). Th
e default value is 0 (zero).

The value of Minimum must be less than (not equal to) the value of Maxi
mum. If the value of Maximum or Minimum is a floating-point number, Get
-Random returns a randomly selected floating-point number.

-SetSeed <int>
Specifies a seed value for the random number generator. This seed value
is used for the current command and for all subsequent Get-Random comm
ands in the current session until you use SetSeed again or close the se
ssion. You cannot reset the seed to its default, clock-based value.

The SetSeed parameter is not required. By default, Get-Random uses the
system clock to generate a seed value. Because SetSeed results in non-r
andom behavior, it is typically used only when trying to reproduce beha
vior, such as when debugging or analyzing a script that includes Get-Ra
ndom commands.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-random

3951433

Description
-----------
This command gets a random integer between 0 (zero) and Int32.MaxValue.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-random -maximum 100

47

Description
-----------
This command gets a random integer between 0 (zero) and 99.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-random -minimum -100 -maximum 100

-56

Description
-----------
This command gets a random integer between -100 and 99.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-random -min 10.7 -max 20.93

18.08467273887

Description
-----------
This command gets a random floating-point number greater than or equal to 1
0.7 and less than 20.92.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-random -input 1, 2, 3, 5, 8, 13

8

Description
-----------
This command gets a randomly selected number from the specified array.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-random -input 1, 2, 3, 5, 8, 13 -count 3

3
1
13

Description
-----------
This command gets three randomly selected numbers in random order from the
array.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-random -input 1, 2, 3, 5, 8, 13 -count ([int]::MaxValue)

2
3
5
1
8
13

Description
-----------
This command returns the entire collection in random order. The value of th
e Count parameter is the MaxValue static property of integers.

To return an entire collection in random order, enter any number that is gr
eater than or equal to the number of objects in the collection.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>get-random -input "red", "yellow", "blue"

yellow

Description
-----------
This command returns a random value from a non-numeric collection.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>get-process | get-random

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
144 4 2080 488 36 0.48 3164 wmiprvse

Description
-----------
This command gets a randomly selected process from the collection of proces
ses on the computer.




-------------------------- EXAMPLE 10 --------------------------

C:\PS>get-content servers.txt | get-random -count (get-content servers.txt)
.count | foreach {invoke-expression -computer $_ -command 'get-process powe
rshell'}

Description
-----------
This command runs a command on a series of remote computers in random order
.




-------------------------- EXAMPLE 11 --------------------------

C:\PS>get-random -max 100 -setseed 23


# Commands with the default seed are pseudorandom
PS C:\ps-test> get-random -max 100
59
PS C:\ps-test> get-random -max 100
65
PS C:\ps-test> get-random -max 100
21

# Commands with the same seed are not random
PS C:\ps-test> get-random -max 100 -setseed 23
74
PS C:\ps-test> get-random -max 100 -setseed 23
74
PS C:\ps-test> get-random -max 100 -setseed 23
74

# SetSeed results in a repeatable series
PS C:\ps-test> get-random -max 100 -setseed 23
74
PS C:\ps-test> get-random -max 100
56
PS C:\ps-test> get-random -max 100
84
PS C:\ps-test> get-random -max 100
46
PS C:\ps-test> get-random -max 100 -setseed 23
74
PS C:\ps-test> get-random -max 100
56
PS C:\ps-test> get-random -max 100
84
PS C:\ps-test> get-random -max 100
46

Description
-----------
This example shows the effect of using the SetSeed parameter. Because SetSe
ed produces non-random behavior, it is typically used only to reproduce res
ults, such as when debugging or analyzing a script.




-------------------------- EXAMPLE 12 --------------------------

C:\PS>$files = dir -path c:\* -recurse

C:\PS> $sample = $files | get-random -count 50

Description
-----------
These commands get a randomly selected sample of 50 files from the C: drive
of the local computer.




-------------------------- EXAMPLE 13 --------------------------

C:\PS>get-random 10001

7600

Description
-----------
This command gets a random integer less than 10001. Because the Maximum par
ameter has position 1, you can omit the parameter name when the value is th
e first or only unnamed parameter in the command.




REMARKS
To see the examples, type: "get-help Get-Random -examples".
For more information, type: "get-help Get-Random -detailed".
For technical information, type: "get-help Get-Random -full".

NAME
Get-Service

SYNOPSIS
Gets the services on a local or remote computer.


SYNTAX
Get-Service [[-Name] <string[]>] [-ComputerName <string[]>] [-DependentServ
ices] [-Exclude <string[]>] [-Include <string[]>] [-RequiredServices] [<Com
monParameters>]

Get-Service -DisplayName <string[]> [-ComputerName <string[]>] [-DependentS
ervices] [-Exclude <string[]>] [-Include <string[]>] [-RequiredServices] [<
CommonParameters>]

Get-Service [-InputObject <ServiceController[]>] [-ComputerName <string[]>]
[-DependentServices] [-Exclude <string[]>] [-Include <string[]>] [-Require
dServices] [<CommonParameters>]


DESCRIPTION
The Get-Service cmdlet gets objects that represent the services on a local
computer or on a remote computer, including running and stopped services.

You can direct Get-Service to get only particular services by specifying th
e service name or display name of the services, or you can pipe service obj
ects to Get-Service.

PARAMETERS
-ComputerName <string[]>
Gets the services running on the specified computers. The default is th
e local computer.

Type the NetBIOS name, an IP address, or a fully qualified domain name
of a remote computer. To specify the local computer, type the computer
name, a dot (.), or "localhost".

This parameter does not rely on Windows PowerShell remoting. You can us
e the ComputerName parameter of Get-Service even if your computer is no
t configured to run remote commands.

-DependentServices [<SwitchParameter>]
Gets only the services that depend upon the specified service.

By default, Get-Service gets all services.

-DisplayName <string[]>
Specifies the display names of services to be retrieved. Wildcards are
permitted. By default, Get-Service gets all services on the computer.

-Exclude <string[]>
Omits the specified services. The value of this parameter qualifies the
Name parameter. Enter a name element or pattern, such as "s*". Wildcar
ds are permitted.

-Include <string[]>
Retrieves only the specified services. The value of this parameter qual
ifies the Name parameter. Enter a name element or pattern, such as "s*"
. Wildcards are permitted.

-InputObject <ServiceController[]>
Specifies ServiceController objects representing the services to be ret
rieved. Enter a variable that contains the objects, or type a command o
r expression that gets the objects. You can also pipe a service object
to Get-Service.

-Name <string[]>
Specifies the service names of services to be retrieved. Wildcards are
permitted. By default, Get-Service gets all of the services on the comp
uter.

-RequiredServices [<SwitchParameter>]
Gets only the services that this service requires.

This parameter gets the value of the ServicesDependedOn property of the
service. By default, Get-Service gets all services.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-service

Description
-----------
This command retrieves all of the services on the system. It behaves as tho
ugh you typed "get-service *". The default display shows the status, servic
e name, and display name of each service.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-service wmi*

Description
-----------
This command retrieves services with service names that begin with "WMI" (t
he acronym for Windows Management Instrumentation).




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-service -displayname *network*

Description
-----------
This command displays services with a display name that includes the word
"network". Searching the display name finds network-related services even w
hen the service name does not include "Net", such as xmlprov, the Network P
rovisioning Service.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-service -name win* -exclude winrm

Description
-----------
These commands get only the services with service names that begin with "wi
n", except for the WinRM service.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-service | where-object {$_.Status -eq "Running"}

Description
-----------
This command displays only the services that are currently running. It uses
the Get-Service cmdlet to get all of the services on the computer. The pip
eline operator (|) passes the results to the Where-Object cmdlet, which sel
ects only the services with a Status property that equals "Running".

Status is only one property of service objects. To see all of the propertie
s, type "get-service | get-member".




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-service -computername Server02

Description
-----------
This command gets the services on the Server02 remote computer.

Because the ComputerName parameter of Get-Service does not use Windows Powe
rShell remoting, you can use this parameter even if the computer is not con
figured for remoting in Windows PowerShell.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-service | where-object {$_.DependentServices} | format-list -prop
erty Name, DependentServices, @{Label="NoOfDependentS
ervices"; Expression={$_.dependentservices.count}}

Name : AudioEndpointBuilder
DependentServices : {AudioSrv}
NoOfDependentServices : 1

Name : Dhcp
DependentServices : {WinHttpAutoProxySvc}
NoOfDependentServices : 1
...

Description
-----------
These commands list the services on the computer that have dependent servic
es.

The first command uses the Get-Service cmdlet to get the services on the co
mputer. A pipeline operator (|) sends the services to the Where-Object cmdl
et, which selects the services whose DependentServices property is not null
.

Another pipeline operator sends the results to the Format-List cmdlet. The
command uses its Property parameter to display the name of the service, the
name of the dependent services, and a calculated property that displays th
e number of dependent services that each service has.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>C:\PS> get-service s* | sort-object status

Status Name DisplayName
------ ---- -----------
Stopped stisvc Windows Image Acquisition (WIA)
Stopped SwPrv MS Software Shadow Copy Provider
Stopped SysmonLog Performance Logs and Alerts
Running Spooler Print Spooler
Running srservice System Restore Service
Running SSDPSRV SSDP Discovery Service
Running ShellHWDetection Shell Hardware Detection
Running Schedule Task Scheduler
Running SCardSvr Smart Card
Running SamSs Security Accounts Manager
Running SharedAccess Windows Firewall/Internet Connectio...
Running SENS System Event Notification
Running seclogon Secondary Logon

C:\PS> get-service s* | sort-object status -descending

Status Name DisplayName
------ ---- -----------
Running ShellHWDetection Shell Hardware Detection
Running SharedAccess Windows Firewall/Internet Connectio...
Running Spooler Print Spooler
Running SSDPSRV SSDP Discovery Service
Running srservice System Restore Service
Running SCardSvr Smart Card
Running SamSs Security Accounts Manager
Running Schedule Task Scheduler
Running SENS System Event Notification
Running seclogon Secondary Logon
Stopped SysmonLog Performance Logs and Alerts
Stopped SwPrv MS Software Shadow Copy Provider
Stopped stisvc Windows Image Acquisition (WIA)

Description
-----------
This command shows that when you sort services in ascending order by the va
lue of their Status property, stopped services appear before running servic
es. This happens because the value of Status is an enumeration, in which "S
topped" has a value of "1", and "Running" has a value of 4.

To list running services first, use the Descending parameter of the Sort-Ob
ject cmdlet.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>get-service -name winrm -computername localhost, Server01, Server02
| format-table -property MachineName, Status, Name, DisplayName -auto

MachineName Status Name DisplayName
------------ ------ ---- -----------
localhost Running WinRM Windows Remote Management (WS-Management)
Server01 Running WinRM Windows Remote Management (WS-Management)
Server02 Running WinRM Windows Remote Management (WS-Management)

Description
-----------
This command uses the Get-Service cmdlet to run a "Get-Service Winrm" comma
nd on two remote computers and the local computer ("localhost").

The Get-Service command runs on the remote computers, and the results are r
eturned to the local computer. A pipeline operator (|) sends the results to
the Format-Table cmdlet, which formats the services as a table. The Format
-Table command uses the Property parameter to specify the properties displa
yed in the table, including the MachineName property.




-------------------------- EXAMPLE 10 --------------------------

C:\PS>get-service winrm -requiredServices

Description
-----------
This command gets the services that the WinRM service requires.

The command returns the value of the ServicesDependedOn property of the ser
vice.




-------------------------- EXAMPLE 11 --------------------------

C:\PS>"winrm" | get-service

Description
-----------
This command gets the WinRM service on the local computer. This example sho
ws that you can pipe a service name string (enclosed in quotation marks) to
Get-Service.




REMARKS
To see the examples, type: "get-help Get-Service -examples".
For more information, type: "get-help Get-Service -detailed".
For technical information, type: "get-help Get-Service -full".

NAME
Get-TraceSource

SYNOPSIS
Gets the Windows PowerShell components that are instrumented for tracing.


SYNTAX
Get-TraceSource [[-Name] <string[]>] [<CommonParameters>]


DESCRIPTION
The Get-TraceSource cmdlet gets the trace sources for Windows PowerShell co
mponents that are currently in use. You can use the data to determine which
Windows PowerShell components you can trace. When tracing, the component g
enerates detailed messages about each step in its internal processing. Deve
lopers use the trace data to monitor data flow, program execution, and erro
rs. The tracing cmdlets were designed for Windows PowerShell developers, bu
t they are available to all users.

PARAMETERS
-Name <string[]>
Gets only the specified trace sources. Wildcards are permitted. The par
ameter name ("Name") is optional.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-traceSource *provider*

Description
-----------
This command gets all of the trace sources that have names that include "pr
ovider".




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-tracesource

Description
-----------
This command gets all of the Windows PowerShell components that can be trac
ed.




REMARKS
To see the examples, type: "get-help Get-TraceSource -examples".
For more information, type: "get-help Get-TraceSource -detailed".
For technical information, type: "get-help Get-TraceSource -full".

NAME
Get-Transaction

SYNOPSIS
Gets the current (active) transaction.


SYNTAX
Get-Transaction [<CommonParameters>]


DESCRIPTION
The Get-Transaction cmdlet gets an object that represents the current trans
action in the session.

This cmdlet never returns more than one object, because only one transactio
n is active at a time. If you start one or more independent transactions (b
y using the Independent parameter of Start-Transaction), the most recently
started transaction is active, and that is the transaction that Get-Transac
tion returns.

When all active transactions have either been rolled back or committed, Get
-Transaction shows the transaction that was most recently active in the ses
sion.

The Get-Transaction cmdlet is one of a set of cmdlets that support the tran
sactions feature in Windows PowerShell. For more information, see about_Tra
nsactions.

PARAMETERS
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>start-transaction

C:\PS> get-transaction

RollbackPreference SubscriberCount Status
------------------ --------------- ------
Error 1 Active

Description
-----------
This command uses the Get-Transaction cmdlet to get the current transaction
.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-transaction | get-member

Name MemberType Definition
---- ---------- ----------
Dispose Method System.Void Dispose(), System.Void Dispose(Bo
olean disposing)
Equals Method System.Boolean Equals(Object obj)
GetHashCode Method System.Int32 GetHashCode()
GetType Method System.Type GetType()
ToString Method System.String ToString()
IsCommitted Property System.Boolean IsCommitted {get;}
IsRolledBack Property System.Boolean IsRolledBack {get;}
RollbackPreference Property System.Management.Automation.RollbackSeverity
RollbackPreference {get;}
SubscriberCount Property System.Int32 SubscriberCount {get;set;}

Description
-----------
This command uses the Get-Member cmdlet to show the properties and methods
of the transaction object.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>cd hklm:\software
HKLM:\SOFTWARE> Start-Transaction
HKLM:\SOFTWARE> New-Item MyCompany -UseTransaction
HKLM:\SOFTWARE> Undo-Transaction
HKLM:\SOFTWARE> Get-Transaction

RollbackPreference SubscriberCount Status
------------------ --------------- ----------
Error 0 RolledBack

Description
-----------
This command shows the property values of a transaction object for a transa
ction that has been rolled back.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>cd hklm:\software
HKLM:\SOFTWARE> Start-Transaction
HKLM:\SOFTWARE> New-Item MyCompany -UseTransaction
HKLM:\SOFTWARE> Complete-Transaction
HKLM:\SOFTWARE> Get-Transaction

RollbackPreference SubscriberCount Status
------------------ --------------- ---------
Error 1 Committed

Description
-----------
This command shows the property values of a transaction object for a transa
ction that has been committed.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>cd hklm:\software
HKLM:\SOFTWARE> Start-Transaction
HKLM:\SOFTWARE> New-Item MyCompany -UseTransaction

HKLM:\SOFTWARE> Start-Transaction
HKLM:\SOFTWARE> New-Item MyCompany2 -UseTransaction

HKLM:\SOFTWARE> Get-Transaction

RollbackPreference SubscriberCount Status
------------------ --------------- ------
Error 2 Active

HKLM:\SOFTWARE> Complete-Transaction
HKLM:\SOFTWARE> Get-Transaction

RollbackPreference SubscriberCount Status
------------------ --------------- ------
Error 1 Active


HKLM:\SOFTWARE> Complete-Transaction
HKLM:\SOFTWARE> Get-Transaction

RollbackPreference SubscriberCount Status
------------------ --------------- ---------
Error 1 Committed

Description
-----------
This example shows the effect on the transaction object of starting a trans
action while another transaction is in progress. Typically, this happens wh
en a script that runs a transaction includes a function or calls a script t
hat contains another complete transaction.

Unless the second Start-Transaction command includes the Independent parame
ter, Start-Transaction does not create a new transaction. Instead, it adds
a second subscriber to the original transaction.

The first Start-Transaction command starts the transaction. A New-Item comm
and with the UseTransaction parameter is part of the transaction.

A second Start-Transaction command adds a subscriber to the transaction. Th
e next New-Item command is also part of the transaction.

The first Get-Transaction command shows the multi-subscriber transaction. N
otice that the subscriber count is 2.

The first Complete-Transaction command does not commit the transaction, but
it reduces the subscriber count to 1.

The second Complete-Transaction command commits the transaction.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>HKLM:\SOFTWARE> Start-Transaction

HKLM:\SOFTWARE> Get-Transaction

RollbackPreference SubscriberCount IsRolledBack IsCommitted
------------------ --------------- ------------ -----------
Error 1 False False

HKLM:\SOFTWARE> Start-Transaction -Independent
HKLM:\SOFTWARE> Get-Transaction

RollbackPreference SubscriberCount IsRolledBack IsCommitted
------------------ --------------- ------------ -----------
Error 1 False False

HKLM:\SOFTWARE> Complete-Transaction
HKLM:\SOFTWARE> Get-Transaction

HKLM:\SOFTWARE> Complete-Transaction
HKLM:\SOFTWARE> Get-Transaction

Description
-----------
This example shows the effect on the transaction object of starting an inde
pendent transaction while another transaction is in progress.

The first Start-Transaction command starts the transaction. A New-Item comm
and with the UseTransaction parameter is part of the transaction.

A second Start-Transaction command adds a subscriber to the transaction. Th
e next New-Item command is also part of the transaction.

The first Get-Transaction command shows the multi-subscriber transaction. N
ote that the subscriber count is 2.

The Complete-Transaction command reduces the subscriber count to 1, but it
does not commit the transaction.

The second Complete-Transaction command commits the transaction.




REMARKS
To see the examples, type: "get-help Get-Transaction -examples".
For more information, type: "get-help Get-Transaction -detailed".
For technical information, type: "get-help Get-Transaction -full".

NAME
Get-UICulture

SYNOPSIS
Gets the current user interface (UI) culture settings in the operating syst
em.


SYNTAX
Get-UICulture [<CommonParameters>]


DESCRIPTION
The Get-UICulture cmdlet gets information about the current UI culture sett
ings for Windows. The UI culture determines which text strings are used for
user interface elements, such as menus and messages.

You can also use the Get-Culture cmdlet, which gets the current culture on
the system. The culture determines the display format of items such as numb
ers, currency, and dates.

PARAMETERS
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-uiculture

Description
-----------
This command gets the current UI culture information.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-uiculture | format-list *

Description
-----------
This command displays the values of all of the properties of the current UI
culture in a list.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>(get-uiculture).calendar

Description
-----------
This command displays the current values for the Calendar property of the c
urrent UI culture. Calendar is just one property of UI culture. To see all
of the properties, type "get-uiculture | get-member".




-------------------------- EXAMPLE 4 --------------------------

C:\PS>(get-uiculture).datetimeformat.shortdatepattern

Description
-----------
This command displays the short date pattern for the current UI culture. To
see all of the subproperties of the DateTimeFormat property of the UI cult
ure, type "(get-uiculture).datetimeformat | gm".




REMARKS
To see the examples, type: "get-help Get-UICulture -examples".
For more information, type: "get-help Get-UICulture -detailed".
For technical information, type: "get-help Get-UICulture -full".

NAME
Get-Unique

SYNOPSIS
Returns the unique items from a sorted list.


SYNTAX
Get-Unique [-AsString] [-InputObject <psobject>] [<CommonParameters>]

Get-Unique [-OnType] [-InputObject <psobject>] [<CommonParameters>]


DESCRIPTION
The Get-Unique cmdlet compares each item in a sorted list to the next item,
eliminates duplicates, and returns only one instance of each item. The lis
t must be sorted for the cmdlet to work properly.

PARAMETERS
-AsString [<SwitchParameter>]
Treats the data as a string. Without this parameter, data is treated as
an object, so when you submit a collection of objects of the same type
to Get-Unique, such as a collection of files, it returns just one (the
first). You can use this parameter to find the unique values of object
properties, such as the file names.

-InputObject <psobject>
Accepts input for Get-Unique. Enter a variable that contains the object
s or type a command or expression that gets the objects.

Get-Unique treats the input submitted by using InputObject as a collect
ion; it does not enumerate individual items in the collection. Because
the collection is a single item, input submitted by using InputObject i
s always returned unchanged.

-OnType [<SwitchParameter>]
Returns only one object of each type.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$a = $(foreach ($line in get-content C:\Test1\File1.txt) {$line.tolow
er().split(" ")}) | sort | get-unique

C:\PS> $a.count

Description
-----------
These commands find the number of unique words in a text file.

The first command gets the content of the File.txt file. It converts each l
ine of text to lowercase letters and then splits each word onto a separate
line at the space (" "). Then, it sorts the resulting list alphabetically (
the default) and uses the Get-Unique cmdlet to eliminate any duplicate word
s. The results are stored in the $a variable.

The second command uses the Count property of the collection of strings in
$a to determine how many items are in $a.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>1,1,1,1,12,23,4,5,4643,5,3,3,3,3,3,3,3 | sort-object | Get-Unique

Description
-----------
This command finds the unique members of the set of integers. The first com
mand takes an array of integers typed at the command line, pipes them to th
e Sort-Object cmdlet to be sorted, and then pipes them to Get-Unique, which
eliminates duplicate entries.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-childitem | sort-object {$_.GetType()} | unique -OnType

Description
-----------
This command uses the Get-ChildItem cmdlet to retrieve the contents of the
local directory, which includes files and directories. The pipeline operato
r (|) sends the results to the Sort-Object cmdlet. The "$_.GetType()" state
ment applies the GetType method to each file or directory. Then, Sort-Objec
t sorts the items by type. Another pipeline operator sends the results to G
et-Unique. The OnType parameter directs Get-Unique to return only one objec
t of each type.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-process | sort-object | select processname | get-unique -asstring

Description
-----------
This command gets the names of processes running on the computer with dupli
cates eliminated.

The Get-Process command gets all of the processes on the computer. The pipe
line operator (|) passes the result to Sort-Object, which, by default, sort
s the processes alphabetically by ProcessName. The results are piped to the
Select-Object cmdlet, which selects only the values of the ProcessName pro
perty of each object. The results are then piped to Get-Unique to eliminate
duplicates.

The AsString parameter tells Get-Unique to treat the ProcessName values as
strings. Without this parameter, Get-Unique treats the ProcessName values a
s objects and returns only one instance of the object, that is, the first p
rocess name in the list.




REMARKS
To see the examples, type: "get-help Get-Unique -examples".
For more information, type: "get-help Get-Unique -detailed".
For technical information, type: "get-help Get-Unique -full".

NAME
Get-Variable

SYNOPSIS
Gets the variables in the current console.


SYNTAX
Get-Variable [[-Name] <string[]>] [-Exclude <string[]>] [-Include <string[]
>] [-Scope <string>] [-ValueOnly] [<CommonParameters>]


DESCRIPTION
The Get-Variable cmdlet gets the Windows PowerShell variables in the curren
t console. You can retrieve just the values of the variables by specifying
the ValueOnly parameter, and you can filter the variables returned by name.

PARAMETERS
-Exclude <string[]>
Omits the specified items. Wildcards are permitted.

-Include <string[]>
Specifies only the items upon which the cmdlet will act, excluding all
others. Wildcards are permitted.

-Name <string[]>
Specifies the name of the variable.

-Scope <string>
Gets only the variables in the specified scope. Valid values are "Globa
l", "Local", or "Script", or a number relative to the current scope (0
through the number of scopes, where 0 is the current scope and 1 is its
parent). "Local" is the default. For more information, see about_Scope
s.

-ValueOnly [<SwitchParameter>]
Gets only the value of the variable.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-variable m*

Description
-----------
This command displays variables with names that begin with the letter "m".
The value of the variables is also displayed.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-variable m* -valueonly

Description
-----------
This command displays only the values of the variables with names that begi
n with the letter "m".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-variable -include M*,P* | sort-object name

Description
-----------
This command gets information about the variables that begin with either th
e letter "M" or the letter "P". The results are piped to the Sort-Object cm
dlet, sorted by name, and displayed.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-variable -scope 0

C:\PS> compare-object (get-variable -scope 0) (get-variable -scope 1)

Description
-----------
The first command gets only the variables that are defined in the local sco
pe. It is equivalent to "get-variable -scope local" and can be abbreviated
as "gv -s 0".

The second command uses the Compare-Object cmdlet to find the variables tha
t are defined in the parent scope (Scope 1) but are visible only in the loc
al scope (Scope 0).




REMARKS
To see the examples, type: "get-help Get-Variable -examples".
For more information, type: "get-help Get-Variable -detailed".
For technical information, type: "get-help Get-Variable -full".

Get-Verb [[-verb] <String[]>] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-WarningAction <ActionPreference>] [-ErrorVariable <String>] [-WarningVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>]

NAME
Get-WinEvent

SYNOPSIS
Gets events from event logs and event tracing log files on local and remote
computers.


SYNTAX
Get-WinEvent [-LogName] <string[]> [-ComputerName <string>] [-Credential <P
SCredential>] [-FilterXPath <string>] [-Force <switch>] [-MaxEvents <int64>
] [-Oldest] [<CommonParameters>]

Get-WinEvent [-Path] <string[]> [-ComputerName <string>] [-Credential <PSCr
edential>] [-FilterXPath <string>] [-Force <switch>] [-MaxEvents <int64>] [
-Oldest] [<CommonParameters>]

Get-WinEvent [-ProviderName] <string[]> [-ComputerName <string>] [-Credenti
al <PSCredential>] [-FilterXPath <string>] [-Force <switch>] [-MaxEvents <i
nt64>] [-Oldest] [<CommonParameters>]

Get-WinEvent -FilterHashTable <Hashtable[]> [-ComputerName <string>] [-Cred
ential <PSCredential>] [-Force <switch>] [-MaxEvents <int64>] [-Oldest] [<C
ommonParameters>]

Get-WinEvent [-ListLog] <string[]> [-ComputerName <string>] [-Credential <P
SCredential>] [<CommonParameters>]

Get-WinEvent [-ListProvider] <string[]> [-ComputerName <string>] [-Credenti
al <PSCredential>] [<CommonParameters>]

Get-WinEvent -FilterXml <XmlDocument> [-ComputerName <string>] [-Credential
<PSCredential>] [-Force <switch>] [-MaxEvents <int64>] [-Oldest] [<CommonP
arameters>]


DESCRIPTION
The Get-WinEvent cmdlet gets events from event logs, including classic logs
, such as the System and Application logs, and the event logs that are gene
rated by the new Windows Event Log technology introduced in Windows Vista.
It also gets events in log files generated by Event Tracing for Windows (ET
W).

Without parameters, a Get-WinEvent command gets all the events from all the
event logs on the computer. To interrupt the command, press CTRL + C.

Get-WinEvent also lists event logs and event log providers. You can get eve
nts from selected logs or from logs generated by selected event providers.
And, you can combine events from multiple sources in a single command. Get-
WinEvent allows you to filter events by using XPath queries, structured XML
queries, and simplified hash-table queries.

Note: Get-WinEvent requires Windows Vista, Windows Server 2008 R2, or later
versions of Windows. And, it requires the Microsoft .NET Framework 3.5 or
a later version.

PARAMETERS
-ComputerName <string>
Gets events from the event logs on the specified computer. Type the Net
BIOS name, an Internet Protocol (IP) address, or the fully qualified do
main name of the computer. The default value is the local computer.

This parameter accepts only one computer name at a time. To find event
logs or events on multiple computers, use a ForEach statement. For more
information about this parameter, see the examples.

To get events and event logs from remote computers, the firewall port f
or the event log service must be configured to allow remote access.

This parameter does not rely on Windows PowerShell remoting. You can us
e the ComputerName parameter even if your computer is not configured to
run remote commands.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default value is the current user.

Type a user name, such as User01 or Domain01\User01. Or, enter a PSCred
ential object, such as one generated by the Get-Credential cmdlet. If y
ou type a user name, you will be prompted for a password. If you type o
nly the parameter name, you will be prompted for both a user name and a
password.

-FilterHashTable <Hashtable[]>
Uses a query in hash table format to select events from one or more eve
nt logs. The query contains a hash table with one or more key-value pai
rs.

Hash table queries have the following rules:
-- Keys and values are case-insensitive.
-- Wildcard characters are valid only in the values associated with the
LogName and ProviderName keys.
-- Each key can be listed only once in each hash-table.
-- The Path value takes paths to .etl, .evt, and .evtx log files.
-- The LogName, Path, and ProviderName keys can be used in the same que
ry.
-- The UserID key can take a valid security identifier (SID) or a domai
n account name that can be used to construct a valid System.Security.Pr
incipal.NTAccount object.
-- The Data value takes event data in an unnamed field. This is for eve
nts in classic event logs.
-- The * key represents a named event data field.
When Get-WinEvent cannot interpret a key-value pair, it interprets the
key as a case-sensitive name for the event data in the event.

The valid key-value pairs are as follows:
-- LogName=<String[]>
-- ProviderName=<String[]>
-- Path=<String[]>
-- Keywords=<Long[]>
-- ID=<Int32[]>
-- Level=<Int32[]>
-- StartTime=<DateTime>
-- EndTime=<DataTime>
-- UserID=<SID>
-- Data=<String[]>
-- *=<String[]>

-FilterXml <XmlDocument>
Uses a structured XML query to select events from one or more event log
s.

To generate a valid XML query, use the Create Custom View and Filter Cu
rrent Log features in Event Viewer. Use the items in the dialog box to
create a query, and then click the XML tab to view the query in XML for
mat. You can copy the XML from the XML tab into the value of the Filter
Xml parameter. For more information about the Event Viewer features, se
e Event Viewer Help.

Typically, you use an XML query to create a complex query that contains
several XPath statements. The XML format also allows you to use a "Sup
press" XML element that excludes events from the query. For more inform
ation about the XML schema for event log queries, see the following top
ics in the MSDN (Microsoft Developer Network) library.

-- "Query Schema": http://go.microsoft.com/fwlink/?LinkId=143685

-- "XML Event Queries" in "Event Selection": http://go.microsoft.com/fw
link/?LinkID=143608

-FilterXPath <string>
Uses an XPath query to select events from one or more logs.

For more information about the XPath language, see "Selection Filters"
in "Event Selection" and in the "XPath Reference" in the MSDN library.

-Force <switch>
Gets debug and analytic logs, in addition to other event logs. The Forc
e parameter is required to get a debug or analytic log when the value o
f the name parameter includes wildcard characters.

By default, Get-WinEvent excludes these logs unless you specify the ful
l name of a debug or analytic log.

-ListLog <string[]>
Gets the specified event logs. Enter the event log names in a comma-sep
arated list. Wildcards are permitted. To get all the logs, enter a valu
e of *.

-ListProvider <string[]>
Gets the specified event log providers. An event log provider is a prog
ram or service that writes events to the event log.

Enter the provider names in a comma-separated list. Wildcards are permi
tted. To get the providers of all the event logs on the computer, enter
a value of *.

-LogName <string[]>
Gets events from the specified event logs. Enter the event log names in
a comma-separated list. Wildcards are permitted. You can also pipe log
names to Get-WinEvent.

-MaxEvents <int64>
Specifies the maximum number of events that Get-WinEvent returns. Enter
an integer. The default is to return all the events in the logs or fil
es.

-Oldest [<SwitchParameter>]
Returns the events in oldest-first order. By default, events are retur
ned in newest-first order.

This parameter is required to get events from .etl and .evt files and f
rom debug and analytic logs. In these files, events are recorded in old
est-first order, and the events can be returned only in oldest-first or
der.

-Path <string[]>
Gets events from the specified event log files. Enter the paths to the
log files in a comma-separated list, or use wildcard characters to crea
te file path patterns.

Get-WinEvent supports files with the .evt, .evtx, and .etl file name ex
tensions. You can include events from different files and file types in
the same command.

-ProviderName <string[]>
Gets events written by the specified event log providers. Enter the pro
vider names in a comma-separated list, or use wildcard characters to cr
eate provider name patterns.

An event log provider is a program or service that writes events to the
event log. It is not a Windows PowerShell provider.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-winevent -listlog *

Description
-----------
This command gets all the logs on the local computer.

Logs are listed in the order that Get-WinEvent gets them. Classic logs are
usually retrieved first, followed by the new Windows Eventing logs.

Because there are typically more than a hundred event logs, this parameter
requires a log name or name pattern. To get all the logs, use *.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-winevent -listlog Setup | format-list -property *


FileSize : 69632
IsLogFull : False
LastAccessTime : 2/14/2008 12:55:12 AM
LastWriteTime : 7/9/2008 3:12:05 AM
OldestRecordNumber : 1
RecordCount : 3
LogName : Setup
LogType : Operational
LogIsolation : Application
IsEnabled : True
IsClassicLog : False
SecurityDescriptor : O:BAG:SYD:(A;;0xf0007;;;SY)(A;
(A;;0x1;;;S-1-5-32-573)
LogFilePath : %SystemRoot%\System32\Winevt\L
MaximumSizeInBytes : 1052672
LogMode : Circular
OwningProviderName : Microsoft-Windows-Eventlog
ProviderNames : {Microsoft-Windows-WUSA, Micro
ProviderLevel :
ProviderKeywords :
ProviderBufferSize : 64
ProviderMinimumNumberOfBuffers : 0
ProviderMaximumNumberOfBuffers : 64
ProviderLatency : 1000
ProviderControlGuid :

Description
-----------
These commands get an object that represents the classic System log on the
local computer. The object includes useful information about the log, inclu
ding its size, event log provider, file path, and whether it is enabled.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-winevent -listlog * -computername Server01| where {$_.recordcount
}

Description
-----------
This command gets only event logs on the Server01 computer that contain eve
nts. Many logs might be empty.

The command uses the RecordCount property of the EventLogConfiguration obje
ct that Get-WinEvent returns when you use the ListLog parameter.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$s = "Server01", "Server02", "Server03"

C:\PS> foreach ($server in $s)
{$server; get-winevent -listlog "Windows PowerShell" -computername $se
rver}

Description
-----------
The commands in this example get objects that represent the Windows PowerSh
ell event logs on the Server01, Server02, and Server03 computers. This comm
and uses the Foreach keyword because the ComputerName parameter takes only
one value.

The first command saves the names of the computers in the $s variable.

The second command uses a Foreach statement. For each of the computers in t
he $s variable, it performs the command in the script block (within the bra
ces). First, the command prints the name of the computer. Then, it runs a G
et-WinEvent command to get an object that represents the Windows PowerShell
log.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-winevent -listprovider *

Description
-----------
This command gets the event log providers on the local computer and the log
s to which they write, if any.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>(get-winevent -listlog Application).providernames

Description
-----------
This command gets all of the providers that write to the Application log on
the local computer.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>>get-winevent -listprovider *policy*

Description
-----------
This command gets the event log providers whose names include the word "pol
icy."




-------------------------- EXAMPLE 8 --------------------------

C:\PS>(get-winevent -listprovider microsoft-windows-grouppolicy).events | f
ormat-table id, description -auto

Description
-----------
This command lists the event IDs that the Microsoft-Windows-GroupPolicy eve
nt provider generates along with the event description.

It uses the Events property of the object that Get-WinEvent returns when yo
u use the ListProvider parameter, and it uses the ID and Description proper
ties of the object in the Events property.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>$events = get-winevent -logname "Windows PowerShell"

C:\PS> $events.count
195

C:\PS> $events | group-object id -noelement | sort-object count -desc
Count Name
----- ----
147 600
22 400
21 601
3 403
2 103

C:\PS> $events | group-object leveldisplayname -noelement
Count Name
----- ----
2 Warning
193 Information

Description
-----------
This example shows how to use the properties of the event objects that Get-
WinEvent returns to learn about the events in an event log.

The first command uses the Get-WinEvent cmdlet to get all of the events in
the Windows PowerShell event log. Then, it saves them in the $events variab
le. The log name is enclosed in quotation marks because it contains a space
.

The second command uses the Count property of object collections to find th
e number of entries in the event log.

The third command displays the incidence of each event in the log, with the
most frequent events first. In this example, event ID 600 is the most freq
uent event.

The fourth command groups the items by the value of their LevelDisplayName
property to show how many Error, Warning, and Information events are in the
log.




-------------------------- EXAMPLE 10 --------------------------

C:\PS>get-winevent -logname *disk*, Microsoft-Windows-Kernel-WHEA

Description
-----------
This command gets the error events whose names include "disk" from all of t
he event logs on the computer and from the Microsoft-Windows-Kernel-WHEA ev
ent log.




-------------------------- EXAMPLE 11 --------------------------

C:\PS>get-winevent -path 'c:\ps-test\Windows PowerShell.evtx'

Description
-----------
This command gets events from a copy of the Windows PowerShell event log fi
le in a test directory. The path is enclosed in quotation marks because the
log name includes a space.




-------------------------- EXAMPLE 12 --------------------------

C:\PS>get-winevent -path 'c:\tracing\tracelog.etl' -maxevents 100 -oldest

C:\PS> get-winevent -path 'c:\tracing\tracelog.etl' -oldest | sort-object -
property timecreated -desc | select-object -first 100

Description
-----------
These commands get the first 100 events from an Event Tracing for Windows (
ETW) event trace log file.

The first command gets the 100 oldest events in the log. It uses the Get-Wi
nEvent cmdlet to get events from the Tracelog.etl file. It uses the MaxEven
ts parameter to limit the retrieval to 100 events. Because the events are l
isted in the order in which they are written to the log (oldest first), the
Oldest parameter is required.

The second command gets the 100 newest events in the log. It uses the Get-W
inEvent cmdlet to get all the events from the Tracing.etl file. It passes
the events to the Sort-Object cmdlet, which sorts them in descending order
by the value of the TimeCreated property. Then, it sends the sorted events
to the Select-Object cmdlet to select the newest 100 events.




-------------------------- EXAMPLE 13 --------------------------

C:\PS>get-winevent -path "c:\tracing\tracelog.etl", "c:\Logs\Windows PowerS
hell.evtx" -oldest | where {$_.id -eq "103"}

Description
-----------
This example shows how to get the events from an event trace log file (.etl
) and from a copy of the Windows PowerShell log file (.evtx) that was saved
to a test directory.

You can combine multiple file types in a single command. Because the files
contain the same type of .NET Framework object (an EventLogRecord object),
you can use the same properties to filter them.

Note that the command requires the Oldest parameter because it is reading f
rom an .etl file, but the Oldest parameter applies to both of the files.




-------------------------- EXAMPLE 14 --------------------------

C:\PS># Use the Where-Object cmdlet
C:\PS> $yesterday = (get-date) - (new-timespan -day 1)
C:\PS> get-winevent -logname "Windows PowerShell" | where {$_.timecreated -
ge $yesterday}


# Uses FilterHashTable
C:\PS> $yesterday = (get-date) - (new-timespan -day 1)
C:\PS> get-winevent -FilterHashTable @{LogName='Windows PowerShell'; Level=
3; StartTime=$yesterday}


# Use FilterXML
C:\PS> get-winevent -FilterXML "<QueryList><Query><Select Path='Windows Pow
erShell'>*[System[Level=3 and TimeCreated[timediff(@SystemTime) <= 86400000
]]]</Select></Query></QueryList>"


# Use FilterXPath
C:\PS> get-winevent -LogName "Windows Powershell" -FilterXPath "*[System[Le
vel=3 and TimeCreated[timediff(@SystemTime) <= 86400000]]]"

Description
-----------
This example shows different filtering methods for selecting events from an
event log. All of these commands get events that occurred in the last 24 h
ours from the Windows PowerShell event log.

The filter methods are more efficient than using the Where-Object cmdlet be
cause the filters are applied while the objects are being retrieved, rather
than retrieving all the objects and then filtering them.

Because dates are difficult to formulate in the XML and XPath formats, to c
reate the XML content for the date, the Filter Current Log feature of Event
Viewer is used. For more information about this feature, see Event Viewer
Help.




-------------------------- EXAMPLE 15 --------------------------

C:\PS>$date = (get-date).AddDays(-2)

C:\PS> $events = get-winevent -FilterHashTable @{ logname = "Microsoft-Wind
ows-Diagnostics-Performance/Operational"; StartTime = $date; ID = 100 }

Description
-----------
This example uses a filter hash table to get events from the performance lo
g.

The first command uses the Get-Date cmdlet and the AddDays method to get a
date that is two days before the current date. It saves the date in the $da
te variable.

The second command uses the Get-WinEvent cmdlet with the FilterHashTable pa
rameter. The keys in the hash table define a filter that selects events fro
m the performance log that occurred within the last two days and that have
event ID 100.

The LogName key specifies the event log, the StartTime key specifies the da
te, and the ID key specifies the event ID.




-------------------------- EXAMPLE 16 --------------------------

C:\PS>$starttime = (get-date).adddays(-7)

C:\PS> $ie-error = Get-WinEvent -FilterHashtable @{logname="application"; p
rovidername="Application Error"; data="iexplore.exe"; starttime=$starttime}

Description
-----------
This example uses a filter hash table to find Internet Explorer application
errors that occurred within the last week.

The first command gets the date that is seven days before the current date
and stores it in the $starttime variable.

The second command uses the Get-WinEvent cmdlet with the FilterHashTable pa
rameter. The keys in the hash table define a filter that selects events fro
m the Application log that were written by the Application Error provider a
nd include the phrase "iexplore.exe".

The LogName key specifies the event log. The ProviderName key specifies the
event provider, the StartTime key specifies the starting date of the event
s, and the Data key specifies the text in the event message.




REMARKS
To see the examples, type: "get-help Get-WinEvent -examples".
For more information, type: "get-help Get-WinEvent -detailed".
For technical information, type: "get-help Get-WinEvent -full".

NAME
Get-WmiObject

SYNOPSIS
Gets instances of Windows Management Instrumentation (WMI) classes or infor
mation about the available classes.


SYNTAX
Get-WmiObject [-Authority <string>] [-Amended] [-AsJob] [-Authentication {D
efault | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy |
Unchanged}] [-ComputerName <string[]>] [-Credential <PSCredential>] [-Enab
leAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Imperson
ate | Delegate}] [-Locale <string>] [-Namespace <string>] [-ThrottleLimit <
int>] [<CommonParameters>]

Get-WmiObject [[-Class] <string>] [-Authority <string>] [-List] [-Recurse]
[-Amended] [-AsJob] [-Authentication {Default | None | Connect | Call | Pac
ket | PacketIntegrity | PacketPrivacy | Unchanged}] [-ComputerName <string[
]>] [-Credential <PSCredential>] [-EnableAllPrivileges] [-Impersonation {De
fault | Anonymous | Identify | Impersonate | Delegate}] [-Locale <string>]
[-Namespace <string>] [-ThrottleLimit <int>] [<CommonParameters>]

Get-WmiObject [-Authority <string>] [-Amended] [-AsJob] [-Authentication {D
efault | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy |
Unchanged}] [-ComputerName <string[]>] [-Credential <PSCredential>] [-Enab
leAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Imperson
ate | Delegate}] [-Locale <string>] [-Namespace <string>] [-ThrottleLimit <
int>] [<CommonParameters>]

Get-WmiObject [-Class] <string> [[-Property] <string[]>] [-Authority <strin
g>] [-DirectRead] [-Filter <string>] [-Amended] [-AsJob] [-Authentication {
Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy
| Unchanged}] [-ComputerName <string[]>] [-Credential <PSCredential>] [-Ena
bleAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Imperso
nate | Delegate}] [-Locale <string>] [-Namespace <string>] [-ThrottleLimit
<int>] [<CommonParameters>]

Get-WmiObject -Query <string> [-Authority <string>] [-DirectRead] [-Amended
] [-AsJob] [-Authentication {Default | None | Connect | Call | Packet | Pac
ketIntegrity | PacketPrivacy | Unchanged}] [-ComputerName <string[]>] [-Cre
dential <PSCredential>] [-EnableAllPrivileges] [-Impersonation {Default | A
nonymous | Identify | Impersonate | Delegate}] [-Locale <string>] [-Namespa
ce <string>] [-ThrottleLimit <int>] [<CommonParameters>]


DESCRIPTION
The Get-WmiObject cmdlet gets instances of WMI classes or information about
the available WMI classes. The ComputerName parameter can always be used t
o specify a remote computer. If the List parameter is specified, the cmdle
t gets information about the WMI classes that are available in a specified
namespace. If the Query parameter is specified, the cmdlet runs a WMI query
language (WQL) statement.

The Get-WmiObject cmdlet does not use the Windows PowerShell remoting infra
structure to perform remote operations. You can use the ComputerName parame
ter of the Get-WmiObject cmdlet even if your computer does not meet the req
uirements for Windows PowerShell remoting and even if your computer is not
configured for remoting in Windows PowerShell.

PARAMETERS
-Amended [<SwitchParameter>]
Gets or sets a value that indicates whether the objects that are return
ed from WMI should contain amended information. Typically, amended info
rmation is localizable information, such as object and property descrip
tions, that is attached to the WMI object..

-AsJob [<SwitchParameter>]
Runs the command as a background job. Use this parameter to run command
s that take a long time to finish.

When you use the AsJob parameter, the command returns an object that re
presents the background job and then displays the command prompt. You c
an continue to work in the session while the job finishes. If Get-WmiOb
ject is used against a remote computer, the job is created on the local
computer, and the results from remote computers are automatically retu
rned to the local computer. To manage the job, use the cmdlets that con
tain the Job noun (the Job cmdlets). To get the job results, use the Re
ceive-Job cmdlet.

Note: To use this parameter with remote computers, the local and remote
computers must be configured for remoting. Additionally, you must star
t Windows PowerShell by using the "Run as administrator" option in Wind
ows Vista and later versions of Windows,. For more information, see abo
ut_Remote_Requirements.

For more information about Windows PowerShell background jobs, see abo
ut_Jobs and about_Remote_Jobs.

-Authentication <AuthenticationLevel>
Specifies the authentication level to be used with the WMI connection.
Valid values are:

-1: Unchanged
0: Default
1: None (No authentication in performed.)
2: Connect (Authentication is performed only when the client establishe
s a relationship with the application.)
3: Call (Authentication is performed only at the beginning of each call
when the application receives the request.)
4: Packet (Authentication is performed on all the data that is received
from the client.)
5: PacketIntegrity (All the data that is transferred between the client
and the application is authenticated and verified.)
6: PacketPrivacy (The properties of the other authentication levels are
used, and all the data is encrypted.)

-Authority <string>
Specifies the authority to use to authenticate the WMI connection. You
can specify standard NTLM or Kerberos authentication. To use NTLM, set
the authority setting to ntlmdomain:<DomainName>, where <DomainName> id
entifies a valid NTLM domain name. To use Kerberos, specify kerberos:<D
omainName>\<ServerName>". You cannot include the authority setting when
you connect to the local computer.

-Class <string>
Specifies the name of a WMI class. When this parameter is used, the cmd
let retrieves instances of the WMI class.

-ComputerName <string[]>
Specifies the computer against which you want to run the management ope
ration. The value can be a fully qualified domain name, a NetBIOS name,
or an IP address. Use the local computer name, use localhost, or use a
dot (.) to specify the local computer. The local computer is the defau
lt. When the remote computer is in a different domain from the user, yo
u must use a fully qualified domain name. This parameter can also be pi
ped to the cmdlet.

This parameter does not rely on Windows PowerShell remoting, which uses
WS-Management ). You can use the ComputerName parameter of Get-WmiObje
ct even if your computer is not configured to run WS-Management remote
commands.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user. Type a user name, such as "User01", "Dom
ain01\User01", or User@Contoso.com. Or, enter a PSCredential object, su
ch as an object that is returned by the Get-Credential cmdlet. When you
type a user name, you will be prompted for a password.

-DirectRead [<SwitchParameter>]
Specifies whether direct access to the WMI provider is requested for th
e specified class without any regard to its base class or to its derive
d classes.

-EnableAllPrivileges [<SwitchParameter>]
Enables all the privileges of the current user before the command makes
the WMI call.

-Filter <string>
Specifies a Where clause to use as a filter. Uses the syntax of the WMI
Query Language (WQL).

Important: Do not include the Where keyword in the value of the paramet
er. For example, the following commands return only the logical disks t
hat where the DeviceID equals 'c:' and the services where the name equa
ls 'WinRM', without using the Where keyword:

get-WmiObject Win32_LogicalDisk -filter "DeviceID = 'c:' "
get-wmiobject win32_service -filter "name='WinRM'"

-Impersonation <ImpersonationLevel>
Specifies the impersonation level to use. Valid values are:

0: Default (reads the local registry for the default impersonation leve
l , which is usually set to "3: Impersonate".)
1: Anonymous (Hides the credentials of the caller.)
2: Identify (Allows objects to query the credentials of the caller.)
3: Impersonate (Allows objects to use the credentials of the caller.)
4: Delegate (Allows objects to permit other objects to use the credenti
als of the caller.)

-List [<SwitchParameter>]
Specifies whether to retrieve and display the names of the WMI classes
in the WMI repository namespace that is specified in the Namespace para
meter. The Default Namespace registry entry in the HKEY_LOCAL_MACHINE\
SOFTWARE\Microsoft\WBEM\Scripting registry key is not used by this cmdl
et to determine the default namespace. If you specify the List paramete
r but not the Namespace parameter, the root\CIMV2 namespace is used by
default.

-Locale <string>
Specifies the preferred locale for WMI objects. Specify the value of th
e Locale parameter as an array in the MS_<LCID> format in the preferred
order .

-Namespace <string>
When used with the Class parameter, this parameter specifies the WMI re
pository namespace where the referenced WMI class is located. When used
with the List parameter, it specifies the namespace from which to gath
er WMI class information.

-Property <string[]>
Specifies the WMI class property or set of properties to retrieve.

-Query <string>
Specifies a WMI Query Language (WQL) statement to run. Event queries ar
e not supported by this parameter.

-Recurse [<SwitchParameter>]
Makes the command search the current namespace and all other namespaces
for the class name that is specified in the Class parameter.

-ThrottleLimit <int>
Allows the user to specify a throttling value for the number of WMI ope
rations that can be executed simultaneously. This parameter is used tog
ether with the AsJob parameter.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-wmiobject win32_process


__GENUS : 2
__CLASS : Win32_Process
__SUPERCLASS : CIM_Process
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_Process.Handle="0"
__PROPERTY_COUNT : 45
__DERIVATION : {CIM_Process, CIM_LogicalElement, CIM_ManagedS
ystemElement}
__SERVER : SYSTEM01
__NAMESPACE : root\cimv2
__PATH : \\SYSTEM01\root\cimv2:Win32_Process.Handle="0"
Caption : System Idle Process
CommandLine :
CreationClassName : Win32_Process
CreationDate :
CSCreationClassName : Win32_ComputerSystem
CSName : SYSTEM01
Description : System Idle Process
ExecutablePath :
ExecutionState :
Handle : 0
HandleCount : 0
InstallDate :
KernelModeTime : 6138394740432
MaximumWorkingSetSize :
MinimumWorkingSetSize :
Name : System Idle Process
OSCreationClassName : Win32_OperatingSystem
OSName : Microsoftr Windows VistaT Ultimate |C:\Windows
|\Device\Harddisk0\Partition3
OtherOperationCount : 0
OtherTransferCount : 0
PageFaults : 0
PageFileUsage : 0
ParentProcessId : 0
PeakPageFileUsage : 0
PeakVirtualSize : 0
PeakWorkingSetSize : 0
Priority : 0
PrivatePageCount : 0
ProcessId : 0
QuotaNonPagedPoolUsage : 0
QuotaPagedPoolUsage : 0
QuotaPeakNonPagedPoolUsage : 0
QuotaPeakPagedPoolUsage : 0
ReadOperationCount : 0
ReadTransferCount : 0
SessionId : 0
Status :
TerminationDate :
ThreadCount : 2
UserModeTime : 0
VirtualSize : 0
WindowsVersion : 6.0.6001
WorkingSetSize : 24576
WriteOperationCount : 0
WriteTransferCount : 0
ProcessName : System Idle Process
Handles : 0
VM : 0
WS : 24576
Path :

...

Description
-----------
This command displays information about all the processes that are running
on a computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-wmiobject win32_service -computername 127.0.0.1

__GENUS : 2
__CLASS : Win32_Process
__SUPERCLASS : CIM_Process
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_Process.Handle="0"
__PROPERTY_COUNT : 45
__DERIVATION : {CIM_Process, CIM_LogicalElement, CIM_ManagedS
ystemElement}
__SERVER : SYSTEM02
__NAMESPACE : root\cimv2
__PATH : \\SYSTEM02\root\cimv2:Win32_Process.Handle="0"
Caption : System Idle Process
CommandLine :
CreationClassName : Win32_Process
CreationDate :
CSCreationClassName : Win32_ComputerSystem
CSName : SYSTEM02
Description : System Idle Process
ExecutablePath :
ExecutionState :
Handle : 0
HandleCount : 0
InstallDate :
KernelModeTime : 6138394740432
MaximumWorkingSetSize :
MinimumWorkingSetSize :
Name : System Idle Process
OSCreationClassName : Win32_OperatingSystem
OSName : Microsoftr Windows VistaT Ultimate |C:\Windows
|\Device\Harddisk0\Partition3
OtherOperationCount : 0
OtherTransferCount : 0
PageFaults : 0
PageFileUsage : 0
ParentProcessId : 0
PeakPageFileUsage : 0
PeakVirtualSize : 0
PeakWorkingSetSize : 0
Priority : 0
PrivatePageCount : 0
ProcessId : 0
QuotaNonPagedPoolUsage : 0
QuotaPagedPoolUsage : 0
QuotaPeakNonPagedPoolUsage : 0
QuotaPeakPagedPoolUsage : 0
ReadOperationCount : 0
ReadTransferCount : 0
SessionId : 0
Status :
TerminationDate :
ThreadCount : 2
UserModeTime : 0
VirtualSize : 0
WindowsVersion : 6.0.6001
WorkingSetSize : 24576
WriteOperationCount : 0
WriteTransferCount : 0
ProcessName : System Idle Process
Handles : 0
VM : 0
WS : 24576
Path :

...

Description
-----------
This command displays information about the services on the remote computer
. It displays the information by specifying the Internet Protocol (IP) addr
ess 127.0.0.1. You can change this IP address to any other valid IP address
on your network so that you can display information about the services on
that remote computer. By default, the account you are running under must be
a member of the local administrators group on the remote computer that you
specify .




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-wmiobject -namespace "root/default" -list


NameSpace: ROOT\default

Name Methods Properties
---- ------- ----------
__NotifyStatus {} {StatusCode}
__ExtendedStatus {} {Description, Oper
ation, ParameterInfo, ProviderName...}
__SecurityRelatedClass {} {}
__Trustee {} {Domain, Name, SID
, SidLength...}
__NTLMUser9X {} {Authority, Flags,
Mask, Name...}
__ACE {} {AccessMask, AceFl
ags, AceType, GuidInheritedObjectType...}
__SecurityDescriptor {} {ControlFlags, DAC
L, Group, Owner...}
__PARAMETERS {} {}
__SystemClass {} {}
__ProviderRegistration {} {provider}
__EventProviderRegistration {} {EventQueryList, p
rovider}
__ObjectProviderRegistration {} {InteractionType,
provider, QuerySupportLevels, SupportsBat...
__ClassProviderRegistration {} {CacheRefreshInter
val, InteractionType, PerUserSchema, prov...
__InstanceProviderRegistration {} {InteractionType,
provider, QuerySupportLevels, SupportsBat...
__MethodProviderRegistration {} {provider}
__PropertyProviderRegistration {} {provider, Support
sGet, SupportsPut}
__EventConsumerProviderRegistration {} {ConsumerClassName
s, provider}
__thisNAMESPACE {} {SECURITY_DESCRIPT
OR}
__NAMESPACE {} {Name}
__IndicationRelated {} {}
__FilterToConsumerBinding {} {Consumer, Creator
SID, DeliverSynchronously, DeliveryQoS...}
__EventConsumer {} {CreatorSID, Machi
neName, MaximumQueueSize}
LogFileEventConsumer {} {CreatorSID, Filen
ame, IsUnicode, MachineName...}
ActiveScriptEventConsumer {} {CreatorSID, KillT
imeout, MachineName, MaximumQueueSize...}
NTEventLogEventConsumer {} {Category, Creator
SID, EventID, EventType...}
SMTPEventConsumer {} {BccLine, CcLine,
CreatorSID, FromLine...}
CommandLineEventConsumer {} {CommandLineTempla
te, CreateNewConsole, CreateNewProcessGro...
__AggregateEvent {} {NumberOfEvents, R
epresentative}
__TimerNextFiring {} {NextEvent64BitTim
e, TimerId}
__EventFilter {} {CreatorSID, Event
Access, EventNamespace, Name...}
__Event {} {SECURITY_DESCRIPT
OR, TIME_CREATED}
__NamespaceOperationEvent {} {SECURITY_DESCRIPT
OR, TargetNamespace, TIME_CREATED}
__NamespaceModificationEvent {} {PreviousNamespace
, SECURITY_DESCRIPTOR, TargetNamespace, T...
__NamespaceDeletionEvent {} {SECURITY_DESCRIPT
OR, TargetNamespace, TIME_CREATED}
__NamespaceCreationEvent {} {SECURITY_DESCRIPT
OR, TargetNamespace, TIME_CREATED}
__ClassOperationEvent {} {SECURITY_DESCRIPT
OR, TargetClass, TIME_CREATED}
__ClassDeletionEvent {} {SECURITY_DESCRIPT
OR, TargetClass, TIME_CREATED}
__ClassModificationEvent {} {PreviousClass, SE
CURITY_DESCRIPTOR, TargetClass, TIME_CREA...
__ClassCreationEvent {} {SECURITY_DESCRIPT
OR, TargetClass, TIME_CREATED}
__InstanceOperationEvent {} {SECURITY_DESCRIPT
OR, TargetInstance, TIME_CREATED}
__InstanceCreationEvent {} {SECURITY_DESCRIPT
OR, TargetInstance, TIME_CREATED}

...

Description
-----------
This command displays the WMI classes in the root or default namespace of t
he local computer.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-wmiobject -query "select * from win32_service where name='WinRM'"
-computername server01, server02

ExitCode : 0
Name : WinRM
ProcessId : 1708
StartMode : Auto
State : Running
Status : OK

ExitCode : 0
Name : WinRM
ProcessId : 948
StartMode : Auto
State : Running
Status : OK

Description
-----------
This command displays information about the WinRM service on the computers
that are specified in the ComputerName parameter.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>(get-wmiobject win32_service -filter "name='WinRM'" -computername ser
ver01).StopService()

__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0

Another query using get-wmiobject -query "select * from win32_service where
name='WinRM'" -computername server01, shows the service as stopped.

ExitCode : 0
Name : WinRM
ProcessId : 0
StartMode : Auto
State : Stopped
Status : OK

Description
-----------
This command stops the WinRM service on the Server01 remote computer. The c
ommand uses the standard Get-WmiObject command and adds a call to the StopS
ervice method of the Win32_Service WMI class.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-wmiobject win32_bios | format-list *

Status : OK
Name : Phoenix ROM BIOS PLUS Version 1.10 2.3.1
Caption : Phoenix ROM BIOS PLUS Version 1.10 2.3.1
SMBIOSPresent : True
__GENUS : 2
__CLASS : Win32_BIOS
__SUPERCLASS : CIM_BIOSElement
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_BIOS.Name="Phoenix ROM BIOS PLUS Version 1.10
2.3.1 ",SoftwareElementID="Phoenix ROM BIOS
PLUS Version 1.10 2.3.1 ",SoftwareElementState=3,T
argetOperatingSystem=0,Version="DELL - 14"
__PROPERTY_COUNT : 27
__DERIVATION : {CIM_BIOSElement, CIM_SoftwareElement, CIM_LogicalE
lement, CIM_ManagedSystemElement}
__SERVER : SERVER01
__NAMESPACE : root\cimv2
__PATH : \\SERVER01\root\cimv2:Win32_BIOS.Name="Phoenix ROM
BIOS PLUS Version 1.10 2.3.1 ",Software
ElementID="Phoenix ROM BIOS PLUS Version 1.10 2.3.1
",SoftwareElementState=3,TargetOperatingSys
tem=0,Version="DELL - 14"
BiosCharacteristics : {7, 9, 10, 11...}
BIOSVersion : {DELL - 14, Phoenix ROM BIOS PLUS Version 1.10 2.
3.1 , Phoenix ROM BIOS PLUS Version 1.10 2.3
.1 , Phoenix ROM BIOS PLUS Version 1.10 2.3.1 }
BuildNumber :
CodeSet :
CurrentLanguage : en|US|iso8859-1
Description : Phoenix ROM BIOS PLUS Version 1.10 2.3.1
IdentificationCode :
InstallableLanguages : 1
InstallDate :
LanguageEdition :
ListOfLanguages : {en|US|iso8859-1}
Manufacturer : Dell Inc.
OtherTargetOS :
PrimaryBIOS : True
ReleaseDate : 20070521000000.000000+000
SerialNumber : 8PWRVD1
SMBIOSBIOSVersion : 2.3.1
SMBIOSMajorVersion : 2
SMBIOSMinorVersion : 3
SoftwareElementID : Phoenix ROM BIOS PLUS Version 1.10 2.3.1
SoftwareElementState : 3
TargetOperatingSystem : 0
Version : DELL - 14
Scope : System.Management.ManagementScope
Path : \\SERVER01\root\cimv2:Win32_BIOS.Name="Phoenix ROM
BIOS PLUS Version 1.10 2.3.1 ",Software
ElementID="Phoenix ROM BIOS PLUS Version 1.10 2.3.1
",SoftwareElementState=3,TargetOperatingSys
tem=0,Version="DELL - 14"
Options : System.Management.ObjectGetOptions
ClassPath : \\SERVER01\root\cimv2:Win32_BIOS
Properties : {BiosCharacteristics, BIOSVersion, BuildNumber, Cap
tion...}
SystemProperties : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY...}
Qualifiers : {dynamic, Locale, provider, UUID}
Site :
Container :

Description
-----------
This command displays BIOS information. It displays all the properties of t
he WMI class, not just the properties that are specified in the Types.ps1xm
l configuration file.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-wmiobject win32_service -credential FABRIKAM\administrator -compu
ter fabrikam

ExitCode : 0
Name : AeLookupSvc
ProcessId : 0
StartMode : Manual
State : Stopped
Status : OK

ExitCode : 1077
Name : ALG
ProcessId : 0
StartMode : Manual
State : Stopped
Status : OK

ExitCode : 1077
Name : AppIDSvc
ProcessId : 0
StartMode : Manual
State : Stopped
Status : OK

ExitCode : 0
Name : Appinfo
ProcessId : 888
StartMode : Manual
State : Running
Status : OK

ExitCode : 1077
Name : AppMgmt
ProcessId : 0
StartMode : Manual
State : Stopped
Status : OK

...

Description
-----------
This command displays service information on a computer named Fabrikam. It
specifies a user account name by using the Credential parameter, which caus
es a dialog box to be displayed in which you enter the corresponding passwo
rd.




REMARKS
To see the examples, type: "get-help Get-WmiObject -examples".
For more information, type: "get-help Get-WmiObject -detailed".
For technical information, type: "get-help Get-WmiObject -full".

NAME
Get-WSManCredSSP

SYNOPSIS
Gets the Credential Security Service Provider-related configuration for the
client.


SYNTAX
Get-WSManCredSSP [<CommonParameters>]


DESCRIPTION
The Get-WSManCredSPP cmdlet gets the Credential Security Service Provider-r
elated configuration of the client and the server. The output indicates whe
ther Credential Security Service Provider (CredSSP) authentication is enabl
ed or disabled. It also displays configuration information for the AllowFre
shCredentials policy of CredSSP. When you use CredSSP authentication, the u
ser's credentials are passed to a remote computer to be authenticated. This
type of authentication is designed for commands that create a remote sessi
on from within another remote session. For example, you use this type of au
thentication if you want to run a background job on a remote computer.

The cmdlet performs the following actions:

- Gets the WS-Management CredSSP setting on the client (<localhost|comp
utername>\Client\Auth\CredSSP).
- Gets the Windows CredSSP policy setting AllowFreshCredentials.
- Gets the WS-Management CredSSP setting on the server (<localhost|comp
utername>\Service\Auth\CredSSP).

Caution: CredSSP authentication delegates the user's credentials from the l
ocal computer to a remote computer. This practice increases the security ri
sk of the remote operation. If the remote computer is compromised, when cre
dentials are passed to it, the credentials can be used to control the netwo
rk session.

To disable CredSSP authentication, use the Disable-WSManCredSSP cmdlet. To
enable CredSSP authentication, use the Enable-WSManCredSSP cmdlet.

PARAMETERS
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-wsmancredssp

Description
-----------
This command displays CredSSP configuration information for both the client
and server.

The output identifies that this computer is or is not configured for CredSS
P.

If the computer is configured for CredSSP, this is the output:

"The machine is configured to allow delegating fresh credentials to the fol
lowing target(s): wsman/server02.accounting.fabrikam.com"

If the computer is not configured for CredSSP, this is the output:

"The machine is not configured to allow delegating fresh credentials."




REMARKS
To see the examples, type: "get-help Get-WSManCredSSP -examples".
For more information, type: "get-help Get-WSManCredSSP -detailed".
For technical information, type: "get-help Get-WSManCredSSP -full".

NAME
Get-WSManInstance

SYNOPSIS
Displays management information for a resource instance specified by a Reso
urce URI.


SYNTAX
Get-WSManInstance -SelectorSet <hashtable> [-ApplicationName <string>] [-Co
mputerName <string>] [-Credential <PSCredential>] [-Fragment <string>] [-Po
rt <int>] [-UseSSL] [-ResourceURI] <Uri> [-Authentication <Authentication>]
[-Dialect <Uri>] [-OptionSet <hashtable>] [-SessionOption <hashtable>] [<C
ommonParameters>]

Get-WSManInstance [-ApplicationName <string>] [-BasePropertiesOnly <switch>
] [-ComputerName <string>] [-Credential <PSCredential>] [-Enumerate] [-filt
er <string>] [-Port <int>] [-References <switch>] [-ReturnType <string>] [-
Shallow <switch>] [-UseSSL] [-ResourceURI] <Uri> [-Authentication <Authenti
cation>] [-Dialect <Uri>] [-OptionSet <hashtable>] [-SessionOption <hashtab
le>] [<CommonParameters>]

Get-WSManInstance -ConnectionURI <Uri> -SelectorSet <hashtable> [-Fragment
<string>] [-ResourceURI] <Uri> [-Authentication <Authentication>] [-Dialect
<Uri>] [-OptionSet <hashtable>] [-SessionOption <hashtable>] [<CommonParam
eters>]

Get-WSManInstance -ConnectionURI <Uri> [-BasePropertiesOnly <switch>] [-Enu
merate] [-filter <string>] [-References <switch>] [-ReturnType <string>] [-
Shallow <switch>] [-ResourceURI] <Uri> [-Authentication <Authentication>] [
-Dialect <Uri>] [-OptionSet <hashtable>] [-SessionOption <hashtable>] [<Com
monParameters>]


DESCRIPTION
The Get-WSManInstance cmdlet retrieves an instance of a management resource
that is specified by a resource URI. The information that is retrieved can
be a complex XML information set (an object) or a simple value. This cmdl
et is the equivalent to the standard WS-Management Get command.

This cmdlet uses the WS-Management connection/transport layer to retrieve i
nformation.

PARAMETERS
-ApplicationName <string>
Specifies the application name in the connection. The default value of
the ApplicationName parameter is "WSMAN". The complete identifier for t
he remote endpoint is in the following format:

<transport>://<server>:<port>/<ApplicationName>

For example:

http://server01:8080/WSMAN

Internet Information Services (IIS), which hosts the session, forwards
requests with this endpoint to the specified application. This default
setting of "WSMAN" is appropriate for most uses. This parameter is desi
gned to be used when numerous computers establish remote connections to
one computer that is running Windows PowerShell. In this case, IIS hos
ts Web Services for Management (WS-Management) for efficiency.

-Authentication <Authentication>
Specifies the authentication mechanism to be used at the server. Possib
le values are:

- Basic: Basic is a scheme in which the user name and password are sent
in clear text to the server or proxy.
- Default : Use the authentication method implemented by the WS-Managem
ent protocol. This is the default.
- Digest: Digest is a challenge-response scheme that uses a server-spec
ified data string for the challenge.
- Kerberos: The client computer and the server mutually authenticate by
using Kerberos certificates.
- Negotiate: Negotiate is a challenge-response scheme that negotiates w
ith the server or proxy to determine the scheme to use for authenticati
on. For example, this parameter value allows negotiation to determine w
hether the Kerberos protocol or NTLM is used.
- CredSSP: Use Credential Security Service Provider (CredSSP) authentic
ation, which allows the user to delegate credentials. This option is de
signed for commands that run on one remote computer but collect data fr
om or run additional commands on other remote computers.

Caution: CredSSP delegates the user's credentials from the local comput
er to a remote computer. This practice increases the security risk of t
he remote operation. If the remote computer is compromised, when creden
tials are passed to it, the credentials can be used to control the netw
ork session.

-BasePropertiesOnly <switch>
Enumerates only the properties that are part of the base class that is
specified by the ResourceURI parameter. This parameter has no effect if
the Shallow parameter is specified.

-ComputerName <string>
Specifies the computer against which you want to run the management ope
ration. The value can be a fully qualified domain name, a NetBIOS name,
or an IP address. Use the local computer name, use localhost, or use a
dot (.) to specify the local computer. The local computer is the defau
lt. When the remote computer is in a different domain from the user, yo
u must use a fully qualified domain name must be used. You can pipe a v
alue for this parameter to the cmdlet.

-ConnectionURI <Uri>
Specifies the connection endpoint. The format of this string is:

<Transport>://<Server>:<Port>/<ApplicationName>

The following string is a properly formatted value for this parameter:

http://Server01:8080/WSMAN

The URI must be fully qualified.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user. Type a user name, such as "User01", "Dom
ain01\User01", or "User@Domain.com". Or, enter a PSCredential object, s
uch as one returned by the Get-Credential cmdlet. When you type a user
name, you will be prompted for a password.

-Dialect <Uri>
Specifies the dialect to use in the filter predicate. This can be any d
ialect that is supported by the remote service. The following aliases c
an be used for the dialect URI:

- WQL: http://schemas.microsoft.com/wbem/wsman/1/WQL
- Selector: http://schemas.microsoft.com/wbem/wsman/1/wsman/SelectorFil
ter
- Association: http://schemas.dmtf.org/wbem/wsman/1/cimbinding/associat
ionFilter

-Enumerate [<SwitchParameter>]
Returns all of the instances of a management resource.

-filter <string>
Specifies the filter expression for the enumeration. If you use this pa
rameter, you must also specify the Dialect parameter.

The valid values of this parameter depend on the dialect that is specif
ied in the Dialect parameter. For example, if the Dialect parameter is
set to WQL, the Filter parameter must contain a string, and the string
must contain a valid WQL query such as the following query:

"Select * from Win32_Service where State != Running"

If the Dialect parameter is set to Association, the Filter parameter mu
st contain a string, and the string must contain a valid filter, such a
s the following filter:

-filter:Object=EPR[;AssociationClassName=AssocClassName][;ResultClassNa
me=ClassName][;Role=RefPropertyName][;ResultRole=RefPropertyName]}

-Fragment <string>
Specifies a section inside the instance that is to be updated or retrie
ved for the specified operation. For example, to get the status of a sp
ooler service, specify "-Fragment Status".

-OptionSet <hashtable>
Passes a set of switches to a service to modify or refine the nature
of the request. These are similar to switches used in command-line shel
ls because they are service specific. Any number of options can be spec
ified.

The following example demonstrates the syntax that passes the values 1,
2, and 3 for the a, b, and c parameters:

-OptionSet @{a=1;b=2;c=3}

-Port <int>
Specifies the port to use when the client connects to the WinRM service
. When the transport is HTTP, the default port is 80. When the transpor
t is HTTPS, the default port is 443. When you use HTTPS as the transpor
t, the value of the ComputerName parameter must match the server's cert
ificate common name (CN). However, if the SkipCNCheck parameter is spec
ified as part of the SessionOption parameter, then the certificate comm
on name of the server does not have to match the host name of the serve
r. The SkipCNCheck parameter should be used only for trusted computers.

-References <switch>
Indicates that association instances (not associated instances) should
be retrieved. You can use this parameter only when the Dialect paramete
r is set to a value of "Association".

-ResourceURI <Uri>
Contains the Uniform Resource Identifier (URI) of the resource class or
instance. The URI is used to identify a specific type of resource, suc
h as disks or processes, on a computer.

A URI consists of a prefix and a path to a resource. For example:

http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Log
icalDisk
http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_NumericSenso
r

-ReturnType <string>
Specifies the type of data to be returned. The valid values are:

Object (the default)
EPR
ObjectAndEPR

If Object is specified or if this parameter is not used, only objects a
re returned. If EPR (endpoint reference) is specified, only the endpoin
t references of the objects are returned. Endpoint references contain i
nformation about the resource URI and the selectors for the instance. I
f ObjectAndEPR is specified, both the object and its associated endpoin
t references are returned.

-SelectorSet <hashtable>
Specifies a set of value pairs that are used to select particular manag
ement resource instances. The SelectorSet parameter is used when more t
han one instance of the resource exists. The value of the SelectorSet p
arameter must be a hash table.

The following example shows how to enter a value for this parameter:

-SelectorSet @{Name="WinRM";ID="yyy"}

-SessionOption <hashtable>
Defines a set of extended options for the WS-Management session. Enter
a SessionOption object that you create by using the New-WSManSessionOpt
ion cmdlet. For more information about the options that are available,
see New-WSManSessionOption.

-Shallow <switch>
Causes only instances of the base class that is specified in the resour
ce URI to be returned. If this switch is not specified, instances of th
e base class that is specified in the URI and in all its derived classe
s is returned.

-UseSSL [<SwitchParameter>]
Specifies that the Secure Sockets Layer (SSL) protocol should be used t
o establish a connection to the remote computer. By default, SSL is not
used.

WS-Management encrypts all the Windows PowerShell content that is tran
smitted over the network. The UseSSL parameter lets you specify the add
itional protection of HTTPS instead of HTTP. If SSL is not available on
the port that is used for the connection and you specify this paramete
r, the command fails.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-wsmaninstance wmicimv2/win32_service -selectorset @{name="winrm"}
-computername server01

xsi : http://www.w3.org/2001/XMLSchema-instance
p : http://schemas.microsoft.com/wbem/wsman/1/wmi/roo
t/cimv2/Win32_Service
cim : http://schemas.dmtf.org/wbem/wscim/1/common
type : p:Win32_Service_Type
lang : en-US
AcceptPause : false
AcceptStop : true
Caption : Windows Remote Management (WS-Management)
CheckPoint : 0
CreationClassName : Win32_Service
Description : Windows Remote Management (WinRM) service impleme
nts the WS-Management protocol for remote
management. WS-Management is a standard web servi
ces protocol used for remote software and
hardware management. The WinRM service listens on
the network for WS-Management requests
and processes them. The WinRM Service needs to be
configured with a listener using the
winrm.cmd command line tool or through Group Poli
cy in order for it to listen over the
network. The WinRM service provides access to WMI
data and enables event collection. Event
collection and subscription to events require tha
t the service is running. WinRM messages
use HTTP and HTTPS as transports. The WinRM servi
ce does not depend on IIS but is
preconfigured to share a port with IIS on the sam
e machine. The WinRM service reserves the
/wsman URL prefix. To prevent conflicts with IIS,
administrators should ensure that any
websites hosted on IIS do not use the /wsman URL
prefix.
DesktopInteract : false
DisplayName : Windows Remote Management (WS-Management)
ErrorControl : Normal
ExitCode : 0
InstallDate : InstallDate
Name : winrm
PathName : C:\Windows\System32\svchost.exe -k NetworkService
ProcessId : 948
ServiceSpecificExitCode : 0
ServiceType : Share Process
Started : true
StartMode : Auto
StartName : NT AUTHORITY\NetworkService
State : Running
Status : OK
SystemCreationClassName : Win32_ComputerSystem
SystemName : SERVER01
TagId : 0
WaitHint : 0

Description
-----------
This command returns all of the information that Windows Management Instrum
entation (WMI) exposes about the WinRM service on the remote server01 compu
ter.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-wsmaninstance wmicimv2/win32_service -selectorset @{name="spooler
"} -fragment status -computername server01

XmlFragment=OK

Description
-----------
This command returns only the status of the Spooler service on the remote s
erver01 computer.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-wsmaninstance -enumerate wmicimv2/win32_process

OSName : Microsoft Windows Vista Ultimate |C:\Windows|\
Device\Harddisk0\Partition3
OtherOperationCount : 11441
OtherTransferCount : 428570
PageFaults : 27346
PageFileUsage : 16428
ParentProcessId : 604
PeakPageFileUsage : 17588
PeakVirtualSize : 93876224
PeakWorkingSetSize : 12472
Priority : 8
PrivatePageCount : 16822272
ProcessId : 1160
QuotaNonPagedPoolUsage : 14
QuotaPagedPoolUsage : 126
QuotaPeakNonPagedPoolUsage : 16
QuotaPeakPagedPoolUsage : 159
ReadOperationCount : 29568
ReadTransferCount : 1660581404
SessionId : 0
Status : Status
TerminationDate : TerminationDate
ThreadCount : 23
UserModeTime : 763156892
VirtualSize : 80846848
WindowsVersion : 6.0.6001
WorkingSetSize : 11624448
WriteOperationCount : 1913
WriteTransferCount : 6825768

xsi : http://www.w3.org/2001/XMLSchema-instance
p : http://schemas.microsoft.com/wbem/wsman/1/wmi/
root/cimv2/Win32_Process
cim : http://schemas.dmtf.org/wbem/wscim/1/common
type : p:Win32_Process_Type
lang : en-US
Caption : svchost.exe
CommandLine : C:\Windows\System32\svchost.exe -k LocalSystem
NetworkRestricted
CreationClassName : Win32_Process
CreationDate : CreationDate
CSCreationClassName : Win32_ComputerSystem
CSName : COMPUTER01
Description : svchost.exe
ExecutablePath : C:\Windows\System32\svchost.exe
ExecutionState : ExecutionState
Handle : 1192
HandleCount : 832

...

Description
-----------
This command returns all the instances of the WMI Win32_Process class on th
e local computer.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-wsmaninstance -enumerate wmicimv2/win32_service -returntype epr

xsi : http://www.w3.org/2001/XMLSchema-instance
p : http://schemas.microsoft.com/wbem/wsman/1/wmi/roo
t/cimv2/Win32_Service
cim : http://schemas.dmtf.org/wbem/wscim/1/common
type : p:Win32_Service_Type
lang : en-US
AcceptPause : false
AcceptStop : false
Caption : Visual Studio 2008 Remote Debugger
CheckPoint : 0
CreationClassName : Win32_Service
Description : Allows members of the Administrators group to rem
otely debug server applications using Visual
Studio 2008. Use the Visual Studio 2008 Remote D
ebugging Configuration Wizard to enable this
service.
DesktopInteract : false
DisplayName : Visual Studio 2008 Remote Debugger
ErrorControl : Ignore
ExitCode : 1077
InstallDate : InstallDate
Name : msvsmon90
PathName : "C:\Program Files\Microsoft Visual Studio 9.0\Com
mon7\IDE\Remote Debugger\x86\msvsmon.exe" /s
ervice msvsmon90
ProcessId : 0
ServiceSpecificExitCode : 0
ServiceType : Own Process
Started : false
StartMode : Disabled
StartName : LocalSystem
State : Stopped
Status : OK
SystemCreationClassName : Win32_ComputerSystem
SystemName : COMPUTER01
TagId : 0
WaitHint : 0

...

Description
-----------
This command returns endpoint references that correspond to all the service
s on the local computer.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>Get-WSManInstance -Enumerate wmicimv2/* -filter "select * from win32_
service where StartMode = 'Auto' and State = 'Stopped'" -computername serve
r01

xsi : http://www.w3.org/2001/XMLSchema-instance
p : http://schemas.microsoft.com/wbem/wsman/1/wmi/roo
t/cimv2/Win32_Service
cim : http://schemas.dmtf.org/wbem/wscim/1/common
type : p:Win32_Service_Type
lang : en-US
AcceptPause : false
AcceptStop : false
Caption : Windows Media Center Service Launcher
CheckPoint : 0
CreationClassName : Win32_Service
Description : Starts Windows Media Center Scheduler and Windows
Media Center Receiver services
at startup if TV is enabled within Windows Media
Center.
DesktopInteract : false
DisplayName : Windows Media Center Service Launcher
ErrorControl : Ignore
ExitCode : 0
InstallDate : InstallDate
Name : ehstart
PathName : C:\Windows\system32\svchost.exe -k LocalServiceNo
Network
ProcessId : 0
ServiceSpecificExitCode : 0
ServiceType : Share Process
Started : false
StartMode : Auto
StartName : NT AUTHORITY\LocalService
State : Stopped
Status : OK
SystemCreationClassName : Win32_ComputerSystem
SystemName : Server01
TagId : 0
WaitHint : 0

...

Description
-----------
This command lists all of the services that meet the following criteria on
the remote server01 computer:

- The startup type of the service is "Automatic".
- The service is stopped.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-wsmaninstance winrm/config/listener -selectorset @{Address="*";Tr
ansport="http"}

cfg : http://schemas.microsoft.com/wbem/wsman/1/config/li
stener
xsi : http://www.w3.org/2001/XMLSchema-instance
lang : en-US
Address : *
Transport : HTTP
Port : 80
Hostname :
Enabled : true
URLPrefix : wsman
CertificateThumbprint :
ListeningOn : {100.0.0.1, 123.123.123.123, ::1, 2001:4898:0:fff:0
:5efe:123.123.123.123...}

Description
-----------
This command lists the WS-Management listener configuration on the local co
mputer for the listener that matches the criteria in the selector set.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-wsmaninstance winrm/config/listener -selectorset @{Address="*";Tr
ansport="http"} -computername server01

cfg : http://schemas.microsoft.com/wbem/wsman/1/config/li
stener
xsi : http://www.w3.org/2001/XMLSchema-instance
lang : en-US
Address : *
Transport : HTTP
Port : 80
Hostname :
Enabled : true
URLPrefix : wsman
CertificateThumbprint :
ListeningOn : {100.0.0.1, 123.123.123.124, ::1, 2001:4898:0:fff:0
:5efe:123.123.123.124...}

Description
-----------
This command lists the WS-Management listener configuration on the remote s
erver01 computer for the listener that matches the criteria in the selector
set.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>Get-WSManInstance -Enumerate -Dialect association -filter "{Object=wi
n32_service?name=winrm}" -res wmicimv2/*

xsi : http://www.w3.org/2001/XMLSchema-instance
p : http://schemas.microsoft.com/wbem/wsman/1/wmi/r
oot/cimv2/Win32_ComputerSystem
cim : http://schemas.dmtf.org/wbem/wscim/1/common
type : p:Win32_ComputerSystem_Type
lang : en-US
AdminPasswordStatus : 1
AutomaticManagedPagefile : true
AutomaticResetBootOption : true
AutomaticResetCapability : true
BootOptionOnLimit : BootOptionOnLimit
BootOptionOnWatchDog : BootOptionOnWatchDog
BootROMSupported : true
BootupState : Normal boot
Caption : SERVER01
ChassisBootupState : 3
CreationClassName : Win32_ComputerSystem
CurrentTimeZone : -480
DaylightInEffect : false
Description : AT/AT COMPATIBLE
DNSHostName : server01
Domain : site01.corp.fabrikam.com
DomainRole : 1
EnableDaylightSavingsTime : true
FrontPanelResetStatus : 2
InfraredSupported : false
InstallDate : InstallDate
KeyboardPasswordStatus : 2
LastLoadInfo : LastLoadInfo
Manufacturer : Dell Inc.
Model : OptiPlex 745
Name : SERVER01
NameFormat : NameFormat
NetworkServerModeEnabled : true
NumberOfLogicalProcessors : 2
NumberOfProcessors : 1
OEMStringArray : www.dell.com
PartOfDomain : true
PauseAfterReset : -1
PCSystemType : 5
PowerManagementSupported : PowerManagementSupported
PowerOnPasswordStatus : 1
PowerState : 0
PowerSupplyState : 3
PrimaryOwnerContact : PrimaryOwnerContact
PrimaryOwnerName : testuser01
ResetCapability : 1
ResetCount : -1
ResetLimit : -1
Roles : {LM_Workstation, LM_Server, SQLServer, NT}
Status : OK
SystemStartupDelay : SystemStartupDelay
SystemStartupSetting : SystemStartupSetting
SystemType : X86-based PC
ThermalState : 3
TotalPhysicalMemory : 3217760256
UserName : FABRIKAM\testuser01
WakeUpType : 6
Workgroup : Workgroup

xsi : http://www.w3.org/2001/XMLSchema-instance
p : http://schemas.microsoft.com/wbem/wsman/1/wmi/roo
t/cimv2/Win32_Service
cim : http://schemas.dmtf.org/wbem/wscim/1/common
type : p:Win32_Service_Type
lang : en-US
AcceptPause : false
AcceptStop : false
Caption : Remote Procedure Call (RPC)
CheckPoint : 0
CreationClassName : Win32_Service
Description : Serves as the endpoint mapper and COM Service Con
trol Manager. If this service is stopped
or disabled, programs using COM or Remote Procedu
re Call (RPC) services will not function
properly.
DesktopInteract : false
DisplayName : Remote Procedure Call (RPC)
ErrorControl : Normal
ExitCode : 0
InstallDate : InstallDate
Name : RpcSs
PathName : C:\Windows\system32\svchost.exe -k rpcss
ProcessId : 1100
ServiceSpecificExitCode : 0
ServiceType : Share Process
Started : true
StartMode : Auto
StartName : NT AUTHORITY\NetworkService
State : Running
Status : OK
SystemCreationClassName : Win32_ComputerSystem
SystemName : SERVER01
TagId : 0
WaitHint : 0

xsi : http://www.w3.org/2001/XMLSchema-instance
p : http://schemas.microsoft.com/wbem/wsman/1/wmi/roo
t/cimv2/Win32_SystemDriver
cim : http://schemas.dmtf.org/wbem/wscim/1/common
type : p:Win32_SystemDriver_Type
lang : en-US
AcceptPause : false
AcceptStop : true
Caption : HTTP
CreationClassName : Win32_SystemDriver
Description : HTTP
DesktopInteract : false
DisplayName : HTTP
ErrorControl : Normal
ExitCode : 0
InstallDate : InstallDate
Name : HTTP
PathName : C:\Windows\system32\drivers\HTTP.sys
ServiceSpecificExitCode : 0
ServiceType : Kernel Driver
Started : true
StartMode : Manual
StartName :
State : Running
Status : OK
SystemCreationClassName : Win32_ComputerSystem
SystemName : SERVER01
TagId : 0

Description
-----------
This command gets the associated instances that are related to the specifie
d instance (winrm).

Important: You must enclose the filter in quotation marks, as shown in the
example.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>Get-WSManInstance -Enumerate -Dialect association -References -filter
"{Object=win32_service?name=winrm}" -res wmicimv2/*

Description
-----------
This command gets association instances that are related to the specified i
nstance (winrm). Because the Dialect parameter is set to "association" and
the Reference parameter is used, this command returns association instance
s, not associated instances.

Important: You must enclose the filter in quotation marks, as shown in the
example.




REMARKS
To see the examples, type: "get-help Get-WSManInstance -examples".
For more information, type: "get-help Get-WSManInstance -detailed".
For technical information, type: "get-help Get-WSManInstance -full".

NAME
Get-History

SYNOPSIS
Gets a list of the commands entered during the current session.


SYNTAX
Get-History [[-Id] <Int64[]>] [[-Count] <int>] [<CommonParameters>]


DESCRIPTION
The Get-History cmdlet gets the session history, that is, the list of comma
nds entered during the current session. Windows PowerShell automatically ma
intains a history of each session. You can save the session history in XML
or CSV format. By default, history files are saved in the home directory, b
ut you can save the file in any location.

PARAMETERS
-Count <int>
Displays the specified number of the most recent history entries. The d
efault is 32. If you use both the Count and Id parameters in a command,
the display ends with the command specified by the Id parameter.

-Id <Int64[]>
Specifies the ID number of a command in the session history. Get-Histor
y gets only the specified command. If you use Id and Count, Get-History
gets the most recent commands ending with the command specified by the
Id parameter.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-history

Description
-----------
This command gets the 32 most recently submitted commands. The default disp
lay shows each command and its ID, which indicates the order of execution.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-history | where-object {$_.commandLine -like "*service*"}

Description
-----------
This command gets entries from the command history that include the word, "
service". The first command gets the 32 most recent entries in the session
history. The pipeline operator (|) passes the results to the Where-Object c
mdlet, which selects only the commands that include "service".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-history -id 7 -count 5 | export-csv history.csv

Description
-----------
This command gets the five most recent history entries ending with entry 7.
The pipeline operator (|) passes the result to the Export-Csv cmdlet, whic
h formats the history as comma-separated text and saves it in the History.c
sv file. The file includes the data that is displayed when you format the h
istory as a list, including the status and start and end times of the comma
nd.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-history -count 1

Description
-----------
This command gets the last (most recently entered) command in the command h
istory. It uses the Count parameter to display just one command. By default
, Get-History displays the most recent commands. This command can be abbrev
iated to "h -c 1" and is equivalent to pressing the up-arrow key.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-history -count $MaximumHistoryCount

Description
-----------
This command displays all of the commands saved in the session history. By
default, $MaximumHistoryCount is 64, so this command can be abbreviated as
"h -c 64".




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-history | format-list

Description
-----------
This command displays all of the properties of entries in the session histo
ry. The pipeline operator (|) passes the result to the Format-List cmdlet,
which displays all of the properties of each history entry, including the I
D, status, and start and end times of the command.




REMARKS
To see the examples, type: "get-help Get-History -examples".
For more information, type: "get-help Get-History -detailed".
For technical information, type: "get-help Get-History -full".

NAME
Get-Item

SYNOPSIS
Gets the item at the specified location.


SYNTAX
Get-Item [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Exclude <
string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-UseTransacti
on] [<CommonParameters>]

Get-Item [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <string[
]>] [-Filter <string>] [-Force] [-Include <string[]>] [-UseTransaction] [<C
ommonParameters>]


DESCRIPTION
The Get-Item cmdlet gets the item at the specified location. It does not ge
t the contents of the item at the location unless you use a wildcard charac
ter (*) to request all the contents of the item.

The Get-Item cmdlet is used by Windows PowerShell providers to enable you t
o navigate through different types of data stores.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user-name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

The Exclude parameter is effective only when the command includes the c
ontents of an item, such as C:\Windows\*, where the wildcard character
specifies the contents of the C:\Windows directory.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to get items that cannot otherwise be accessed, such
as hidden items. Implementation varies from provider to provider. For m
ore information, see about_Providers. Even using the Force parameter, t
he cmdlet cannot override security restrictions.

-Include <string[]>
Retrieves only the specified items. The value of this parameter qualifi
es the Path parameter. Enter a path element or pattern, such as "*.txt"
. Wildcards are permitted.

The Include parameter is effective only when the command includes the c
ontents of an item, such as C:\Windows\*, where the wildcard character
specifies the contents of the C:\Windows directory.

-LiteralPath <string[]>
Specifies a path to the item. Unlike Path, the value of LiteralPath is
used exactly as it is typed. No characters are interpreted as wildcards
. If the path includes escape characters, enclose it in single quotatio
n marks. Single quotation marks tell Windows PowerShell not to interpre
t any characters as escape sequences.

-Path <string[]>
Specifies the path to an item. Get-Item gets the item at the specified
location. Wildcards are permitted. This parameter is required, but the
parameter name ("Path") is optional.

Use a dot (.) to specify the current location. Use the wildcard charact
er (*) to specify all the items in the current location.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-item .

Directory: C:\

Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 7/26/2006 10:01 AM ps-test

Description
-----------
This command gets the current directory. The dot (.) represents the item at
the current location (not its contents).




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-item *

Directory: C:\ps-test

Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 7/26/2006 9:29 AM Logs
d---- 7/26/2006 9:26 AM Recs
-a--- 7/26/2006 9:28 AM 80 date.csv
-a--- 7/26/2006 10:01 AM 30 filenoext
-a--- 7/26/2006 9:30 AM 11472 process.doc
-a--- 7/14/2006 10:47 AM 30 test.txt

Description
-----------
This command gets all the items in the current directory. The wildcard char
acter (*) represents all the contents of the current item.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-item C:\

Description
-----------
This command gets the current directory of the C: drive. The object that is
retrieved represents only the directory, not its contents.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-item C:\*

Description
-----------
This command gets the items in the C: drive. The wildcard character (*) rep
resents all the items in the container, not just the container.

In Windows PowerShell, use a single asterisk (*) to get contents, instead o
f the traditional "*.*". The format is interpreted literally, so "*.*" woul
d not retrieve directories or file names without a dot.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>(get-item C:\Windows).LastAccessTime

Description
-----------
This command gets the LastAccessTime property of the C:\Windows directory.
LastAccessTime is just one property of file system directories. To see all
of the properties of a directory, type "(Get-Item <directory-name>) | Get-M
ember".




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-item hklm:\software\microsoft\powershell\1\shellids\microsoft.pow
ershell\*

Description
-----------
This command shows the contents of the Microsoft.PowerShell registry key. Y
ou can use Get-Item with the Windows PowerShell Registry provider to get re
gistry keys and subkeys, but you must use Get-ItemProperty to get the regis
try values and data.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-item c:\Windows\* -include *.* -exclude w*

Description
-----------
This command gets items in the Windows directory with names that include a
dot (.), but do not begin with w*. This command works only when the path in
cludes a wildcard character (*) to specify the contents of the item.




REMARKS
To see the examples, type: "get-help Get-Item -examples".
For more information, type: "get-help Get-Item -detailed".
For technical information, type: "get-help Get-Item -full".

NAME
Get-Job

SYNOPSIS
Gets Windows PowerShell background jobs that are running in the current ses
sion.


SYNTAX
Get-Job [-Command <string[]>] [<CommonParameters>]

Get-Job [[-InstanceId] <Guid[]>] [<CommonParameters>]

Get-Job [[-Name] <string[]>] [<CommonParameters>]

Get-Job [[-Id] <Int32[]>] [<CommonParameters>]

Get-Job [-State {NotStarted | Running | Completed | Failed | Stopped | Bloc
ked}] [<CommonParameters>]


DESCRIPTION
The Get-Job cmdlet gets objects that represent the background jobs that wer
e started in the current session. You can use Get-Job to get jobs that were
started by using Start-Job, or by using the AsJob parameter of any cmdlet.


Without parameters, a "Get-Job" command gets all jobs in the current sessio
n. You can use the parameters of Get-Job to get particular jobs.

The job object that Get-Job returns contains useful information about the j
ob, but it does not contain the job results. To get the results, use the Re
ceive-Job cmdlet.

A Windows PowerShell background job is a command that runs "in the backgrou
nd" without interacting with the current session. Typically, you use a back
ground job to run a complex command that takes a long time to complete. For
more information about background jobs in Windows PowerShell, see about_Jo
bs.

PARAMETERS
-Command <string[]>
Gets the jobs that include the specified command. The default is all jo
bs. Enter a command (as a string). You can use wildcards to specify a c
ommand pattern.

-Id <Int32[]>
Gets only jobs with the specified IDs.

The ID is an integer that uniquely identifies the job within the curren
t session. It is easier to remember and to type than the instance ID, b
ut it is unique only within the current session. You can type one or mo
re IDs (separated by commas). To find the ID of a job, type "Get-Job" w
ithout parameters.

-InstanceId <Guid[]>
Gets jobs with the specified instance IDs. The default is all jobs.

An instance ID is a GUID that uniquely identifies the job on the comput
er. To find the instance ID of a job, use Get-Job.

-Name <string[]>
Gets the job with the specified friendly names. Enter a job name, or us
e wildcard characters to enter a job name pattern. By default, Get-Job
gets all jobs in the current session.

-State <JobState>
Gets only jobs in the specified state. Valid values are NotStarted, Run
ning, Completed, Stopped, Failed, and Blocked. By default, Get-Job gets
all the jobs in the current session.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-job

Description
-----------
This command gets all background jobs started in the current session. It do
es not include jobs created in other sessions, even if the jobs run on the
local computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$j = get-job -name Job1

C:\PS> $ID = $j.InstanceID

C:\PS> $ID

Guid
----
03c3232e-1d23-453b-a6f4-ed73c9e29d55

C:\PS> stop-job -instanceid $ID

Description
-----------
These commands show how to get the instance ID of a job and then use it to
stop a job. Unlike the name of a job, which is not unique, the instance ID
is unique.

The first command uses the Get-Job cmdlet to get a job. It uses the Name pa
rameter to identify the job. The command stores the job object that Get-Job
returns in the $j variable. In this example, there is only one job with th
e specified name.

The second command gets the InstanceId property of the object in the $j var
iable and stores it in the $ID variable.

The third command displays the value of the $ID variable.

The fourth command uses Stop-Job cmdlet to stop the job. It uses the Instan
ceId parameter to identify the job and $ID variable to represent the instan
ce ID of the job.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-job -command "*get-process*"

Description
-----------
This command gets the jobs on the system that include a Get-Process command
. The command uses the Command parameter of Get-Job to limit the jobs retri
eved. The command uses wildcard characters (*) to get jobs that include a G
et-Process command anywhere within the command string.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>"*get-process*" | get-job

Description
-----------
Like the command in the previous example, this command gets the jobs on th
e system that include a Get-Process command. The command uses a pipeline op
erator (|) to send a string (in double quotation marks) to the Get-Job cmdl
et. It is the equivalent of the previous command.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-job -state NotStarted

Description
-----------
This command gets only those jobs that have been created but have not yet b
een started. This includes jobs that are scheduled to run in the future and
those not yet scheduled.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-job -name job*

Description
-----------
This command gets all jobs that have job names beginning with "job". Becaus
e "job<number>" is the default name for a job, this command gets all jobs t
hat do not have an explicitly assigned name.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>start-job -scriptblock {get-process} -name MyJob

C:\PS> $j = get-job -name MyJob

C:\PS> $j

Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
1 myjob Completed True localhost get-process

C:\PS> receive-job -job $j

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
124 4 13572 12080 59 1140 audiodg
783 16 11428 13636 100 548 CcmExec
96 4 4252 3764 59 3856 ccmsetup
...

Description
-----------
This example shows how to use Get-Job to get a job object, and then it show
s how to use the job object to represent the job in a command.

The first command uses the Start-Job cmdlet to start a background job that
runs a Get-Process command on the local computer. The command uses the Name
parameter of Start-Job to assign a friendly name to the job.

The second command uses Get-Job to get the job. It uses the Name parameter
of Get-Job to identify the job. The command saves the resulting job object
in the $j variable.

The third command displays the value of the job object in the $j variable.
The value of the State property shows that the job is complete. The value o
f the HasMoreData property shows that there are results available from the
job that have not yet been retrieved.

The fourth command uses the Receive-Job cmdlet to get the results of the jo
b. It uses the job object in the $j variable to represent the job. You can
also use a pipeline operator to send a job object to Receive-Job.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>start-job -scriptblock {get-eventlog system}

C:\PS> invoke-command -computername S1 -scriptblock {get-eventlog system} -
AsJob

C:\PS> invoke-command -computername S2 -scriptblock {start-job -scriptblock
{get-eventlog system}}

C:\PS> get-job

Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
1 Job1 Running True localhost get-eventlog system
2 Job2 Running True S1 get-eventlog system

C:\PS> invoke-command -computername S2 -scriptblock {get-job}

Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
4 Job4 Running True localhost get-eventlog system

Description
-----------
This example demonstrates that the Get-Job cmdlet can get all of the jobs t
hat were started in the current session, even if they were started by using
different methods.

The first command uses the Start-Job cmdlet to start a job on the local com
puter.

The second command uses the AsJob parameter of Invoke-Command to start a jo
b on the S1 computer. Even though the commands in the job run on the remote
computer, the job object is created on the local computer, so you use loca
l commands to manage the job.

The third command uses the Invoke-Command cmdlet to run a Start-Job command
on the S2 computer. With this method, the job object is created on the rem
ote computer, so you use remote commands to manage the job.

The fourth command uses Get-Job to get the jobs stored on the local compute
r.

The fifth command uses Invoke-Command to run a Get-Job command on the S2 co
mputer.

The sample output shows the results of the Get-Job commands.

For more information about running background jobs on remote computers, see
about_Remote_Jobs.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>start-job -scriptblock {get-process}

Id Name State HasMoreData Location Co
mmand
-- ---- ----- ----------- -------- --
-----
1 Job1 Failed False localhost ge
t-process

C:\PS> (get-job).jobstateinfo | format-list -property *

State : Failed
Reason :


C:\PS> get-job | format-list *

HasMoreData : False
StatusMessage :
Location : localhost
Command : get-process
JobStateInfo : Failed
Finished : System.Threading.ManualResetEvent
InstanceId : fb792295-1318-4f5d-8ac8-8a89c5261507
Id : 1
Name : Job1
ChildJobs : {Job2}
Output : {}
Error : {}
Progress : {}
Verbose : {}
Debug : {}
Warning : {}
StateChanged :


C:\PS> (get-job -name job2).jobstateinfo.reason
Connecting to remote server using WSManCreateShellEx api failed. The async
callback gave the following error message :
Access is denied.

Description
-----------
This command shows how to use the job object that Get-Job returns to invest
igate why a job failed. It also shows how to get the child jobs of each job
.

The first command uses the Start-Job cmdlet to start a job on the local com
puter. The job object that Start-Job returns shows that the job failed. The
value of the State property is "Failed".

The second command uses Get-Job to get the job object. The command uses the
dot method to get the value of the JobStateInfo property of the object. It
uses a pipeline operator to send the object in the JobStateInfo property t
o the Format-List cmdlet, which formats all of the properties of the object
(*) in a list.

The result of the Format-List command shows that the value of the Reason pr
operty of the job is blank.

The third command investigates further. It uses a Get-Job command to get th
e job and then uses a pipeline operator to send the entire job object to th
e Format-List cmdlet, which displays all of the properties of the job in a
list.

The display of all properties in the job object shows that the job contains
a child job named "Job2".

The fourth command uses Get-Job to get the job object that represents the J
ob2 child job. This is the job in which the command actually ran. It uses t
he dot method to get the Reason property of the JobStateInfo property.

The result shows that the job failed because of an "access denied" error. I
n this case, the user forgot to use the "Run as administrator" option when
opening Windows PowerShell.

Because background jobs use the remoting features of Windows PowerShell, th
e computer must be configured for remoting to run a job, even when the job
runs on the local computer.

For information about requirements for remoting in Windows PowerShell, see
about_Remote_Requirements. For troubleshooting tips, see about_Remote_Troub
leshooting.




REMARKS
To see the examples, type: "get-help Get-Job -examples".
For more information, type: "get-help Get-Job -detailed".
For technical information, type: "get-help Get-Job -full".

NAME
Get-Location

SYNOPSIS
Gets information about the current working location.


SYNTAX
Get-Location [-PSDrive <string[]>] [-PSProvider <string[]>] [-UseTransactio
n] [<CommonParameters>]

Get-Location [-Stack] [-StackName <string[]>] [-UseTransaction] [<CommonPar
ameters>]


DESCRIPTION
The Get-Location cmdlet gets an object that represents the current director
y, much like the pwd (print working directory) command.

When you move between Windows PowerShell drives, Windows PowerShell retains
your location in each drive. You can use Get-Location to find your locatio
n in each drive.

You can also use Get-Location to get the current directory at run time and
use it in functions and scripts, such as in a function that displays the cu
rrent directory in the Windows PowerShell prompt.

If you use the Push-Location cmdlet to add locations to a path stack, you c
an use the Stack parameter of Get-Location to display the current stack.

PARAMETERS
-PSDrive <string[]>
Gets the current location in the specified Windows PowerShell drive.

For example, if you are in the Certificate: drive, you can use this par
ameter to find your current location in the C: drive.

-PSProvider <string[]>
Gets the current location in the drive supported by the specified Windo
ws PowerShell provider.

If the specified provider supports more than one drive, Get-Location re
turns the location on the most recently accessed drive.

For example, if you are in the C: drive, you can use this parameter to
find your current location in the drives of the Windows PowerShell Regi
stry provider.

-Stack [<SwitchParameter>]
Displays the locations in the default path stack.

To add paths to the default stack, use the Push-Location cmdlet.

-StackName <string[]>
Displays the locations in the specified path stacks.

To create path stacks, use the Push-Location cmdlet.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-location

Path
----
C:\WINDOWS

Description
-----------
This command displays your location in the current Windows PowerShell drive
.

For example, if you are in the Windows directory of the C: drive, it displa
ys the path to that directory.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>set-location

Description
-----------
These commands demonstrate the use of Get-Location to display your current
location in different Windows PowerShell drives.

The first command uses the Set-Location cmdlet to set the current location
to the Windows subdirectory of the C: drive.

C:\PS> set-location C:\Windows

The second command uses the Set-Location cmdlet to change the location to t
he HKLM:\Software\Microsoft registry key. When you change to a location in
the HKLM: drive, Windows PowerShell retains your location in the C: drive.

PS C:\WINDOWS> set-location HKLM:\Software\Microsoft
PS HKLM:\Software\Microsoft>

The third command uses the Set-Location cmdlet to change the location to th
e "HKCU:\Control Panel\Input Method" registry key.

PS HKLM:\Software\Microsoft> set-location 'HKCU:\Control Panel\Input Me
thod'
PS HKCU:\Control Panel\Input Method>

The fourth command uses the Get-Location cmdlet to find the current locatio
n on the C: drive. It uses the PSDrive parameter to specify the drive.

PS HKCU:\Control Panel\Input Method> get-location -psdrive c
Path
----
C:\WINDOWS

The fifth command uses the Set-Location cmdlet to return to the C: drive. E
ven though the command does not specify a subdirectory, Windows PowerShell
returns you to the saved location.

PS HKCU:\Control Panel\Input Method> set-location C:
PS C:\WINDOWS>

The sixth command uses the Get-Location cmdlet to find the current location
in the drives supported by the Windows PowerShell registry provider. Get-L
ocation returns the location of the most recently accessed registry drive,
HKCU:.

PS C:\WINDOWS> get-location -psprovider registry
Path
----
HKCU:\Control Panel\Input Method

To see the current location in the HKLM: drive, you need to use the PSDrive
parameter to specify the drive. The seventh command does just this:

PS C:\WINDOWS> get-location -psdrive HKLM
Path
----
HKLM:\Software\Microsoft




-------------------------- EXAMPLE 3 --------------------------

C:\PS>set-location

Description
-----------
These commands show how to use the Stack and StackName parameters of Get-Lo
cation to list the paths in the default and alternate path stacks.

The first command sets the current location to the Windows directory on the
C: drive.

C:\PS> set-location C:\Windows

The second command uses the Push-Location cmdlet to push the current locati
on (C:\Windows) onto the path stack and change to the System32 subdirectory
. Because no stack is specified, the current location is pushed onto the de
fault stack.
C:\WINDOWS>push-location System32

The third command pushes the current location (C:\Windows\System32) onto th
e Stack2 stack and changes the location to the WindowsPowerShell subirector
y.

C:\Windows\System32>push-location WindowsPowerShell -stack Stack2

The fourth command uses the Get-Location cmdlet to get the paths on the def
ault path stack.

C:\WINDOWS\system32\WindowsPowerShell>get-location -stack

Path
----
C:\WINDOWS

The last command uses the StackName parameter of Get-Location to get the pa
ths on the Stack2 stack.

C:\WINDOWS\system32\WindowsPowerShell>get-location -stackname Stack2

Path
----
C:\WINDOWS\system32




-------------------------- EXAMPLE 4 --------------------------

C:\PS>function prompt { 'PowerShell: ' + (get-location) + '> '}

PowerShell: C:\WINDOWS>

Description
-----------
This example shows how to customize the Windows PowerShell prompt. The func
tion that defines the prompt includes a Get-Location command, which is run
whenever the prompt appears in the console.

The format of the default Windows PowerShell prompt is defined by a special
function called "prompt". You can change the prompt in your console by cre
ating a new function called "prompt".

To see the current prompt function, type the following command:

get-content function:prompt

The command begins with the "function" keyword followed by the function nam
e, "prompt". The function body appears within braces ( {} ).

This command defines a new prompt that begins with the string "PowerShell:
". To append the current location, it uses a Get-Location command, which ru
ns when the prompt function is called. The prompt ends with the string "> "
.




REMARKS
To see the examples, type: "get-help Get-Location -examples".
For more information, type: "get-help Get-Location -detailed".
For technical information, type: "get-help Get-Location -full".

NAME
Get-Member

SYNOPSIS
Gets the properties and methods of objects.


SYNTAX
Get-Member [[-Name] <string[]>] [-Force] [-InputObject <psobject>] [-Member
Type {AliasProperty | CodeProperty | Property | NoteProperty | ScriptProper
ty | Properties | PropertySet | Method | CodeMethod | ScriptMethod | Method
s | ParameterizedProperty | MemberSet | Event | All}] [-Static] [-View {Ext
ended | Adapted | Base | All}] [<CommonParameters>]


DESCRIPTION
The Get-Member cmdlet gets the "members" (properties and methods) of object
s.

To specify the object, use the InputObject parameter or pipe an object to G
et-Member. To retrieve information about static members (members of the cla
ss, not of the instance), use the Static parameter. To get only certain typ
es of members, such as NoteProperties, use the MemberType parameter.

PARAMETERS
-Force [<SwitchParameter>]
Adds the intrinsic members (PSBase, PSAdapted, PSObject, PSTypeNames) a
nd the compiler-generated get_ and set_ methods to the display. By defa
ult, Get-Member gets these properties in all views other than "Base" an
d "Adapted," but it does not display them.

The following list describes the properties that are added when you use
the Force parameter:

-- PSBase: The original properties of the .NET Framework object withou
t extension or adaptation. These are the properties defined for the obj
ect class and listed in MSDN.
-- PSAdapted: The properties and methods defined in the Windows PowerSh
ell extended type system.
-- PSExtended: The properties and methods that were added in the Types.
ps1xml files or by using the Add-Member cmdlet.
-- PSObject: The adapter that converts the base object to a Windows Pow
erShell PSObject object.
-- PSTypeNames: A list of object types that describe the object, in ord
er of specificity. When formatting the object, Windows PowerShell searc
hes for the types in the Format.ps1xml files in the Windows PowerShell
installation directory ($pshome). It uses the formatting definition for
the first type that it finds.

-InputObject <psobject>
Specifies the object whose members are retrieved.

Using the InputObject parameter is not the same as piping an object to
Get-Member. The differences are as follows:

-- When you pipe a collection of objects to Get-Member, Get-Member gets
the members of the individual objects in the collection, such as the p
roperties of the integers in an array of integers.

-- When you use InputObject to submit a collection of objects, Get-Memb
er gets the members of the collection, such as the properties of the ar
ray in an array of integers.

-MemberType <PSMemberTypes>
Gets only members with the specified member type. The default is All.

The valid values for this parameter are:

-- AliasProperty: A property that defines a new name for an existing pr
operty.
-- CodeMethod: A method that references a static method of a .NET Frame
work class.
-- CodeProperty: A property that references a static property of a .NET
Framework class.
-- Event: Indicates that the object sends a message to indicate an act
ion or a change in state.
-- MemberSet: A predefined collection of properties and methods, such a
s PSBase, PSObject, and PSTypeNames.
-- Method: A method of the underlying .NET Framework object.
-- NoteProperty: A property with a static value.
-- ParameterizedProperty: A property that takes parameters and paramete
r values.
-- Property: A property of the underlying .NET Framework object.
-- PropertySet: A predefined collection of object properties.
-- ScriptMethod: A method whose value is the output of a script.
-- ScriptProperty: A property whose value is the output of a script.

-- All: Gets all member types.
-- Methods: Gets all types of methods of the object (for example, Metho
d, CodeMethod, ScriptMethod).
-- Properties: Gets all types of properties of the object (for example,
Property, CodeProperty, AliasProperty, ScriptProperty).

Not all objects have every type of member. If you specify a member type
that the object does not have, Windows PowerShell returns a null value
.

To get related types of members, such as all extended members, use the
View parameter. If you use the MemberType parameter with the Static or
View parameters, Get-Member gets the members that belong to both sets.

-Name <string[]>
Specifies the names of one or more properties or methods of the object.
Get-Member gets only the specified properties and methods.

If you use the Name parameter with the MemberType, View, or Static para
meters, Get-Member gets only the members that satisfy the criteria of a
ll parameters.

To get a static member by name, use the Static parameter with the Name
parameter.

-Static [<SwitchParameter>]
Gets only the static properties and methods of the object.

Static properties and methods are defined on the class of objects, not
on any particular instance of the class.

If you use the Static parameter with the View parameter, the View param
eter is ignored. If you use the Static parameter with the MemberType pa
rameter, Get-Member gets only the members that belong to both sets.

-View <PSMemberViewTypes>
Gets only particular types of members (properties and methods). Specify
one or more of the values. The default is "Adapted, Extended".

Valid values are:
-- Base: Gets only the original properties and methods of the .NET Fra
mework object (without extension or adaptation).
-- Adapted: Gets only the properties and methods defined in the Window
s PowerShell extended type system.
-- Extended: Gets only the properties and methods that were added in th
e Types.ps1xml files or by using the Add-Member cmdlet.
-- All: Gets the members in the Base, Adapted, and Extended views.

The View parameter determines the members retrieved, not just the displ
ay of those members.

To get particular member types, such as script properties, use the Memb
erType parameter. If you use the MemberType and View parameters in the
same command, Get-Member gets the members that belong to both sets. If
you use the Static and View parameters in the same command, the View pa
rameter is ignored.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-service | get-member


TypeName: System.ServiceProcess.ServiceController

Name MemberType Definition
---- ---------- ----------
Name AliasProperty Name = ServiceName
Close Method System.Void Close()
Continue Method System.Void Continue()
CreateObjRef Method System.Runtime.Remoting.ObjRef Crea
teObjRef(Type requestedType)
Dispose Method System.Void Dispose()
Equals Method System.Boolean Equals(Object obj)
ExecuteCommand Method System.Void ExecuteCommand(Int32 co
mmand)
GetHashCode Method System.Int32 GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetType Method System.Type GetType()
InitializeLifetimeService Method System.Object InitializeLifetimeSer
vice()
Pause Method System.Void Pause()
Refresh Method System.Void Refresh()
Start Method System.Void Start(), System.Void St
art(String[] args)
Stop Method System.Void Stop()
ToString Method System.String ToString()
WaitForStatus Method System.Void WaitForStatus(ServiceCo
ntrollerStatus desiredStatus), System.Voi...
CanPauseAndContinue Property System.Boolean CanPauseAndContinue
{get;}
CanShutdown Property System.Boolean CanShutdown {get;}
CanStop Property System.Boolean CanStop {get;}
Container Property System.ComponentModel.IContainer Co
ntainer {get;}
DependentServices Property System.ServiceProcess.ServiceContro
ller[] DependentServices {get;}
DisplayName Property System.String DisplayName {get;set;
}
MachineName Property System.String MachineName {get;set;
}
ServiceHandle Property System.Runtime.InteropServices.Safe
Handle ServiceHandle {get;}
ServiceName Property System.String ServiceName {get;set;
}
ServicesDependedOn Property System.ServiceProcess.ServiceContro
ller[] ServicesDependedOn {get;}
ServiceType Property System.ServiceProcess.ServiceType S
erviceType {get;}
Site Property System.ComponentModel.ISite Site {g
et;set;}
Status Property System.ServiceProcess.ServiceContro
llerStatus Status {get;}

Description
-----------
This command displays the properties and methods of the process objects (Sy
stem.ServiceProcess.ServiceController) that are generated by the Get-Servic
e cmdlet.

The command uses the pipeline operator (|) to send the output of a Get-Serv
ice command to Get-Member.

Because the Get-Member part of the command does not have any parameters, it
uses all of the default values. As such, it gets all member types, but it
does not get static members and does not display intrinsic members.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-service | get-member -force

C:\PS> (get-service -schedule).psbase

Description
-----------
This example gets all of the members (properties and methods) of the servic
e objects (System.ServiceProcess.ServiceController) retrieved by the Get-Se
rvice cmdlet, including the intrinsic members, such as PSBase and PSObject,
and the get_ and set_ methods.

The first command uses the Get-Service cmdlet to get objects that represent
the services on the system. It uses a pipeline operator (|) to pass the se
rvice objects to the Get-Member cmdlet.

The Get-Member command uses the Force parameter to add the intrinsic member
s and compiler-generated members of the objects to the display. Get-Member
gets these members, but it hides them by default.

You can use these properties and methods in the same way that you would use
an adapted method of the object. The second command shows how to display t
he value of the PSBase property of the Schedule service.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-service | get-member -view extended

TypeName: System.ServiceProcess.ServiceController

Name MemberType Definition
---- ---------- ----------
Name AliasProperty Name = ServiceName

Description
-----------
This command gets the methods and properties of service objects that were e
xtended by using the Types.ps1xml file or the Add-Member cmdlet.


The Get-Member command uses the View parameter to get only the extended mem
bers of the service objects. In this case, the extended member is the Name
property, which is an alias property of the ServiceName property.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-eventlog -log system | gm -membertype scriptproperty

TypeName: System.Diagnostics.EventLogEntry

Name MemberType Definition
---- ---------- ----------
EventID ScriptProperty System.Object EventID {get=$this.get_EventID() -band
0xFFFF;}

Description
-----------
This command gets the script properties of event log objects in the System
log in Event Viewer. In this case, the only script property is the EventID.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-eventlog -log system | get-member -membertype scriptproperty


TypeName: System.Diagnostics.EventLogEntry

Name MemberType Definition
---- ---------- ----------
EventID ScriptProperty System.Object EventID {get=$this.get_EventID() -band
0xFFFF;}

Description
-----------
This command gets the script properties of event log objects in the System
log in Event Viewer.

The command uses the MemberType parameter to get only objects with a value
of AliasProperty for their MemberType property.

The command returns the EventID property of the EventLog object.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>$a = "get-process", "get-service", "get-culture", "get-psdrive", "get
-executionpolicy"

C:\PS> foreach ($cmdlet in $a) {invoke-expression $cmdlet | get-member -nam
e machinename}

TypeName: System.Diagnostics.Process

Name MemberType Definition
---- ---------- ----------
MachineName Property System.String MachineName {get;}


TypeName: System.ServiceProcess.ServiceController

Name MemberType Definition
---- ---------- ----------
MachineName Property System.String MachineName {get;set;}

Description
-----------
This command gets objects that have a MachineName property from a list of c
mdlets.

The first command stores the names of several cmdlets in the $a variable.

The second command uses a ForEach statement to invoke each command, send th
e results to Get-Member, and limit the results from Get-Member to members t
hat have the name "MachineName."

The results show that only process objects (System.Diagnostics.Process) and
service objects (System.ServiceProcess.ServiceController) have a MachineNa
me property.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>$a = get-member -inputobject @(1)

C:\PS>$a.count

1

C:\PS> $a = get-member -inputobject 1,2,3

TypeName: System.Object[]
Name MemberType Definition
---- ---------- ----------
Count AliasProperty Count = Length
Address Method System.Object& Address(Int32 )
Clone Method System.Object Clone()
...

C:\PS>$a.count
1

Description
-----------
This example demonstrates how to find the properties and methods of an arra
y of objects when you have only one object of the given type.

Because the goal of the command is to find the properties of an array, the
first command uses the InputObject parameter. It uses the "at" symbol (@) t
o indicate an array. In this case, the array contains only one object, the
integer 1.

The third command uses the Get-Member cmdlet to get the properties and meth
ods of an array of integers, and the command saves them in the $a variable.

The fourth command uses the Count property of the array to find the number
of objects in the $a variable.




REMARKS
To see the examples, type: "get-help Get-Member -examples".
For more information, type: "get-help Get-Member -detailed".
For technical information, type: "get-help Get-Member -full".

NAME
Get-Module

SYNOPSIS
Gets the modules that have been imported or that can be imported into the c
urrent session.


SYNTAX
Get-Module [-All] [-ListAvailable] [-Name <string[]>] [<CommonParameters>]

Get-Module [[-Name] <string[]>] [<CommonParameters>]


DESCRIPTION
The Get-Module cmdlet gets the modules that have been imported, or that can
be imported, into the session.

Get-Module only gets modules; it does not import them. To import the module
s into your session, use Import-Module.

PARAMETERS
-All [<SwitchParameter>]
Gets module objects for all module files.

Without the All parameter, Get-Module gets only the module object for t
he default module file. The cmdlet selects file types in the following
order: manifest (.psd1) files, script module (.psm1) files, and binary
module (.dll) files.

-ListAvailable [<SwitchParameter>]
Gets all of the modules that can be imported into the session. Get-Modu
le gets the modules in the paths specified by the $env:PSModulePath env
ironment variable.

Without this parameter, Get-Module gets only the modules that have been
imported into the session.

-Name <string[]>
Gets only modules with the specified names or name patterns. Wildcards
are permitted. You can also pipe the names to Get-Module.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-module

Description
-----------
This command gets the modules that have been imported into the current sess
ion.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-module -listAvailable

Description
-----------
This command gets the modules that can be imported into the current session
.

Get-Module looks for available modules in the path specified by the $env:PS
ModulePath environment variable. For more information about PSModulePath, s
ee about_Modules and about_Environment_Variables.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-module -listAvailable -all

Description
-----------
This command gets all of the exported files for all available modules.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-module | get-member -type property

TypeName: System.Management.Automation.PSModuleInfo

Name MemberType Definition
---- ---------- ----------
AccessMode Property System.Management.Automation.ModuleAcc
Description Property System.String Description {get;set;}
ExportedAliases Property System.Collections.Generic.Dictionary`
ExportedCmdlets Property System.Collections.Generic.Dictionary`
ExportedFunctions Property System.Collections.Generic.Dictionary`
ExportedVariables Property System.Collections.Generic.Dictionary`
Guid Property System.Guid Guid {get;}
ModuleBase Property System.String ModuleBase {get;}
ModuleType Property System.Management.Automation.ModuleTyp
Name Property System.String Name {get;}
NestedModules Property System.Collections.ObjectModel.ReadOnl
OnRemove Property System.Management.Automation.ScriptBlo
Path Property System.String Path {get;}
PrivateData Property System.Object PrivateData {get;set;}
SessionState Property System.Management.Automation.SessionSt
Version Property System.Version Version {get;}

Description
-----------
This command get the properties of the PSModuleInfo object that Get-Module
returns. There is one object for each module file.

You can use the properties to format and filter the module objects. For mor
e information about the properties, see "PSModule Properties" in the MSDN (
Microsoft Developer Network) library at http://go.microsoft.com/fwlink/?Lin
kId=143624.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-module -listAvailable -all | format-table -property name, modulet
ype, path -groupby name -auto

Name: MyTestCmdlets

Name ModuleType Path
---- ---------- ----
MyTestCmdlets Script C:\Windows\system32\WindowsPowerShell\v1.0\Modules
\TestCmdlets\TestCmdlets.dll


Name: PSDiagnostics

Name ModuleType Path
---- ---------- ----
PSDiagnostics Manifest C:\Windows\system32\WindowsPowerShell\v1.0\Modules
\PSDiagnostics\PSDiagnostics.psd1
PSDiagnostics Script C:\Windows\system32\WindowsPowerShell\v1.0\Modules
\PSDiagnostics\PSDiagnostics.psm1


Name: FileTransfer

Name ModuleType Path
---- ---------- ----
FileTransfer Manifest C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
FileTransfer\FileTransfer.psd1

Description
-----------
This command gets all module files (imported and available) and groups them
by module name. This lets you see the module files that each script is exp
orting.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>$m = get-module -list -name FileTransfer | where {$_.moduletype -eq "
Manifest"}

C:\PS> get-content $m.path

@{
GUID="{8FA5064B-8479-4c5c-86EA-0D311FE48875}"
Author="Microsoft Corporation"
CompanyName="Microsoft Corporation"
Copyright="© Microsoft Corporation. All rights reserved."
ModuleVersion="1.0.0.0"
Description="Windows Powershell File Transfer Module"
PowerShellVersion="2.0"
CLRVersion="2.0"
NestedModules="Microsoft.BackgroundIntelligentTransfer.Management"
FormatsToProcess="FileTransfer.Format.ps1xml"
RequiredAssemblies=Join-Path $psScriptRoot "Microsoft.BackgroundIntelligent
Transfer.Management.Interop.dll"
}

Description
-----------
These commands display the contents of the module manifest for the Windows
PowerShell File Transfer module.

The first command gets the PSModuleInfo object that represent the module ma
nifest for the File Transfer module. It saves the object in the $m variable
.

The second command uses dot notation to get the path to the manifest file,
which is stored in the Path property of the object. Then, it uses the Get-C
ontent cmdlet to get the content of the manifest file in the specified path
.

Modules are not required to have manifest files. When they do have a manife
st file, a manifest is required only to include a version number. However,
manifest files often provide useful information about a module, its require
ments, and its contents.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-module -listAvailable -name FileTransfer | format-list -property
*

Name : FileTransfer
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\File
Transfer\FileTransfer.psd1
Description : Powershell File Transfer Module
Guid : 8fa5064b-8479-4c5c-86ea-0d311fe48875
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\File
Transfer
PrivateData :
Version : 1.0.0.0
ModuleType : Manifest
AccessMode : ReadWrite
ExportedFunctions : {}
ExportedCmdlets : {}
NestedModules : {}
ExportedVariables : {}
ExportedAliases : {}
SessionState : System.Management.Automation.SessionState
OnRemove :

Description
-----------
This command displays all of the properties of the FileTransfer module in a
list.

Because the module has not yet been imported into the session, the Exported
* properties and the NestedModules property are not yet populated. These pr
operties are populated only after the elements have been exported and the n
ested modules have been instantiated.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>dir (get-module -listavailable FileTransfer).modulebase

Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FileTrans
fer


Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/16/2008 12:36 PM en-US
-a--- 11/19/2008 11:30 PM 16184 FileTransfer.Format.ps1xml
-a--- 11/20/2008 11:30 PM 1044 FileTransfer.psd1
-a--- 12/16/2008 12:20 AM 108544 Microsoft.BackgroundIntelligen
tTransfer.Management.Interop.dll

Description
-----------
This command lists the files in the module's directory. This is another way
to determine what is in a module before you import it. Some modules might
have help files or ReadMe files that describe the module.




REMARKS
To see the examples, type: "get-help Get-Module -examples".
For more information, type: "get-help Get-Module -detailed".
For technical information, type: "get-help Get-Module -full".

NAME
Get-ItemProperty

SYNOPSIS
Gets the properties of a specified item.


SYNTAX
Get-ItemProperty [-LiteralPath] <string[]> [[-Name] <string[]>] [-Credentia
l <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Include <strin
g[]>] [-UseTransaction] [<CommonParameters>]

Get-ItemProperty [-Path] <string[]> [[-Name] <string[]>] [-Credential <PSCr
edential>] [-Exclude <string[]>] [-Filter <string>] [-Include <string[]>] [
-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Get-ItemProperty cmdlet gets the properties of the specified items. For
example, you can use Get-ItemProperty to get the value of the LastAccessTi
me property of a file object. You can also use Get-ItemProperty to view reg
istry entries and their values.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. Wildcards are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects rather than having Windows PowerShell filter
the objects after they are retrieved.

-Include <string[]>
Includes the specified items.

-LiteralPath <string[]>
Specifies a path to the item property. The value of LiteralPath is used
exactly as it is typed. No characters are interpreted as wildcards. If
the path includes escape characters, enclose it in single quotation ma
rks. Single quotation marks tell Windows PowerShell not to interpret an
y characters as escape sequences.

-Name <string[]>
Specifies the name of the property or properties to retrieve.

-Path <string[]>
Specifies the path to the item or items.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-itemproperty C:\Windows

Description
-----------
This command gets information about the C:\Windows directory.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-itemproperty C:\Test\Weather.xls | format-list

Description
-----------
This command gets the properties of the C:\Test\Weather.xls file. The resul
t is piped to the Format-List cmdlet to display the output as a list.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-itemproperty -path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersio
n

Description
-----------
This command displays the value name and data of each of the registry entri
es contained in the CurrentVersion registry subkey. Note that the command r
equires that there is a Windows PowerShell drive named HKLM: that is mapped
to the HKEY_LOCAL_MACHINE hive of the registry. A drive with that name and
mapping is available in Windows PowerShell by default. Alternatively, the
path to this registry subkey can be specified by using the following altern
ative path that begins with the provider name followed by two colons:
Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-itemproperty -path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersio
n `
-name "ProgramFilesDir"

Description
-----------
This command gets the value name and data of the ProgramFilesDir registry e
ntry in the CurrentVersion registry subkey. The command uses the Path param
eter to specify the subkey and the Name parameter to specify the value name
of the entry.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-itemproperty -path HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShe
llEngine

ApplicationBase : C:\Windows\system32\WindowsPowerShell\v1.0\
ConsoleHostAssemblyName : Microsoft.PowerShell.ConsoleHost, Version=1.0.0.0
, Culture=neutral, PublicKeyToken=31bf3856ad
364e35, ProcessorArchitecture=msil
PowerShellVersion : 2.0
RuntimeVersion : v2.0.50727
CTPVersion : 5
PSCompatibleVersion : 1.0,2.0

Description
-----------
This command gets the value names and data of the registry entries in the
PowerShellEngine registry key. The results are shown in the following sampl
e output.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-itemproperty -path HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds
\Microsoft.PowerShell

Path ExecutionPolicy
---- ---------------
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe RemoteSigned


C:\PS>get-itemproperty -path HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds
\Microsoft.PowerShell | format-list -property *

PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\So
ftware\Microsoft\PowerShell\1\ShellIds\Micro
soft.PowerShell
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\So
ftware\Microsoft\PowerShell\1\ShellIds
PSChildName : Microsoft.PowerShell
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
Path : C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
ExecutionPolicy : RemoteSigned

Description
-----------
This example shows how to format the output of a Get-ItemProperty command i
n a list to make it easy to see the registry values and data and to make it
easy to interpret the results.

The first command uses the Get-ItemProperty cmdlet to get the registry entr
ies in the Microsoft.PowerShell subkey. This subkey stores options for the
default shell for Windows PowerShell. The results are shown in the followin
g sample output.

The output shows that there are two registry entries, Path and ExecutionPol
icy. When a registry key contains fewer than five entries, by default it is
displayed in a table, but it is often easier to view in a list.

The second command uses the same Get-ItemProperty command. However, this ti
me, the command uses a pipeline operator (|) to send the results of the com
mand to the Format-List cmdlet. The Format-List command uses the Property p
arameter with a value of * (all) to display all of the properties of the ob
jects in a list. The results are shown in the following sample output.

The resulting display shows the Path and ExecutionPolicy registry entries,
along with several less familiar properties of the registry key object. The
other properties, prefixed with "PS", are properties of Windows PowerShell
custom objects, such as the objects that represent the registry keys.




REMARKS
To see the examples, type: "get-help Get-ItemProperty -examples".
For more information, type: "get-help Get-ItemProperty -detailed".
For technical information, type: "get-help Get-ItemProperty -full".

NAME
Get-Process

SYNOPSIS
Gets the processes that are running on the local computer or a remote compu
ter.


SYNTAX
Get-Process [[-Name] <string[]>] [-ComputerName <string[]>] [-FileVersionIn
fo] [-Module] [<CommonParameters>]

Get-Process -Id <Int32[]> [-ComputerName <string[]>] [-FileVersionInfo] [-M
odule] [<CommonParameters>]

Get-Process -InputObject <Process[]> [-ComputerName <string[]>] [-FileVersi
onInfo] [-Module] [<CommonParameters>]


DESCRIPTION
The Get-Process cmdlet gets the processes on a local or remote computer.

Without parameters, Get-Process gets all of the processes on the local comp
uter. You can also specify a particular process by process name or process
ID (PID) or pass a process object through the pipeline to Get-Process.

By default, Get-Process returns a process object that has detailed informat
ion about the process and supports methods that let you start and stop the
process. You can also use the parameters of Get-Process to get file version
information for the program that runs in the process and to get the module
s that the process loaded.

PARAMETERS
-ComputerName <string[]>
Gets the processes running on the specified computers. The default is t
he local computer.

Type the NetBIOS name, an IP address, or a fully qualified domain name
of one or more computers. To specify the local computer, type the compu
ter name, a dot (.), or "localhost".

This parameter does not rely on Windows PowerShell remoting. You can us
e the ComputerName parameter of Get-Process even if your computer is no
t configured to run remote commands.

-FileVersionInfo [<SwitchParameter>]
Gets the file version information for the program that runs in the proc
ess.

On Windows Vista and later versions of Windows, you must open Windows P
owerShell with the "Run as administrator" option to use this parameter
on processes that you do not own.

Using this parameter is equivalent to getting the MainModule.FileVersio
nInfo property of each process object. When you use this parameter, Get
-Process returns a FileVersionInfo object (System.Diagnostics.FileVersi
onInfo), not a process object. So, you cannot pipe the output of the co
mmand to a cmdlet that expects a process object, such as Stop-Process.

-Id <Int32[]>
Specifies one or more processes by process ID (PID). To specify multipl
e IDs, use commas to separate the IDs. To find the PID of a process, ty
pe "get-process".

-InputObject <Process[]>
Specifies one or more process objects. Enter a variable that contains t
he objects, or type a command or expression that gets the objects.

-Module [<SwitchParameter>]
Gets the modules that have been loaded by the processes.

On Windows Vista and later versions of Windows, you must open Windows P
owerShell with the "Run as administrator" option to use this parameter
on processes that you do not own.

This parameter is equivalent to getting the Modules property of each pr
ocess object. When you use this parameter, Get-Process returns a Proces
sModule object (System.Diagnostics.ProcessModule), not a process object
. So, you cannot pipe the output of the command to a cmdlet that expect
s a process object, such as Stop-Process.

When you use both the Module and FileVersionInfo parameters in the same
command, Get-Process returns a FileVersionInfo object with information
about the file version of all modules.

-Name <string[]>
Specifies one or more processes by process name. You can type multiple
process names (separated by commas) or use wildcard characters. The par
ameter name ("Name") is optional.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>Get-Process

Description
-----------
This command gets a list of all of the running processes running on the loc
al computer. For a definition of each column, see the "Additional Notes" se
ction of the Help topic for Get-Help.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>Get-Process winword, explorer | format-list *

Description
-----------
This command gets all available data about the Winword and Explorer process
es on the computer. It uses the Name parameter to specify the processes, bu
t it omits the optional parameter name. The pipeline operator (|) passes th
e data to the Format-List cmdlet, which displays all available properties (
*) of the Winword and Explorer process objects.

You can also identify the processes by their process IDs. For example, "get
-process -id 664, 2060".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-process | where-object {$_.WorkingSet -gt 20000000}

Description
-----------
This command gets all processes that have a working set greater than 20 MB.
It uses the Get-Process cmdlet to get all running processes. The pipeline
operator (|) passes the process objects to the Where-Object cmdlet, which s
elects only the object with a value greater than 20,000,000 bytes for the W
orkingSet property.

WorkingSet is one of many properties of process objects. To see all of the
properties, type "Get-Process | Get-Member". By default, the values of all
amount properties are in bytes, even though the default display lists them
in kilobytes and megabytes.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$a = get-process

C:\PS> get-process -inputobject $a | format-table -view priority

Description
-----------
These commands list the processes on the computer in groups based on their
priority class.

The first command gets all the processes on the computer and then stores th
em in the $a variable.

The second command uses the InputObject parameter to pass the process objec
ts that are stored in the $a variable to the Get-Process cmdlet. The pipel
ine operator passes the objects to the Format-Table cmdlet, which formats t
he processes by using the Priority view.

The priority view, and other views, are defined in the PS1XML format files
in the Windows PowerShell home directory ($pshome).




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-process powershell -computername S1, localhost | ft @{Label="NPM(
K)";Expression={[int]($_.NPM/1024)}}, @{Label="PM(K)";Expression={[int]($_.
PM/1024)}},@{Label="WS(K)";Expression={[int]($_.WS/1024)}},@{Label="VM(M)";
Expression={[int]($_.VM/1MB)}}, @{Label="CPU(s)";Expression={if ($_.CPU -ne
$()) { $_.CPU.ToString("N")}}}, Id, MachineName, ProcessName -auto


NPM(K) PM(K) WS(K) VM(M) CPU(s) Id MachineName ProcessName
------ ----- ----- ----- ------ -- ----------- -----------
6 23500 31340 142 1980 S1 powershell
6 23500 31348 142 4016 S1 powershell
27 54572 54520 576 4428 localhost powershell

Description
-----------
This example provides a Format-Table (alias = ft) command that adds the Mac
hineName property to the standard Get-Process output display.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-process powershell -fileversioninfo

ProductVersion FileVersion FileName
-------------- ----------- --------
6.1.6713.1 6.1.6713.1 (f... C:\WINDOWS\system32\WindowsPowerShell\v1.
0\powershell.exe

Description
-----------
This command uses the FileVersionInfo parameter to get the version informat
ion for the PowerShell.exe file that is the main module for the PowerShell
process.

To run this command with processes that you do not own on Windows Vista and
later versions of Windows, you must open Windows PowerShell with the "Run
as administrator" option.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-process sql* -module

Description
-----------
This command uses the Module parameter to get the modules that have been lo
aded by the process. This command gets the modules for the processes that h
ave names that begin with "sql".

To run this command on Windows Vista (and later versions of Windows) with p
rocesses that you do not own, you must start Windows PowerShell with the "R
un as administrator" option.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>$p = get-wmiobject win32_process -filter "name='powershell.exe'"

C:\PS> $p.getowner()

__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 3
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
Domain : DOMAIN01
ReturnValue : 0
User : user01

Description
-----------
This command shows how to find the owner of a process. Because the System.D
iagnostics.Process object that Get-Process returns does not have a property
or method that returns the process owner, the command uses
the Get-WmiObject cmdlet to get a Win32_Process object that represents the
same process.

The first command uses Get-WmiObject to get the PowerShell process. It save
s it in the $p variable.

The second command uses the GetOwner method to get the owner of the process
in $p. The command reveals that the owner is Domain01\user01.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>get-process powershell

C:\PS> get-process -id $pid

C:\PS> get-process powershell

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
308 26 52308 61780 567 3.18 5632 powershell
377 26 62676 63384 575 3.88 5888 powershell


C:\PS> get-process -id $pid

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
396 26 56488 57236 575 3.90 5888 powershell

Description
-----------
These commands show how to use the $pid automatic variable to identify the
process that is hosting the current Windows PowerShell session. You can use
this method to distinguish the host process from other PowerShell processe
s that you might want to stop or close.

The first command gets all of the PowerShell processes in the current sessi
on.

The second command gets the PowerShell process that is hosting the current
session.




REMARKS
To see the examples, type: "get-help Get-Process -examples".
For more information, type: "get-help Get-Process -detailed".
For technical information, type: "get-help Get-Process -full".

NAME
Group-Object

SYNOPSIS
Groups objects that contain the same value for specified properties.


SYNTAX
Group-Object [-AsHashTable] [-AsString] [[-Property] <Object[]>] [-CaseSens
itive] [-Culture <string>] [-InputObject <psobject>] [-NoElement] [<CommonP
arameters>]


DESCRIPTION
The Group-Object cmdlet displays objects in groups based on the value of a
specified property. Group-Object returns a table with one row for each prop
erty value and a column that displays the number of items with that value.

If you specify more than one property, Group-Object first groups them by th
e values of the first property, and then, within each property group, it gr
oups by the value of the next property.

PARAMETERS
-AsHashTable [<SwitchParameter>]
Returns the group as a hash table. The keys of the hash table are the
property values by which the objects are grouped. The values of the has
h table are the objects that have that property value.

By itself, the AsHashTable parameter returns each hash table in which e
ach key is an instance of the grouped object. When used with the AsStr
ing parameter, the keys in the hash table are strings.

-AsString [<SwitchParameter>]
Converts the hash table keys to strings. By default, the hash table key
s are instances of the grouped object. This parameter is valid only whe
n used with the AsHashTable parameter.

-CaseSensitive [<SwitchParameter>]
Makes the grouping case-sensitive. Without this parameter, the property
values of objects in a group might have different cases.

-Culture <string>
Specifies the culture to use when comparing strings.

-InputObject <psobject>
Specifies the objects to group. Enter a variable that contains the obje
cts, or type a command or expression that gets the objects.

When you use the InputObject parameter to submit a collection of object
s to Group-Object, Group-Object receives one object that represents the
collection. As a result, it creates a single group with that object as
its member.

To group the objects in a collection, pipe the objects to Group-Object.

-NoElement [<SwitchParameter>]
Omits the members of a group from the results.

-Property <Object[]>
Specifies the properties for grouping. The objects are arranged into gr
oups based on the value of the specified property.

The value of the Property parameter can be a new calculated property. T
o create a calculated, property, create a hash table with an Expression
key that specifies a string or script block value.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-childitem *.doc | group-object -property length

Description
-----------
This command gets the files in the current location that have a .doc extens
ion and groups them by size.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-childitem | sort-object -property extension | group-object -prope
rty extension

Description
-----------
This command gets the files in the current location, sorts them by file nam
e extension, and then groups them by file name extension. Note that the fil
es are sorted before they are grouped.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>1..35 | group-object -property {$_ % 2},{$_ % 3}

Description
-----------
This example shows how to use script blocks as the value of the Property pa
rameter.

This command displays the integers from 1 to 35, grouped by the remainder l
eft when they are divided by 2 or 3.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$events = get-eventlog -logname system -newest 1000

C:\PS> $events | group-object -property eventID

Count Name Group
----- ---- -----
44 Information {System.Diagnostics.EventLogEntry,
5 Error {System.Diagnostics.EventLogEntry,
1 Warning {System.Diagnostics.EventLogEntry}

Description
-----------
These commands display the 1,000 most recent entries in the System event lo
g, grouped by Event ID.

The first command uses the Get-EventLog cmdlet to retrieve the events and t
he assignment operator (=) to save them in the $events variable.

The second command uses a pipeline operator (|) to send the events in the $
events variable to the Group-Object cmdlet. The command uses the Property p
arameter to specify that the events should be grouped according to the valu
e of their EventID property.

In the output, the Count column represents the number of entries in each gr
oup, the Name column represents the EventID values that define a group, and
the Group column represents the objects in each group.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-process | group-object -property priorityclass

Count Name Group
----- ---- -----
55 Normal {System.Diagnostics.Process (AdtAgent), System.Di
agnostics.Process (alg), System.Dia...
1 {System.Diagnostics.Process (Idle)}
3 High {System.Diagnostics.Process (Newproc), System.Dia
gnostics.Process (winlogon), System.D...
2 BelowNormal {System.Diagnostics.Process (winperf),


C:\PS>get-process | group-object -property company -noelement
Count Name
----- ----
55 Normal
1
3 High
2 BelowNormal

Description
-----------
This example demonstrates the effect of the NoElement parameter. These comm
ands group the processes on the computer by priority class.

The first command uses the Get-Process cmdlet to get the processes on the c
omputer. It uses a pipeline operator (|) to send the results to Group-Objec
t, which groups the objects by the value of the PriorityClass property of t
he process.

The second command is identical to the first, except that it uses the NoEle
ment parameter to eliminate the members of the group from the output. The r
esult is a table with only the count and property value name.

The results are shown in the following sample output.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-eventlog -logname system -newest 1000 | group-object -property {$
_.TimeWritten - $_.TimeGenerated}

Description
-----------
This command demonstrates how to provide the value of the Property paramete
r as a script block.

This command displays the most recent 1,000 entries from the system event l
og, grouped according to the time between when they were generated and when
they were written to the log.

The command uses the Get-EventLog cmdlet to get the event log entries. It u
ses a pipeline operator (|) to send the entries to the Group-Object cmdlet.
The value of the Property parameter is specified as a script block (an exp
ression in braces). The result of evaluating the script block is the time b
etween when the log entry was generated and when it was written to the log.
That value is used to group the 1,000 most recent events.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-childitem | group-object extension -noelement

Count Name
----- ----
21
82 .txt
9 .cmd
5 .log
12 .xml
5 .htm
36 .ps1
1 .psc1
3 .exe
6 .csv
1 .psd1
2 .bat

Description
-----------
This command groups the items in the current directory by file name extensi
on. It uses the NoElement parameter to omit the members of the group.

The results are shown in the following sample output.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>"a", "b", "c", "c", "d" | get-unique

a
b
c
d

C:\PS> "a", "b", "c", "c", "d" | group-object -noelement | where {$_.Count
-gt 1}
Count Name
----- ----
2 c

C:\PS> get-process | group-object -property Name -noelement | where {$_.cou
nt -gt 1}
Count Name
----- ----
2 csrss
5 svchost
2 winlogon
2 wmiprvse

Description
-----------
This example shows how to find the unique and non-unique (repeated) propert
y values in a collection.

The first command gets the unique elements of an array by piping the array
to the Get-Unique cmdlet.

The second command gets the non-unique elements of an array. It pipes the a
rray to the Group-Object cmdlet, which groups the objects by value. The res
ulting groups are piped to the Where-Object cmdlet, which selects objects w
ith groups with more than one member.

The third command shows a practical use for this technique. It uses the sam
e method to find processes on the computer that have the same process name.

The results are shown in the following sample output.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>$a = get-command get-*, set-* -type cmdlet | group-object -property v
erb -ashashtable -asstring

C:\PS> $a

Name Value
---- -----
Get {Get-PSCallStack, Get-PSBreakpoint, Get-PSDrive, Get-PSSession...}
Set {Set-Service, Set-StrictMode, Set-PSDebug, Set-PSSessionConfigurati
on...}

C:\PS> $a.get

CommandType Name Definition
----------- ---- ----------
Cmdlet Get-PSCallStack Get-PSCallStack [-Verbose] [-Debug] [-
ErrorAction <ActionPrefer...
Cmdlet Get-PSBreakpoint Get-PSBreakpoint [[-Id] <Int32[]>] [-V
erbose] [-Debug] [-ErrorA...
Cmdlet Get-PSDrive Get-PSDrive [[-Name] <String[]>] [-Sco
pe <String>] [-PSProvider...
...

Description
-----------
This example uses the AsHashTable and AsString parameters to return the gro
ups in a hash table, that is, as a collection of key-value pairs.

In the resulting hash table, each property value is a key, and the group el
ements are the values. Because each key is a property of the hash table obj
ect, you can use dot notation to display the values.

The first command gets the Get and Set cmdlets in the session, groups them
by verb, returns the groups as a hash table, and saves the hash table in th
e $a variable.

The second command displays the hash table in $a. There are two key-value p
airs, one for the Get cmdlets and one for the Set cmdlets.

The third command uses dot notation to display the values of the Get key in
$a. The values are CmdletInfo object. The AsString parameter does not conv
ert the objects in the groups to strings.




REMARKS
To see the examples, type: "get-help Group-Object -examples".
For more information, type: "get-help Group-Object -detailed".
For technical information, type: "get-help Group-Object -full".

NAME
Group-Object

SYNOPSIS
Groups objects that contain the same value for specified properties.


SYNTAX
Group-Object [-AsHashTable] [-AsString] [[-Property] <Object[]>] [-CaseSens
itive] [-Culture <string>] [-InputObject <psobject>] [-NoElement] [<CommonP
arameters>]


DESCRIPTION
The Group-Object cmdlet displays objects in groups based on the value of a
specified property. Group-Object returns a table with one row for each prop
erty value and a column that displays the number of items with that value.

If you specify more than one property, Group-Object first groups them by th
e values of the first property, and then, within each property group, it gr
oups by the value of the next property.

PARAMETERS
-AsHashTable [<SwitchParameter>]
Returns the group as a hash table. The keys of the hash table are the
property values by which the objects are grouped. The values of the has
h table are the objects that have that property value.

By itself, the AsHashTable parameter returns each hash table in which e
ach key is an instance of the grouped object. When used with the AsStr
ing parameter, the keys in the hash table are strings.

-AsString [<SwitchParameter>]
Converts the hash table keys to strings. By default, the hash table key
s are instances of the grouped object. This parameter is valid only whe
n used with the AsHashTable parameter.

-CaseSensitive [<SwitchParameter>]
Makes the grouping case-sensitive. Without this parameter, the property
values of objects in a group might have different cases.

-Culture <string>
Specifies the culture to use when comparing strings.

-InputObject <psobject>
Specifies the objects to group. Enter a variable that contains the obje
cts, or type a command or expression that gets the objects.

When you use the InputObject parameter to submit a collection of object
s to Group-Object, Group-Object receives one object that represents the
collection. As a result, it creates a single group with that object as
its member.

To group the objects in a collection, pipe the objects to Group-Object.

-NoElement [<SwitchParameter>]
Omits the members of a group from the results.

-Property <Object[]>
Specifies the properties for grouping. The objects are arranged into gr
oups based on the value of the specified property.

The value of the Property parameter can be a new calculated property. T
o create a calculated, property, create a hash table with an Expression
key that specifies a string or script block value.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-childitem *.doc | group-object -property length

Description
-----------
This command gets the files in the current location that have a .doc extens
ion and groups them by size.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-childitem | sort-object -property extension | group-object -prope
rty extension

Description
-----------
This command gets the files in the current location, sorts them by file nam
e extension, and then groups them by file name extension. Note that the fil
es are sorted before they are grouped.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>1..35 | group-object -property {$_ % 2},{$_ % 3}

Description
-----------
This example shows how to use script blocks as the value of the Property pa
rameter.

This command displays the integers from 1 to 35, grouped by the remainder l
eft when they are divided by 2 or 3.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$events = get-eventlog -logname system -newest 1000

C:\PS> $events | group-object -property eventID

Count Name Group
----- ---- -----
44 Information {System.Diagnostics.EventLogEntry,
5 Error {System.Diagnostics.EventLogEntry,
1 Warning {System.Diagnostics.EventLogEntry}

Description
-----------
These commands display the 1,000 most recent entries in the System event lo
g, grouped by Event ID.

The first command uses the Get-EventLog cmdlet to retrieve the events and t
he assignment operator (=) to save them in the $events variable.

The second command uses a pipeline operator (|) to send the events in the $
events variable to the Group-Object cmdlet. The command uses the Property p
arameter to specify that the events should be grouped according to the valu
e of their EventID property.

In the output, the Count column represents the number of entries in each gr
oup, the Name column represents the EventID values that define a group, and
the Group column represents the objects in each group.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-process | group-object -property priorityclass

Count Name Group
----- ---- -----
55 Normal {System.Diagnostics.Process (AdtAgent), System.Di
agnostics.Process (alg), System.Dia...
1 {System.Diagnostics.Process (Idle)}
3 High {System.Diagnostics.Process (Newproc), System.Dia
gnostics.Process (winlogon), System.D...
2 BelowNormal {System.Diagnostics.Process (winperf),


C:\PS>get-process | group-object -property company -noelement
Count Name
----- ----
55 Normal
1
3 High
2 BelowNormal

Description
-----------
This example demonstrates the effect of the NoElement parameter. These comm
ands group the processes on the computer by priority class.

The first command uses the Get-Process cmdlet to get the processes on the c
omputer. It uses a pipeline operator (|) to send the results to Group-Objec
t, which groups the objects by the value of the PriorityClass property of t
he process.

The second command is identical to the first, except that it uses the NoEle
ment parameter to eliminate the members of the group from the output. The r
esult is a table with only the count and property value name.

The results are shown in the following sample output.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-eventlog -logname system -newest 1000 | group-object -property {$
_.TimeWritten - $_.TimeGenerated}

Description
-----------
This command demonstrates how to provide the value of the Property paramete
r as a script block.

This command displays the most recent 1,000 entries from the system event l
og, grouped according to the time between when they were generated and when
they were written to the log.

The command uses the Get-EventLog cmdlet to get the event log entries. It u
ses a pipeline operator (|) to send the entries to the Group-Object cmdlet.
The value of the Property parameter is specified as a script block (an exp
ression in braces). The result of evaluating the script block is the time b
etween when the log entry was generated and when it was written to the log.
That value is used to group the 1,000 most recent events.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-childitem | group-object extension -noelement

Count Name
----- ----
21
82 .txt
9 .cmd
5 .log
12 .xml
5 .htm
36 .ps1
1 .psc1
3 .exe
6 .csv
1 .psd1
2 .bat

Description
-----------
This command groups the items in the current directory by file name extensi
on. It uses the NoElement parameter to omit the members of the group.

The results are shown in the following sample output.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>"a", "b", "c", "c", "d" | get-unique

a
b
c
d

C:\PS> "a", "b", "c", "c", "d" | group-object -noelement | where {$_.Count
-gt 1}
Count Name
----- ----
2 c

C:\PS> get-process | group-object -property Name -noelement | where {$_.cou
nt -gt 1}
Count Name
----- ----
2 csrss
5 svchost
2 winlogon
2 wmiprvse

Description
-----------
This example shows how to find the unique and non-unique (repeated) propert
y values in a collection.

The first command gets the unique elements of an array by piping the array
to the Get-Unique cmdlet.

The second command gets the non-unique elements of an array. It pipes the a
rray to the Group-Object cmdlet, which groups the objects by value. The res
ulting groups are piped to the Where-Object cmdlet, which selects objects w
ith groups with more than one member.

The third command shows a practical use for this technique. It uses the sam
e method to find processes on the computer that have the same process name.

The results are shown in the following sample output.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>$a = get-command get-*, set-* -type cmdlet | group-object -property v
erb -ashashtable -asstring

C:\PS> $a

Name Value
---- -----
Get {Get-PSCallStack, Get-PSBreakpoint, Get-PSDrive, Get-PSSession...}
Set {Set-Service, Set-StrictMode, Set-PSDebug, Set-PSSessionConfigurati
on...}

C:\PS> $a.get

CommandType Name Definition
----------- ---- ----------
Cmdlet Get-PSCallStack Get-PSCallStack [-Verbose] [-Debug] [-
ErrorAction <ActionPrefer...
Cmdlet Get-PSBreakpoint Get-PSBreakpoint [[-Id] <Int32[]>] [-V
erbose] [-Debug] [-ErrorA...
Cmdlet Get-PSDrive Get-PSDrive [[-Name] <String[]>] [-Sco
pe <String>] [-PSProvider...
...

Description
-----------
This example uses the AsHashTable and AsString parameters to return the gro
ups in a hash table, that is, as a collection of key-value pairs.

In the resulting hash table, each property value is a key, and the group el
ements are the values. Because each key is a property of the hash table obj
ect, you can use dot notation to display the values.

The first command gets the Get and Set cmdlets in the session, groups them
by verb, returns the groups as a hash table, and saves the hash table in th
e $a variable.

The second command displays the hash table in $a. There are two key-value p
airs, one for the Get cmdlets and one for the Set cmdlets.

The third command uses dot notation to display the values of the Get key in
$a. The values are CmdletInfo object. The AsString parameter does not conv
ert the objects in the groups to strings.




REMARKS
To see the examples, type: "get-help Group-Object -examples".
For more information, type: "get-help Group-Object -detailed".
For technical information, type: "get-help Group-Object -full".

NAME
Get-PSSession

SYNOPSIS
Gets the Windows PowerShell sessions (PSSessions) in the current session.


SYNTAX
Get-PSSession [[-ComputerName] <string[]>] [<CommonParameters>]

Get-PSSession [-Id] <Int32[]> [<CommonParameters>]

Get-PSSession [-InstanceId <Guid[]>] [<CommonParameters>]

Get-PSSession [-Name <string[]>] [<CommonParameters>]


DESCRIPTION
The Get-PSSession cmdlet gets the Windows PowerShell sessions (PSSessions)
that were created in the current session.

Without parameters, Get-PSSession gets all of the PSSessions created in the
current session. You can use the parameters of Get-PSSession to get the se
ssions that are connected to particular computers, or you can identify sess
ions by their names, IDs, or instance IDs.

For more information about Windows PowerShell sessions, see about_PSSession
s.

PARAMETERS
-ComputerName <string[]>
Gets only the PSSessions that are connected to the specified computers.
Wildcards are permitted.

Type the NetBIOS name, an IP address, or a fully-qualified domain name
of one or more computers. To specify the local computer, type the compu
ter name, "localhost", or a dot (.).

-Id <Int32[]>
Gets only the PSSessions with the specified IDs. Type one or more IDs (
separated by commas), or use the range operator (..) to specify a range
of IDs.

An ID is an integer that uniquely identifies the PSSession in the curre
nt session. It is easier to remember and type than the InstanceId, but
it is unique only within the current session. To find the ID of a PSSe
ssion, use Get-PSSession without parameters.

-InstanceId <Guid[]>
Gets only the PSSessions with the specified instance IDs.

The instance ID is a GUID that uniquely identifies a PSSession on a loc
al or remote computer. The InstanceID is unique, even when you have mul
tiple sessions running in Windows PowerShell.

The InstanceID is stored in the InstanceID property of the object that
represents a PSSession. To find the InstanceID of the PSSessions in the
current session, type "get-pssession | format-table Name, ComputerName
, InstanceId".

-Name <string[]>
Gets only the PSSessions with the specified friendly names. Wildcards a
re permitted.

To find the names of the PSSessions in the current session, type "get-p
ssession" without parameters.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-pssession

Description
-----------
This command gets all of the PSSessions that were created in the current se
ssion.

It does not get PSSessions that were created in other sessions or on other
computers, even if they connect to this computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$s = get-pssession -computername Server02

Description
-----------
This command gets the PSSessions that are connected to the Server02 compute
r and saves them in the $p variable.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>new-pssession -computername Server01, Server02, Server03

C:\PS> $s1, $s2, $s3 = get-pssession

Description
-----------
This example shows how to save the results of a Get-PSSession command in mu
ltiple variables.

The first command uses the New-PSSession cmdlet to create PSSessions on thr
ee remote computers.

The second command uses a Get-PSSession cmdlet to get the three PSSessions.
It then saves each of the PSSessions in a separate variable.

When Windows PowerShell assigns an array of objects to an array of variable
s, it assigns the first object to the first variable, the second object to
the second variable, and so on. If there are more objects than variables, i
t assigns all remaining objects to the last variable in the array. If there
are more variables than objects, the extra variables are not used.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-pssession | format-table -property computername, InstanceID

C:\PS> $s = get-pssession -InstanceID a786be29-a6bb-40da-80fb-782c67f7db0f

C:\PS> remove-pssession -session $s

Description
-----------
This example shows how to get a PSSession by using its instance ID, and the
n to delete the PSSession.

The first command gets all of the PSSessions on the local computer. It send
s the PSSessions to the Format-Table cmdlet, which displays the ComputerNam
e and InstanceID properties of each PSSession.

The second command uses the Get-PSSession cmdlet to get a particular PSSess
ion and to save it in the $s variable. The command uses the InstanceID para
meter to identify the PSSession.

The third command uses the Remove-PSSession cmdlet to delete the PSSession
in the $s variable.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-pssession -computername Serv*

Description
-----------
This command gets all the PSSessions that connect to computers that have co
mputer names that begin with "Serv".




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-pssession -name Test*, Ux*

Description
-----------
This command gets PSSessions that have names that begin with "Test" or "Ux"
.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-pssession 2

Description
-----------
This command gets the PSSession with ID 2.




REMARKS
To see the examples, type: "get-help Get-PSSession -examples".
For more information, type: "get-help Get-PSSession -detailed".
For technical information, type: "get-help Get-PSSession -full".

NAME
Get-PSSnapin

SYNOPSIS
Gets the Windows PowerShell snap-ins on the computer.


SYNTAX
Get-PSSnapin [[-Name] <string[]>] [-Registered] [<CommonParameters>]


DESCRIPTION
The Get-PSSnapin cmdlet gets the Windows PowerShell snap-ins that have been
added to the current session or that have been registered on the system. T
he snap-ins are listed in the order in which they are detected.

Get-PSSnapin gets only registered snap-ins. To register a Windows PowerShel
l snap-in, use the InstallUtil tool included with the Microsoft .NET Framew
ork 2.0. For more information, see "How to Register Cmdlets, Providers, and
Host Applications" in the MSDN (Microsoft Developer Network) library at ht
tp://go.microsoft.com/fwlink/?LinkId=143619.

PARAMETERS
-Name <string[]>
Gets only the specified Windows PowerShell snap-ins. Enter the names of
one or more Windows PowerShell snap-ins. Wildcards are permitted.

The parameter name ("Name") is optional.

-Registered [<SwitchParameter>]
Gets the Windows PowerShell snap-ins that have been registered on the s
ystem (even if they have not yet been added to the session).

The snap-ins that are installed with Windows PowerShell do not appear i
n this list.

Without this parameter, Get-PSSnapin gets the Windows PowerShell snap-i
ns that have been added to the session.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-PSSnapIn

Description
-----------
This command gets the Windows PowerShell snap-ins that are currently loaded
in the session. This includes the snap-ins that are installed with Windows
PowerShell and those that have been added to the session.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-PSSnapIn -registered

Description
-----------
This command gets the Windows PowerShell snap-ins that have been registered
on the computer, including those that have already been added to the sessi
on. The output does not include snap-ins that are installed with Windows Po
werShell or Windows PowerShell snap-in dynamic-link libraries (DLLs) that h
ave not yet been registered on the system.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-PSSnapIn smp*

Description
-----------
This command gets the Windows PowerShell snap-ins in the current session th
at have names that begin with "smp".




REMARKS
To see the examples, type: "get-help Get-PSSnapin -examples".
For more information, type: "get-help Get-PSSnapin -detailed".
For technical information, type: "get-help Get-PSSnapin -full".

NAME
Get-Service

SYNOPSIS
Gets the services on a local or remote computer.


SYNTAX
Get-Service [[-Name] <string[]>] [-ComputerName <string[]>] [-DependentServ
ices] [-Exclude <string[]>] [-Include <string[]>] [-RequiredServices] [<Com
monParameters>]

Get-Service -DisplayName <string[]> [-ComputerName <string[]>] [-DependentS
ervices] [-Exclude <string[]>] [-Include <string[]>] [-RequiredServices] [<
CommonParameters>]

Get-Service [-InputObject <ServiceController[]>] [-ComputerName <string[]>]
[-DependentServices] [-Exclude <string[]>] [-Include <string[]>] [-Require
dServices] [<CommonParameters>]


DESCRIPTION
The Get-Service cmdlet gets objects that represent the services on a local
computer or on a remote computer, including running and stopped services.

You can direct Get-Service to get only particular services by specifying th
e service name or display name of the services, or you can pipe service obj
ects to Get-Service.

PARAMETERS
-ComputerName <string[]>
Gets the services running on the specified computers. The default is th
e local computer.

Type the NetBIOS name, an IP address, or a fully qualified domain name
of a remote computer. To specify the local computer, type the computer
name, a dot (.), or "localhost".

This parameter does not rely on Windows PowerShell remoting. You can us
e the ComputerName parameter of Get-Service even if your computer is no
t configured to run remote commands.

-DependentServices [<SwitchParameter>]
Gets only the services that depend upon the specified service.

By default, Get-Service gets all services.

-DisplayName <string[]>
Specifies the display names of services to be retrieved. Wildcards are
permitted. By default, Get-Service gets all services on the computer.

-Exclude <string[]>
Omits the specified services. The value of this parameter qualifies the
Name parameter. Enter a name element or pattern, such as "s*". Wildcar
ds are permitted.

-Include <string[]>
Retrieves only the specified services. The value of this parameter qual
ifies the Name parameter. Enter a name element or pattern, such as "s*"
. Wildcards are permitted.

-InputObject <ServiceController[]>
Specifies ServiceController objects representing the services to be ret
rieved. Enter a variable that contains the objects, or type a command o
r expression that gets the objects. You can also pipe a service object
to Get-Service.

-Name <string[]>
Specifies the service names of services to be retrieved. Wildcards are
permitted. By default, Get-Service gets all of the services on the comp
uter.

-RequiredServices [<SwitchParameter>]
Gets only the services that this service requires.

This parameter gets the value of the ServicesDependedOn property of the
service. By default, Get-Service gets all services.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-service

Description
-----------
This command retrieves all of the services on the system. It behaves as tho
ugh you typed "get-service *". The default display shows the status, servic
e name, and display name of each service.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-service wmi*

Description
-----------
This command retrieves services with service names that begin with "WMI" (t
he acronym for Windows Management Instrumentation).




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-service -displayname *network*

Description
-----------
This command displays services with a display name that includes the word
"network". Searching the display name finds network-related services even w
hen the service name does not include "Net", such as xmlprov, the Network P
rovisioning Service.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-service -name win* -exclude winrm

Description
-----------
These commands get only the services with service names that begin with "wi
n", except for the WinRM service.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-service | where-object {$_.Status -eq "Running"}

Description
-----------
This command displays only the services that are currently running. It uses
the Get-Service cmdlet to get all of the services on the computer. The pip
eline operator (|) passes the results to the Where-Object cmdlet, which sel
ects only the services with a Status property that equals "Running".

Status is only one property of service objects. To see all of the propertie
s, type "get-service | get-member".




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-service -computername Server02

Description
-----------
This command gets the services on the Server02 remote computer.

Because the ComputerName parameter of Get-Service does not use Windows Powe
rShell remoting, you can use this parameter even if the computer is not con
figured for remoting in Windows PowerShell.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-service | where-object {$_.DependentServices} | format-list -prop
erty Name, DependentServices, @{Label="NoOfDependentS
ervices"; Expression={$_.dependentservices.count}}

Name : AudioEndpointBuilder
DependentServices : {AudioSrv}
NoOfDependentServices : 1

Name : Dhcp
DependentServices : {WinHttpAutoProxySvc}
NoOfDependentServices : 1
...

Description
-----------
These commands list the services on the computer that have dependent servic
es.

The first command uses the Get-Service cmdlet to get the services on the co
mputer. A pipeline operator (|) sends the services to the Where-Object cmdl
et, which selects the services whose DependentServices property is not null
.

Another pipeline operator sends the results to the Format-List cmdlet. The
command uses its Property parameter to display the name of the service, the
name of the dependent services, and a calculated property that displays th
e number of dependent services that each service has.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>C:\PS> get-service s* | sort-object status

Status Name DisplayName
------ ---- -----------
Stopped stisvc Windows Image Acquisition (WIA)
Stopped SwPrv MS Software Shadow Copy Provider
Stopped SysmonLog Performance Logs and Alerts
Running Spooler Print Spooler
Running srservice System Restore Service
Running SSDPSRV SSDP Discovery Service
Running ShellHWDetection Shell Hardware Detection
Running Schedule Task Scheduler
Running SCardSvr Smart Card
Running SamSs Security Accounts Manager
Running SharedAccess Windows Firewall/Internet Connectio...
Running SENS System Event Notification
Running seclogon Secondary Logon

C:\PS> get-service s* | sort-object status -descending

Status Name DisplayName
------ ---- -----------
Running ShellHWDetection Shell Hardware Detection
Running SharedAccess Windows Firewall/Internet Connectio...
Running Spooler Print Spooler
Running SSDPSRV SSDP Discovery Service
Running srservice System Restore Service
Running SCardSvr Smart Card
Running SamSs Security Accounts Manager
Running Schedule Task Scheduler
Running SENS System Event Notification
Running seclogon Secondary Logon
Stopped SysmonLog Performance Logs and Alerts
Stopped SwPrv MS Software Shadow Copy Provider
Stopped stisvc Windows Image Acquisition (WIA)

Description
-----------
This command shows that when you sort services in ascending order by the va
lue of their Status property, stopped services appear before running servic
es. This happens because the value of Status is an enumeration, in which "S
topped" has a value of "1", and "Running" has a value of 4.

To list running services first, use the Descending parameter of the Sort-Ob
ject cmdlet.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>get-service -name winrm -computername localhost, Server01, Server02
| format-table -property MachineName, Status, Name, DisplayName -auto

MachineName Status Name DisplayName
------------ ------ ---- -----------
localhost Running WinRM Windows Remote Management (WS-Management)
Server01 Running WinRM Windows Remote Management (WS-Management)
Server02 Running WinRM Windows Remote Management (WS-Management)

Description
-----------
This command uses the Get-Service cmdlet to run a "Get-Service Winrm" comma
nd on two remote computers and the local computer ("localhost").

The Get-Service command runs on the remote computers, and the results are r
eturned to the local computer. A pipeline operator (|) sends the results to
the Format-Table cmdlet, which formats the services as a table. The Format
-Table command uses the Property parameter to specify the properties displa
yed in the table, including the MachineName property.




-------------------------- EXAMPLE 10 --------------------------

C:\PS>get-service winrm -requiredServices

Description
-----------
This command gets the services that the WinRM service requires.

The command returns the value of the ServicesDependedOn property of the ser
vice.




-------------------------- EXAMPLE 11 --------------------------

C:\PS>"winrm" | get-service

Description
-----------
This command gets the WinRM service on the local computer. This example sho
ws that you can pipe a service name string (enclosed in quotation marks) to
Get-Service.




REMARKS
To see the examples, type: "get-help Get-Service -examples".
For more information, type: "get-help Get-Service -detailed".
For technical information, type: "get-help Get-Service -full".

NAME
Get-Unique

SYNOPSIS
Returns the unique items from a sorted list.


SYNTAX
Get-Unique [-AsString] [-InputObject <psobject>] [<CommonParameters>]

Get-Unique [-OnType] [-InputObject <psobject>] [<CommonParameters>]


DESCRIPTION
The Get-Unique cmdlet compares each item in a sorted list to the next item,
eliminates duplicates, and returns only one instance of each item. The lis
t must be sorted for the cmdlet to work properly.

PARAMETERS
-AsString [<SwitchParameter>]
Treats the data as a string. Without this parameter, data is treated as
an object, so when you submit a collection of objects of the same type
to Get-Unique, such as a collection of files, it returns just one (the
first). You can use this parameter to find the unique values of object
properties, such as the file names.

-InputObject <psobject>
Accepts input for Get-Unique. Enter a variable that contains the object
s or type a command or expression that gets the objects.

Get-Unique treats the input submitted by using InputObject as a collect
ion; it does not enumerate individual items in the collection. Because
the collection is a single item, input submitted by using InputObject i
s always returned unchanged.

-OnType [<SwitchParameter>]
Returns only one object of each type.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$a = $(foreach ($line in get-content C:\Test1\File1.txt) {$line.tolow
er().split(" ")}) | sort | get-unique

C:\PS> $a.count

Description
-----------
These commands find the number of unique words in a text file.

The first command gets the content of the File.txt file. It converts each l
ine of text to lowercase letters and then splits each word onto a separate
line at the space (" "). Then, it sorts the resulting list alphabetically (
the default) and uses the Get-Unique cmdlet to eliminate any duplicate word
s. The results are stored in the $a variable.

The second command uses the Count property of the collection of strings in
$a to determine how many items are in $a.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>1,1,1,1,12,23,4,5,4643,5,3,3,3,3,3,3,3 | sort-object | Get-Unique

Description
-----------
This command finds the unique members of the set of integers. The first com
mand takes an array of integers typed at the command line, pipes them to th
e Sort-Object cmdlet to be sorted, and then pipes them to Get-Unique, which
eliminates duplicate entries.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-childitem | sort-object {$_.GetType()} | unique -OnType

Description
-----------
This command uses the Get-ChildItem cmdlet to retrieve the contents of the
local directory, which includes files and directories. The pipeline operato
r (|) sends the results to the Sort-Object cmdlet. The "$_.GetType()" state
ment applies the GetType method to each file or directory. Then, Sort-Objec
t sorts the items by type. Another pipeline operator sends the results to G
et-Unique. The OnType parameter directs Get-Unique to return only one objec
t of each type.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-process | sort-object | select processname | get-unique -asstring

Description
-----------
This command gets the names of processes running on the computer with dupli
cates eliminated.

The Get-Process command gets all of the processes on the computer. The pipe
line operator (|) passes the result to Sort-Object, which, by default, sort
s the processes alphabetically by ProcessName. The results are piped to the
Select-Object cmdlet, which selects only the values of the ProcessName pro
perty of each object. The results are then piped to Get-Unique to eliminate
duplicates.

The AsString parameter tells Get-Unique to treat the ProcessName values as
strings. Without this parameter, Get-Unique treats the ProcessName values a
s objects and returns only one instance of the object, that is, the first p
rocess name in the list.




REMARKS
To see the examples, type: "get-help Get-Unique -examples".
For more information, type: "get-help Get-Unique -detailed".
For technical information, type: "get-help Get-Unique -full".

NAME
Get-Variable

SYNOPSIS
Gets the variables in the current console.


SYNTAX
Get-Variable [[-Name] <string[]>] [-Exclude <string[]>] [-Include <string[]
>] [-Scope <string>] [-ValueOnly] [<CommonParameters>]


DESCRIPTION
The Get-Variable cmdlet gets the Windows PowerShell variables in the curren
t console. You can retrieve just the values of the variables by specifying
the ValueOnly parameter, and you can filter the variables returned by name.

PARAMETERS
-Exclude <string[]>
Omits the specified items. Wildcards are permitted.

-Include <string[]>
Specifies only the items upon which the cmdlet will act, excluding all
others. Wildcards are permitted.

-Name <string[]>
Specifies the name of the variable.

-Scope <string>
Gets only the variables in the specified scope. Valid values are "Globa
l", "Local", or "Script", or a number relative to the current scope (0
through the number of scopes, where 0 is the current scope and 1 is its
parent). "Local" is the default. For more information, see about_Scope
s.

-ValueOnly [<SwitchParameter>]
Gets only the value of the variable.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-variable m*

Description
-----------
This command displays variables with names that begin with the letter "m".
The value of the variables is also displayed.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-variable m* -valueonly

Description
-----------
This command displays only the values of the variables with names that begi
n with the letter "m".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-variable -include M*,P* | sort-object name

Description
-----------
This command gets information about the variables that begin with either th
e letter "M" or the letter "P". The results are piped to the Sort-Object cm
dlet, sorted by name, and displayed.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-variable -scope 0

C:\PS> compare-object (get-variable -scope 0) (get-variable -scope 1)

Description
-----------
The first command gets only the variables that are defined in the local sco
pe. It is equivalent to "get-variable -scope local" and can be abbreviated
as "gv -s 0".

The second command uses the Compare-Object cmdlet to find the variables tha
t are defined in the parent scope (Scope 1) but are visible only in the loc
al scope (Scope 0).




REMARKS
To see the examples, type: "get-help Get-Variable -examples".
For more information, type: "get-help Get-Variable -detailed".
For technical information, type: "get-help Get-Variable -full".

NAME
Get-WmiObject

SYNOPSIS
Gets instances of Windows Management Instrumentation (WMI) classes or infor
mation about the available classes.


SYNTAX
Get-WmiObject [-Authority <string>] [-Amended] [-AsJob] [-Authentication {D
efault | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy |
Unchanged}] [-ComputerName <string[]>] [-Credential <PSCredential>] [-Enab
leAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Imperson
ate | Delegate}] [-Locale <string>] [-Namespace <string>] [-ThrottleLimit <
int>] [<CommonParameters>]

Get-WmiObject [[-Class] <string>] [-Authority <string>] [-List] [-Recurse]
[-Amended] [-AsJob] [-Authentication {Default | None | Connect | Call | Pac
ket | PacketIntegrity | PacketPrivacy | Unchanged}] [-ComputerName <string[
]>] [-Credential <PSCredential>] [-EnableAllPrivileges] [-Impersonation {De
fault | Anonymous | Identify | Impersonate | Delegate}] [-Locale <string>]
[-Namespace <string>] [-ThrottleLimit <int>] [<CommonParameters>]

Get-WmiObject [-Authority <string>] [-Amended] [-AsJob] [-Authentication {D
efault | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy |
Unchanged}] [-ComputerName <string[]>] [-Credential <PSCredential>] [-Enab
leAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Imperson
ate | Delegate}] [-Locale <string>] [-Namespace <string>] [-ThrottleLimit <
int>] [<CommonParameters>]

Get-WmiObject [-Class] <string> [[-Property] <string[]>] [-Authority <strin
g>] [-DirectRead] [-Filter <string>] [-Amended] [-AsJob] [-Authentication {
Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy
| Unchanged}] [-ComputerName <string[]>] [-Credential <PSCredential>] [-Ena
bleAllPrivileges] [-Impersonation {Default | Anonymous | Identify | Imperso
nate | Delegate}] [-Locale <string>] [-Namespace <string>] [-ThrottleLimit
<int>] [<CommonParameters>]

Get-WmiObject -Query <string> [-Authority <string>] [-DirectRead] [-Amended
] [-AsJob] [-Authentication {Default | None | Connect | Call | Packet | Pac
ketIntegrity | PacketPrivacy | Unchanged}] [-ComputerName <string[]>] [-Cre
dential <PSCredential>] [-EnableAllPrivileges] [-Impersonation {Default | A
nonymous | Identify | Impersonate | Delegate}] [-Locale <string>] [-Namespa
ce <string>] [-ThrottleLimit <int>] [<CommonParameters>]


DESCRIPTION
The Get-WmiObject cmdlet gets instances of WMI classes or information about
the available WMI classes. The ComputerName parameter can always be used t
o specify a remote computer. If the List parameter is specified, the cmdle
t gets information about the WMI classes that are available in a specified
namespace. If the Query parameter is specified, the cmdlet runs a WMI query
language (WQL) statement.

The Get-WmiObject cmdlet does not use the Windows PowerShell remoting infra
structure to perform remote operations. You can use the ComputerName parame
ter of the Get-WmiObject cmdlet even if your computer does not meet the req
uirements for Windows PowerShell remoting and even if your computer is not
configured for remoting in Windows PowerShell.

PARAMETERS
-Amended [<SwitchParameter>]
Gets or sets a value that indicates whether the objects that are return
ed from WMI should contain amended information. Typically, amended info
rmation is localizable information, such as object and property descrip
tions, that is attached to the WMI object..

-AsJob [<SwitchParameter>]
Runs the command as a background job. Use this parameter to run command
s that take a long time to finish.

When you use the AsJob parameter, the command returns an object that re
presents the background job and then displays the command prompt. You c
an continue to work in the session while the job finishes. If Get-WmiOb
ject is used against a remote computer, the job is created on the local
computer, and the results from remote computers are automatically retu
rned to the local computer. To manage the job, use the cmdlets that con
tain the Job noun (the Job cmdlets). To get the job results, use the Re
ceive-Job cmdlet.

Note: To use this parameter with remote computers, the local and remote
computers must be configured for remoting. Additionally, you must star
t Windows PowerShell by using the "Run as administrator" option in Wind
ows Vista and later versions of Windows,. For more information, see abo
ut_Remote_Requirements.

For more information about Windows PowerShell background jobs, see abo
ut_Jobs and about_Remote_Jobs.

-Authentication <AuthenticationLevel>
Specifies the authentication level to be used with the WMI connection.
Valid values are:

-1: Unchanged
0: Default
1: None (No authentication in performed.)
2: Connect (Authentication is performed only when the client establishe
s a relationship with the application.)
3: Call (Authentication is performed only at the beginning of each call
when the application receives the request.)
4: Packet (Authentication is performed on all the data that is received
from the client.)
5: PacketIntegrity (All the data that is transferred between the client
and the application is authenticated and verified.)
6: PacketPrivacy (The properties of the other authentication levels are
used, and all the data is encrypted.)

-Authority <string>
Specifies the authority to use to authenticate the WMI connection. You
can specify standard NTLM or Kerberos authentication. To use NTLM, set
the authority setting to ntlmdomain:<DomainName>, where <DomainName> id
entifies a valid NTLM domain name. To use Kerberos, specify kerberos:<D
omainName>\<ServerName>". You cannot include the authority setting when
you connect to the local computer.

-Class <string>
Specifies the name of a WMI class. When this parameter is used, the cmd
let retrieves instances of the WMI class.

-ComputerName <string[]>
Specifies the computer against which you want to run the management ope
ration. The value can be a fully qualified domain name, a NetBIOS name,
or an IP address. Use the local computer name, use localhost, or use a
dot (.) to specify the local computer. The local computer is the defau
lt. When the remote computer is in a different domain from the user, yo
u must use a fully qualified domain name. This parameter can also be pi
ped to the cmdlet.

This parameter does not rely on Windows PowerShell remoting, which uses
WS-Management ). You can use the ComputerName parameter of Get-WmiObje
ct even if your computer is not configured to run WS-Management remote
commands.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user. Type a user name, such as "User01", "Dom
ain01\User01", or User@Contoso.com. Or, enter a PSCredential object, su
ch as an object that is returned by the Get-Credential cmdlet. When you
type a user name, you will be prompted for a password.

-DirectRead [<SwitchParameter>]
Specifies whether direct access to the WMI provider is requested for th
e specified class without any regard to its base class or to its derive
d classes.

-EnableAllPrivileges [<SwitchParameter>]
Enables all the privileges of the current user before the command makes
the WMI call.

-Filter <string>
Specifies a Where clause to use as a filter. Uses the syntax of the WMI
Query Language (WQL).

Important: Do not include the Where keyword in the value of the paramet
er. For example, the following commands return only the logical disks t
hat where the DeviceID equals 'c:' and the services where the name equa
ls 'WinRM', without using the Where keyword:

get-WmiObject Win32_LogicalDisk -filter "DeviceID = 'c:' "
get-wmiobject win32_service -filter "name='WinRM'"

-Impersonation <ImpersonationLevel>
Specifies the impersonation level to use. Valid values are:

0: Default (reads the local registry for the default impersonation leve
l , which is usually set to "3: Impersonate".)
1: Anonymous (Hides the credentials of the caller.)
2: Identify (Allows objects to query the credentials of the caller.)
3: Impersonate (Allows objects to use the credentials of the caller.)
4: Delegate (Allows objects to permit other objects to use the credenti
als of the caller.)

-List [<SwitchParameter>]
Specifies whether to retrieve and display the names of the WMI classes
in the WMI repository namespace that is specified in the Namespace para
meter. The Default Namespace registry entry in the HKEY_LOCAL_MACHINE\
SOFTWARE\Microsoft\WBEM\Scripting registry key is not used by this cmdl
et to determine the default namespace. If you specify the List paramete
r but not the Namespace parameter, the root\CIMV2 namespace is used by
default.

-Locale <string>
Specifies the preferred locale for WMI objects. Specify the value of th
e Locale parameter as an array in the MS_<LCID> format in the preferred
order .

-Namespace <string>
When used with the Class parameter, this parameter specifies the WMI re
pository namespace where the referenced WMI class is located. When used
with the List parameter, it specifies the namespace from which to gath
er WMI class information.

-Property <string[]>
Specifies the WMI class property or set of properties to retrieve.

-Query <string>
Specifies a WMI Query Language (WQL) statement to run. Event queries ar
e not supported by this parameter.

-Recurse [<SwitchParameter>]
Makes the command search the current namespace and all other namespaces
for the class name that is specified in the Class parameter.

-ThrottleLimit <int>
Allows the user to specify a throttling value for the number of WMI ope
rations that can be executed simultaneously. This parameter is used tog
ether with the AsJob parameter.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-wmiobject win32_process


__GENUS : 2
__CLASS : Win32_Process
__SUPERCLASS : CIM_Process
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_Process.Handle="0"
__PROPERTY_COUNT : 45
__DERIVATION : {CIM_Process, CIM_LogicalElement, CIM_ManagedS
ystemElement}
__SERVER : SYSTEM01
__NAMESPACE : root\cimv2
__PATH : \\SYSTEM01\root\cimv2:Win32_Process.Handle="0"
Caption : System Idle Process
CommandLine :
CreationClassName : Win32_Process
CreationDate :
CSCreationClassName : Win32_ComputerSystem
CSName : SYSTEM01
Description : System Idle Process
ExecutablePath :
ExecutionState :
Handle : 0
HandleCount : 0
InstallDate :
KernelModeTime : 6138394740432
MaximumWorkingSetSize :
MinimumWorkingSetSize :
Name : System Idle Process
OSCreationClassName : Win32_OperatingSystem
OSName : Microsoftr Windows VistaT Ultimate |C:\Windows
|\Device\Harddisk0\Partition3
OtherOperationCount : 0
OtherTransferCount : 0
PageFaults : 0
PageFileUsage : 0
ParentProcessId : 0
PeakPageFileUsage : 0
PeakVirtualSize : 0
PeakWorkingSetSize : 0
Priority : 0
PrivatePageCount : 0
ProcessId : 0
QuotaNonPagedPoolUsage : 0
QuotaPagedPoolUsage : 0
QuotaPeakNonPagedPoolUsage : 0
QuotaPeakPagedPoolUsage : 0
ReadOperationCount : 0
ReadTransferCount : 0
SessionId : 0
Status :
TerminationDate :
ThreadCount : 2
UserModeTime : 0
VirtualSize : 0
WindowsVersion : 6.0.6001
WorkingSetSize : 24576
WriteOperationCount : 0
WriteTransferCount : 0
ProcessName : System Idle Process
Handles : 0
VM : 0
WS : 24576
Path :

...

Description
-----------
This command displays information about all the processes that are running
on a computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-wmiobject win32_service -computername 127.0.0.1

__GENUS : 2
__CLASS : Win32_Process
__SUPERCLASS : CIM_Process
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_Process.Handle="0"
__PROPERTY_COUNT : 45
__DERIVATION : {CIM_Process, CIM_LogicalElement, CIM_ManagedS
ystemElement}
__SERVER : SYSTEM02
__NAMESPACE : root\cimv2
__PATH : \\SYSTEM02\root\cimv2:Win32_Process.Handle="0"
Caption : System Idle Process
CommandLine :
CreationClassName : Win32_Process
CreationDate :
CSCreationClassName : Win32_ComputerSystem
CSName : SYSTEM02
Description : System Idle Process
ExecutablePath :
ExecutionState :
Handle : 0
HandleCount : 0
InstallDate :
KernelModeTime : 6138394740432
MaximumWorkingSetSize :
MinimumWorkingSetSize :
Name : System Idle Process
OSCreationClassName : Win32_OperatingSystem
OSName : Microsoftr Windows VistaT Ultimate |C:\Windows
|\Device\Harddisk0\Partition3
OtherOperationCount : 0
OtherTransferCount : 0
PageFaults : 0
PageFileUsage : 0
ParentProcessId : 0
PeakPageFileUsage : 0
PeakVirtualSize : 0
PeakWorkingSetSize : 0
Priority : 0
PrivatePageCount : 0
ProcessId : 0
QuotaNonPagedPoolUsage : 0
QuotaPagedPoolUsage : 0
QuotaPeakNonPagedPoolUsage : 0
QuotaPeakPagedPoolUsage : 0
ReadOperationCount : 0
ReadTransferCount : 0
SessionId : 0
Status :
TerminationDate :
ThreadCount : 2
UserModeTime : 0
VirtualSize : 0
WindowsVersion : 6.0.6001
WorkingSetSize : 24576
WriteOperationCount : 0
WriteTransferCount : 0
ProcessName : System Idle Process
Handles : 0
VM : 0
WS : 24576
Path :

...

Description
-----------
This command displays information about the services on the remote computer
. It displays the information by specifying the Internet Protocol (IP) addr
ess 127.0.0.1. You can change this IP address to any other valid IP address
on your network so that you can display information about the services on
that remote computer. By default, the account you are running under must be
a member of the local administrators group on the remote computer that you
specify .




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-wmiobject -namespace "root/default" -list


NameSpace: ROOT\default

Name Methods Properties
---- ------- ----------
__NotifyStatus {} {StatusCode}
__ExtendedStatus {} {Description, Oper
ation, ParameterInfo, ProviderName...}
__SecurityRelatedClass {} {}
__Trustee {} {Domain, Name, SID
, SidLength...}
__NTLMUser9X {} {Authority, Flags,
Mask, Name...}
__ACE {} {AccessMask, AceFl
ags, AceType, GuidInheritedObjectType...}
__SecurityDescriptor {} {ControlFlags, DAC
L, Group, Owner...}
__PARAMETERS {} {}
__SystemClass {} {}
__ProviderRegistration {} {provider}
__EventProviderRegistration {} {EventQueryList, p
rovider}
__ObjectProviderRegistration {} {InteractionType,
provider, QuerySupportLevels, SupportsBat...
__ClassProviderRegistration {} {CacheRefreshInter
val, InteractionType, PerUserSchema, prov...
__InstanceProviderRegistration {} {InteractionType,
provider, QuerySupportLevels, SupportsBat...
__MethodProviderRegistration {} {provider}
__PropertyProviderRegistration {} {provider, Support
sGet, SupportsPut}
__EventConsumerProviderRegistration {} {ConsumerClassName
s, provider}
__thisNAMESPACE {} {SECURITY_DESCRIPT
OR}
__NAMESPACE {} {Name}
__IndicationRelated {} {}
__FilterToConsumerBinding {} {Consumer, Creator
SID, DeliverSynchronously, DeliveryQoS...}
__EventConsumer {} {CreatorSID, Machi
neName, MaximumQueueSize}
LogFileEventConsumer {} {CreatorSID, Filen
ame, IsUnicode, MachineName...}
ActiveScriptEventConsumer {} {CreatorSID, KillT
imeout, MachineName, MaximumQueueSize...}
NTEventLogEventConsumer {} {Category, Creator
SID, EventID, EventType...}
SMTPEventConsumer {} {BccLine, CcLine,
CreatorSID, FromLine...}
CommandLineEventConsumer {} {CommandLineTempla
te, CreateNewConsole, CreateNewProcessGro...
__AggregateEvent {} {NumberOfEvents, R
epresentative}
__TimerNextFiring {} {NextEvent64BitTim
e, TimerId}
__EventFilter {} {CreatorSID, Event
Access, EventNamespace, Name...}
__Event {} {SECURITY_DESCRIPT
OR, TIME_CREATED}
__NamespaceOperationEvent {} {SECURITY_DESCRIPT
OR, TargetNamespace, TIME_CREATED}
__NamespaceModificationEvent {} {PreviousNamespace
, SECURITY_DESCRIPTOR, TargetNamespace, T...
__NamespaceDeletionEvent {} {SECURITY_DESCRIPT
OR, TargetNamespace, TIME_CREATED}
__NamespaceCreationEvent {} {SECURITY_DESCRIPT
OR, TargetNamespace, TIME_CREATED}
__ClassOperationEvent {} {SECURITY_DESCRIPT
OR, TargetClass, TIME_CREATED}
__ClassDeletionEvent {} {SECURITY_DESCRIPT
OR, TargetClass, TIME_CREATED}
__ClassModificationEvent {} {PreviousClass, SE
CURITY_DESCRIPTOR, TargetClass, TIME_CREA...
__ClassCreationEvent {} {SECURITY_DESCRIPT
OR, TargetClass, TIME_CREATED}
__InstanceOperationEvent {} {SECURITY_DESCRIPT
OR, TargetInstance, TIME_CREATED}
__InstanceCreationEvent {} {SECURITY_DESCRIPT
OR, TargetInstance, TIME_CREATED}

...

Description
-----------
This command displays the WMI classes in the root or default namespace of t
he local computer.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-wmiobject -query "select * from win32_service where name='WinRM'"
-computername server01, server02

ExitCode : 0
Name : WinRM
ProcessId : 1708
StartMode : Auto
State : Running
Status : OK

ExitCode : 0
Name : WinRM
ProcessId : 948
StartMode : Auto
State : Running
Status : OK

Description
-----------
This command displays information about the WinRM service on the computers
that are specified in the ComputerName parameter.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>(get-wmiobject win32_service -filter "name='WinRM'" -computername ser
ver01).StopService()

__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0

Another query using get-wmiobject -query "select * from win32_service where
name='WinRM'" -computername server01, shows the service as stopped.

ExitCode : 0
Name : WinRM
ProcessId : 0
StartMode : Auto
State : Stopped
Status : OK

Description
-----------
This command stops the WinRM service on the Server01 remote computer. The c
ommand uses the standard Get-WmiObject command and adds a call to the StopS
ervice method of the Win32_Service WMI class.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-wmiobject win32_bios | format-list *

Status : OK
Name : Phoenix ROM BIOS PLUS Version 1.10 2.3.1
Caption : Phoenix ROM BIOS PLUS Version 1.10 2.3.1
SMBIOSPresent : True
__GENUS : 2
__CLASS : Win32_BIOS
__SUPERCLASS : CIM_BIOSElement
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_BIOS.Name="Phoenix ROM BIOS PLUS Version 1.10
2.3.1 ",SoftwareElementID="Phoenix ROM BIOS
PLUS Version 1.10 2.3.1 ",SoftwareElementState=3,T
argetOperatingSystem=0,Version="DELL - 14"
__PROPERTY_COUNT : 27
__DERIVATION : {CIM_BIOSElement, CIM_SoftwareElement, CIM_LogicalE
lement, CIM_ManagedSystemElement}
__SERVER : SERVER01
__NAMESPACE : root\cimv2
__PATH : \\SERVER01\root\cimv2:Win32_BIOS.Name="Phoenix ROM
BIOS PLUS Version 1.10 2.3.1 ",Software
ElementID="Phoenix ROM BIOS PLUS Version 1.10 2.3.1
",SoftwareElementState=3,TargetOperatingSys
tem=0,Version="DELL - 14"
BiosCharacteristics : {7, 9, 10, 11...}
BIOSVersion : {DELL - 14, Phoenix ROM BIOS PLUS Version 1.10 2.
3.1 , Phoenix ROM BIOS PLUS Version 1.10 2.3
.1 , Phoenix ROM BIOS PLUS Version 1.10 2.3.1 }
BuildNumber :
CodeSet :
CurrentLanguage : en|US|iso8859-1
Description : Phoenix ROM BIOS PLUS Version 1.10 2.3.1
IdentificationCode :
InstallableLanguages : 1
InstallDate :
LanguageEdition :
ListOfLanguages : {en|US|iso8859-1}
Manufacturer : Dell Inc.
OtherTargetOS :
PrimaryBIOS : True
ReleaseDate : 20070521000000.000000+000
SerialNumber : 8PWRVD1
SMBIOSBIOSVersion : 2.3.1
SMBIOSMajorVersion : 2
SMBIOSMinorVersion : 3
SoftwareElementID : Phoenix ROM BIOS PLUS Version 1.10 2.3.1
SoftwareElementState : 3
TargetOperatingSystem : 0
Version : DELL - 14
Scope : System.Management.ManagementScope
Path : \\SERVER01\root\cimv2:Win32_BIOS.Name="Phoenix ROM
BIOS PLUS Version 1.10 2.3.1 ",Software
ElementID="Phoenix ROM BIOS PLUS Version 1.10 2.3.1
",SoftwareElementState=3,TargetOperatingSys
tem=0,Version="DELL - 14"
Options : System.Management.ObjectGetOptions
ClassPath : \\SERVER01\root\cimv2:Win32_BIOS
Properties : {BiosCharacteristics, BIOSVersion, BuildNumber, Cap
tion...}
SystemProperties : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY...}
Qualifiers : {dynamic, Locale, provider, UUID}
Site :
Container :

Description
-----------
This command displays BIOS information. It displays all the properties of t
he WMI class, not just the properties that are specified in the Types.ps1xm
l configuration file.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-wmiobject win32_service -credential FABRIKAM\administrator -compu
ter fabrikam

ExitCode : 0
Name : AeLookupSvc
ProcessId : 0
StartMode : Manual
State : Stopped
Status : OK

ExitCode : 1077
Name : ALG
ProcessId : 0
StartMode : Manual
State : Stopped
Status : OK

ExitCode : 1077
Name : AppIDSvc
ProcessId : 0
StartMode : Manual
State : Stopped
Status : OK

ExitCode : 0
Name : Appinfo
ProcessId : 888
StartMode : Manual
State : Running
Status : OK

ExitCode : 1077
Name : AppMgmt
ProcessId : 0
StartMode : Manual
State : Stopped
Status : OK

...

Description
-----------
This command displays service information on a computer named Fabrikam. It
specifies a user account name by using the Credential parameter, which caus
es a dialog box to be displayed in which you enter the corresponding passwo
rd.




REMARKS
To see the examples, type: "get-help Get-WmiObject -examples".
For more information, type: "get-help Get-WmiObject -detailed".
For technical information, type: "get-help Get-WmiObject -full".

NAME
Get-History

SYNOPSIS
Gets a list of the commands entered during the current session.


SYNTAX
Get-History [[-Id] <Int64[]>] [[-Count] <int>] [<CommonParameters>]


DESCRIPTION
The Get-History cmdlet gets the session history, that is, the list of comma
nds entered during the current session. Windows PowerShell automatically ma
intains a history of each session. You can save the session history in XML
or CSV format. By default, history files are saved in the home directory, b
ut you can save the file in any location.

PARAMETERS
-Count <int>
Displays the specified number of the most recent history entries. The d
efault is 32. If you use both the Count and Id parameters in a command,
the display ends with the command specified by the Id parameter.

-Id <Int64[]>
Specifies the ID number of a command in the session history. Get-Histor
y gets only the specified command. If you use Id and Count, Get-History
gets the most recent commands ending with the command specified by the
Id parameter.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-history

Description
-----------
This command gets the 32 most recently submitted commands. The default disp
lay shows each command and its ID, which indicates the order of execution.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-history | where-object {$_.commandLine -like "*service*"}

Description
-----------
This command gets entries from the command history that include the word, "
service". The first command gets the 32 most recent entries in the session
history. The pipeline operator (|) passes the results to the Where-Object c
mdlet, which selects only the commands that include "service".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-history -id 7 -count 5 | export-csv history.csv

Description
-----------
This command gets the five most recent history entries ending with entry 7.
The pipeline operator (|) passes the result to the Export-Csv cmdlet, whic
h formats the history as comma-separated text and saves it in the History.c
sv file. The file includes the data that is displayed when you format the h
istory as a list, including the status and start and end times of the comma
nd.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-history -count 1

Description
-----------
This command gets the last (most recently entered) command in the command h
istory. It uses the Count parameter to display just one command. By default
, Get-History displays the most recent commands. This command can be abbrev
iated to "h -c 1" and is equivalent to pressing the up-arrow key.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-history -count $MaximumHistoryCount

Description
-----------
This command displays all of the commands saved in the session history. By
default, $MaximumHistoryCount is 64, so this command can be abbreviated as
"h -c 64".




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-history | format-list

Description
-----------
This command displays all of the properties of entries in the session histo
ry. The pipeline operator (|) passes the result to the Format-List cmdlet,
which displays all of the properties of each history entry, including the I
D, status, and start and end times of the command.




REMARKS
To see the examples, type: "get-help Get-History -examples".
For more information, type: "get-help Get-History -detailed".
For technical information, type: "get-help Get-History -full".

H:

NAME
Get-Help

SYNOPSIS
Displays information about Windows PowerShell commands and concepts.


SYNTAX
Get-Help [-Full] [[-Name] <string>] [-Category <string[]>] [-Component <str
ing[]>] [-Functionality <string[]>] [-Online] [-Path <string>] [-Role <stri
ng[]>] [<CommonParameters>]

Get-Help [-Detailed] [[-Name] <string>] [-Category <string[]>] [-Component
<string[]>] [-Functionality <string[]>] [-Online] [-Path <string>] [-Role <
string[]>] [<CommonParameters>]

Get-Help [-Examples] [[-Name] <string>] [-Category <string[]>] [-Component
<string[]>] [-Functionality <string[]>] [-Online] [-Path <string>] [-Role <
string[]>] [<CommonParameters>]

Get-Help [-Parameter <string>] [[-Name] <string>] [-Category <string[]>] [-
Component <string[]>] [-Functionality <string[]>] [-Online] [-Path <string>
] [-Role <string[]>] [<CommonParameters>]


DESCRIPTION
The Get-Help cmdlet displays information about Windows PowerShell concepts
and commands, including cmdlets, providers, functions and scripts. To get a
list of all cmdlet help topic titles, type "get-help *".

If you type "Get-Help" followed by the exact name of a help topic, or by a
word unique to a help topic, Get-Help displays the topic contents. If you e
nter a word or word pattern that appears in several help topic titles, Get-
Help displays a list of the matching titles. If you enter a word that does
not appear in any help topic titles, Get-Help displays a list of topics tha
t include that word in their contents.

In addition to "get-help", you can also type "help" or "man", which display
s one screen of text at a time, or "<cmdlet-name> -?", which is identical t
o Get-Help but works only for cmdlets.

You can display the entire help file or selected parts of the file, such as
the syntax, parameters, or examples. You can also use the Online parameter
to display an online version of a help file in your Internet browser. Thes
e parameters have no effect on conceptual help topics.

Conceptual help topics in Windows PowerShell begin with "about_", such as "
about_Comparison_Operators". To see all "about_" topics, type "get-help abo
ut_*". To see a particular topic, type "get-help about_<topic-name>", such
as "get-help about_Comparison_Operators".

PARAMETERS
-Category <string[]>
Displays help for items in the specified category. Valid values are Ali
as, Cmdlet, Provider, and HelpFile. Conceptual topics are in the HelpFi
le category.

Category is a property of the MamlCommandHelpInfo object that Get-Help
returns. This parameter has no effect on displays of conceptual ("about
_") help.

-Component <string[]>
Displays a list of tools with the specified component value, such as "E
xchange." Enter a component name. Wildcards are permitted.

Component is a property of the MamlCommandHelpInfo object that Get-Help
returns. This parameter has no effect on displays of conceptual ("Abou
t_") help.

-Detailed [<SwitchParameter>]
Adds parameter descriptions and examples to the basic help display.

This parameter has no effect on displays of conceptual ("About_") help.

-Examples [<SwitchParameter>]
Displays only the name, synopsis, and examples. To display only the exa
mples, type "(get-help <cmdlet-name>).examples".

This parameter has no effect on displays of conceptual ("About_") help.

-Full [<SwitchParameter>]
Displays the entire help file for a cmdlet, including parameter descrip
tions and attributes, examples, input and output object types, and addi
tional notes.

This parameter has no effect on displays of conceptual ("About_") help.

-Functionality <string[]>
Displays help for items with the specified functionality. Enter the fun
ctionality. Wildcards are permitted.

Functionality is a property of the MamlCommandHelpInfo object that Get-
Help returns. This parameter has no effect on displays of conceptual ("
About_") help.

-Name <string>
Requests help about the specified tool or conceptual topic. Enter a cmd
let, provider, script, or function name, such as Get-Member, a conceptu
al topic name, such as "about_Objects", or an alias, such as "ls". Wild
cards are permitted in cmdlet and provider names, but you cannot use wi
ldcards to find the names of function help and script help topics.

To get help for a script that is not located in a path that is listed i
n the Path environment variable, type the path and file name of the scr
ipt .

If you enter the exact name of a help topic, Get-Help displays the topi
c contents. If you enter a word or word pattern that appears in several
help topic titles, Get-Help displays a list of the matching titles. If
you enter a word that does not match any help topic titles, Get-Help d
isplays a list of topics that include that word in their contents.

The names of conceptual topics, such as about_Objects, must be entered
in English, even in non-English versions of Windows PowerShell.

-Online [<SwitchParameter>]
Displays the online version of a help topic in the default Internet bro
wser. This parameter is valid only for cmdlet, function, and script hel
p topics.

Get-Help uses the Internet address (Uniform Resource Identifier [URI])
that appears in the first item of the Related Links section of a cmdlet
, function, or script help topic. This parameter works only when the he
lp topic includes a URI that begins with "Http" or "Https" and an Inter
net browser is installed on the system.

For information about supporting this feature in help topics that you w
rite, see about_Comment_Based_Help, and see "How to Write Cmdlet Help"
in the MSDN (Microsoft Developer Network) library at http://go.microsof
t.com/fwlink/?LinkID=123415.

-Parameter <string>
Displays only the detailed descriptions of the specified parameters. Wi
ldcards are permitted.

This parameter has no effect on displays of conceptual ("About_") help.

-Path <string>
Gets help that explains how the cmdlet works in the specified provider
path. Enter a Windows PowerShell provider path.

This parameter gets a customized version of a cmdlet help topic that ex
plains how the cmdlet works in the specified Windows PowerShell provide
r path. This parameter is effective only for help about a provider cmdl
et and only when the provider includes a custom version of the provider
cmdlet help topic.

To see the custom cmdlet help for a provider path, go to the provider p
ath location and enter a Get-Help command or, from any path location, u
se the Path parameter of Get-Help to specify the provider path. For mor
e information, see about_Providers.

-Role <string[]>
Displays help customized for the specified user role. Enter a role. Wil
dcards are permitted.

Enter the role that the user plays in an organization. Some cmdlets dis
play different text in their help files based on the value of this para
meter. This parameter has no effect on help for the core cmdlets.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-help

Description
-----------
This command displays help about the Windows PowerShell help system.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-help *

Description
-----------
This command displays a list of all help files in the Windows PowerShell he
lp system.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-help get-alias

C:\PS>help get-alias

C:\PS>get-alias -?

Description
-----------
These commands display basic information about the get-alias cmdlet. The "G
et-Help" and "-?" commands display the information on a single page. The "H
elp" command displays the information one page at a time.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-help about_*

Description
-----------
This command displays a list of the conceptual topics included in Windows P
owerShell help. All of these topics begin with the characters "about_". To
display a particular help file, type "get-help <topic-name>, for example, "
get-help about_signing".




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-help ls -detailed

Description
-----------
This command displays detailed help for the Get-ChildItem cmdlet by specify
ing one of its aliases, "ls." The Detailed parameter requests the detailed
view of the help file, which includes parameter descriptions and examples.
To see the complete help file for a cmdlet, use the Full parameter.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-help format-string -full

Description
-----------
This command displays the full view help for the Format-String cmdlet. The
full view of help includes parameter descriptions, examples, and a table of
technical details about the parameters.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-help start-service -examples

Description
-----------
This command displays examples of using start-service in Windows PowerShell
commands.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>get-help get-childitem -parameter f*

Description
-----------
This command displays descriptions of the parameters of the Get-ChildItem c
mdlet that begin with "f" (filter and force). For descriptions of all param
eters, type "get-help get-childitem parameter*".




-------------------------- EXAMPLE 9 --------------------------

C:\PS>(get-help write-output).syntax

Description
-----------
This command displays only the syntax of the Write-Output cmdlet.

Syntax is one of many properties of help objects; others are description, d
etails, examples, and parameters. To find all properties and methods of hel
p objects, type "get-help <cmdlet-name> | get-member"; for example, "get-he
lp start-service | get member".




-------------------------- EXAMPLE 10 --------------------------

C:\PS>(get-help trace-command).alertset

Description
-----------
This command displays the notes about the cmdlet. The notes are stored in t
he alertSet property of the help object.

The notes include conceptual information and tips for using the cmdlet. By
default, the notes are displayed only when you use the Full parameter of Ge
t-Help, but you can also display them by using the alertSet property.




-------------------------- EXAMPLE 11 --------------------------

C:\PS>get-help add-member -full | out-string -stream | select-string -patte
rn clixml

Description
-----------
This example shows how to search for a word in particular cmdlet help topic
. This command searches for the word "clixml" in the full version of the he
lp topic for the Add-Member cmdlet.

Because the Get-Help cmdlet generates a MamlCommandHelpInfo object, not a s
tring, you need to use a command that transforms the help topic content int
o a string, such as Out-String or Out-File.




-------------------------- EXAMPLE 12 --------------------------

C:\PS>get-help get-member -online

Description
-----------
This command displays the online version of the help topic for the Get-Memb
er cmdlet.




-------------------------- EXAMPLE 13 --------------------------

C:\PS>get-help remoting

Description
-----------
This command displays a list of topics that include the word "remoting" in
their contents.

When you enter a word that does not appear in any topic title, Get-Help dis
plays a list of topics that include that word.




-------------------------- EXAMPLE 14 --------------------------

C:\PS>get-help get-item -path SQLSERVER:\DataCollection

NAME
Get-Item

SYNOPSIS
Gets a collection of Server objects for the local computer and any comp
uters to which you have made a SQL Server PowerShell connection.
...

C:\PS> cd SQLSERVER:\DataCollection
C:\PS> SQLSERVER:\DataCollection> get-help get-item


NAME
Get-Item

SYNOPSIS
Gets a collection of Server objects for the local computer and any comp
uters to which you have made a SQL Server PowerShell connection.
...


C:\PS> Get-Item

NAME
Get-Item

SYNOPSIS
Gets the item at the specified location.

...

Description
-----------
This example shows how to get help for the Get-Item cmdlet that explains ho
w to use the cmdlet in the DataCollection node of the Windows PowerShell SQ
L Server provider.

The example shows two ways of getting the custom help for Get-Item.

The first command uses the Path parameter of Get-Help to specify the provid
er path. This command can be entered at any path location.

The second command uses the Set-Location cmdlet (alias = "cd") to go to the
provider path. From that location, even without the Path parameter, the Ge
t-Help command gets the custom help for the provider path.

The third command shows that a Get-Help command in a file system path, and
without the Path parameter, gets the standard help for the Get-Item cmdlet.




-------------------------- EXAMPLE 15 --------------------------

C:\PS>get-help c:\ps-test\MyScript.ps1

Description
-----------
This command gets help for the MyScript.ps1 script. For information about w
riting help for your functions and scripts, see about_Comment_Based_Help.




REMARKS
To see the examples, type: "get-help Get-Help -examples".
For more information, type: "get-help Get-Help -detailed".
For technical information, type: "get-help Get-Help -full".

NAME
Get-History

SYNOPSIS
Gets a list of the commands entered during the current session.


SYNTAX
Get-History [[-Id] <Int64[]>] [[-Count] <int>] [<CommonParameters>]


DESCRIPTION
The Get-History cmdlet gets the session history, that is, the list of comma
nds entered during the current session. Windows PowerShell automatically ma
intains a history of each session. You can save the session history in XML
or CSV format. By default, history files are saved in the home directory, b
ut you can save the file in any location.

PARAMETERS
-Count <int>
Displays the specified number of the most recent history entries. The d
efault is 32. If you use both the Count and Id parameters in a command,
the display ends with the command specified by the Id parameter.

-Id <Int64[]>
Specifies the ID number of a command in the session history. Get-Histor
y gets only the specified command. If you use Id and Count, Get-History
gets the most recent commands ending with the command specified by the
Id parameter.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-history

Description
-----------
This command gets the 32 most recently submitted commands. The default disp
lay shows each command and its ID, which indicates the order of execution.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-history | where-object {$_.commandLine -like "*service*"}

Description
-----------
This command gets entries from the command history that include the word, "
service". The first command gets the 32 most recent entries in the session
history. The pipeline operator (|) passes the results to the Where-Object c
mdlet, which selects only the commands that include "service".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-history -id 7 -count 5 | export-csv history.csv

Description
-----------
This command gets the five most recent history entries ending with entry 7.
The pipeline operator (|) passes the result to the Export-Csv cmdlet, whic
h formats the history as comma-separated text and saves it in the History.c
sv file. The file includes the data that is displayed when you format the h
istory as a list, including the status and start and end times of the comma
nd.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-history -count 1

Description
-----------
This command gets the last (most recently entered) command in the command h
istory. It uses the Count parameter to display just one command. By default
, Get-History displays the most recent commands. This command can be abbrev
iated to "h -c 1" and is equivalent to pressing the up-arrow key.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-history -count $MaximumHistoryCount

Description
-----------
This command displays all of the commands saved in the session history. By
default, $MaximumHistoryCount is 64, so this command can be abbreviated as
"h -c 64".




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-history | format-list

Description
-----------
This command displays all of the properties of entries in the session histo
ry. The pipeline operator (|) passes the result to the Format-List cmdlet,
which displays all of the properties of each history entry, including the I
D, status, and start and end times of the command.




REMARKS
To see the examples, type: "get-help Get-History -examples".
For more information, type: "get-help Get-History -detailed".
For technical information, type: "get-help Get-History -full".

I:

NAME
Invoke-Command

SYNOPSIS
Runs commands on local and remote computers.


SYNTAX
Invoke-Command [-ScriptBlock] <scriptblock> [[-ComputerName] <string[]>] [-
ApplicationName <string>] [-AsJob] [-Authentication {Default | Basic | Nego
tiate | NegotiateWithImplicitCredential | Credssp | Digest | Kerberos}] [-C
ertificateThumbprint <string>] [-ConfigurationName <string>] [-Credential <
PSCredential>] [-HideComputerName] [-JobName <string>] [-Port <int>] [-Sess
ionOption <PSSessionOption>] [-ThrottleLimit <int>] [-UseSSL] [-ArgumentLis
t <Object[]>] [-InputObject <psobject>] [<CommonParameters>]

Invoke-Command [-FilePath] <string> [[-ComputerName] <string[]>] [-Applicat
ionName <string>] [-AsJob] [-Authentication {Default | Basic | Negotiate |
NegotiateWithImplicitCredential | Credssp | Digest | Kerberos}] [-Configura
tionName <string>] [-Credential <PSCredential>] [-HideComputerName] [-JobNa
me <string>] [-Port <int>] [-SessionOption <PSSessionOption>] [-ThrottleLim
it <int>] [-UseSSL] [-ArgumentList <Object[]>] [-InputObject <psobject>] [<
CommonParameters>]

Invoke-Command [-FilePath] <string> [[-Session] <PSSession[]>] [-AsJob] [-H
ideComputerName] [-JobName <string>] [-ThrottleLimit <int>] [-ArgumentList
<Object[]>] [-InputObject <psobject>] [<CommonParameters>]

Invoke-Command [-FilePath] <string> [[-ConnectionURI] <Uri[]>] [-AllowRedir
ection] [-AsJob] [-Authentication {Default | Basic | Negotiate | NegotiateW
ithImplicitCredential | Credssp | Digest | Kerberos}] [-ConfigurationName <
string>] [-Credential <PSCredential>] [-HideComputerName] [-JobName <string
>] [-SessionOption <PSSessionOption>] [-ThrottleLimit <int>] [-ArgumentList
<Object[]>] [-InputObject <psobject>] [<CommonParameters>]

Invoke-Command [-ScriptBlock] <scriptblock> [-ArgumentList <Object[]>] [-In
putObject <psobject>] [<CommonParameters>]

Invoke-Command [-ScriptBlock] <scriptblock> [[-Session] <PSSession[]>] [-As
Job] [-HideComputerName] [-JobName <string>] [-ThrottleLimit <int>] [-Argum
entList <Object[]>] [-InputObject <psobject>] [<CommonParameters>]

Invoke-Command [-ScriptBlock] <scriptblock> [[-ConnectionURI] <Uri[]>] [-Al
lowRedirection] [-AsJob] [-Authentication {Default | Basic | Negotiate | Ne
gotiateWithImplicitCredential | Credssp | Digest | Kerberos}] [-Certificate
Thumbprint <string>] [-ConfigurationName <string>] [-Credential <PSCredenti
al>] [-HideComputerName] [-JobName <string>] [-SessionOption <PSSessionOpti
on>] [-ThrottleLimit <int>] [-ArgumentList <Object[]>] [-InputObject <psobj
ect>] [<CommonParameters>]


DESCRIPTION
The Invoke-Command cmdlet runs commands on a local or remote computer and r
eturns all output from the commands, including errors. With a single Invoke
-Command command, you can run commands on multiple computers.

To run a single command on a remote computer, use the ComputerName paramete
r. To run a series of related commands that share data, create a PSSession
(a persistent connection) on the remote computer, and then use the Session
parameter of Invoke-Command to run the command in the PSSession.

You can also use Invoke-Command on a local computer to evaluate or run a st
ring in a script block as a command. Windows PowerShell converts the script
block to a command and runs the command immediately in the current scope,
instead of just echoing the string at the command line.

Before using Invoke-Command to run commands on a remote computer, read abou
t_Remote.

PARAMETERS
-AllowRedirection [<SwitchParameter>]
Allows redirection of this connection to an alternate URI.

When you use the ConnectionURI parameter, the remote destination can re
turn an instruction to redirect to a different URI. By default, Windows
PowerShell does not redirect connections, but you can use the AllowRed
irection parameter to allow it to redirect the connection.

You can also limit the number of times that the connection is redirecte
d by setting the MaximumConnectionRedirectionCount property of the $PSS
essionOption preference variable, or the MaximumConnectionRedirectionCo
unt property of the value of the SessionOption parameter. The default v
alue is 5. For more information, see the description of the SessionOpti
on parameter and the help topic for the New-PSSessionOption cmdlet.

-ApplicationName <string>
Specifies the application name segment of the connection URI. Use this
parameter to specify the application name when you are not using the Co
nnectionURI parameter in the command.

The default value is the value of the $PSSessionApplicationName prefere
nce variable on the local computer. If this preference variable is not
defined, the default value is WSMAN. This value is appropriate for most
uses. For more information, see about_Preference_Variables.

The WinRM service uses the application name to select a listener to ser
vice the connection request. The value of this parameter should match t
he value of the URLPrefix property of a listener on the remote computer
.

-ArgumentList <Object[]>
Supplies the values of local variables in the command. The variables in
the command are replaced by these values before the command is run on
the remote computer. Enter the values in a comma-separated list. Values
are associated with variables in the order that they are listed. The a
lias for ArgumentList is "Args".

The values in ArgumentList can be actual values, such as "1024", or the
y can be references to local variables, such as "$max".

To use local variables in a command, use the following command format:
{param($<name1>[, $<name2>]...) <command-with-local-variables>} -Argume
ntList <value | $local-variable>

The "param" keyword lists the local variables that are used in the comm
and. The ArgumentList parameter supplies the values of the variables, i
n the order that they are listed.

-AsJob [<SwitchParameter>]
Runs the command as a background job on a remote computer. Use this par
ameter to run commands that take an extensive time to complete.

When you use AsJob, the command returns an object that represents the j
ob, and then displays the command prompt. You can continue to work in t
he session while the job completes. To manage the job, use the Job cmd
lets. To get the job results, use Receive-Job.

The AsJob parameter is similar to using Invoke-Command to run a Start-J
ob command remotely. However, with AsJob, the job is created on the loc
al computer, even though the job runs on a remote computer, and the res
ults of the remote job are automatically returned to the local computer
.

For more information about Windows PowerShell background jobs, see abou
t_Jobs and about_Remote_Jobs.

-Authentication <AuthenticationMechanism>
Specifies the mechanism that is used to authenticate the user's credent
ials. Valid values are Default, Basic, Credssp, Digest, Kerberos, Neg
otiate, and NegotiateWithImplicitCredential. The default value is Defa
ult.

CredSSP authentication is available only in Windows Vista, Windows Serv
er 2008, and later versions of Windows.

For information about the values of this parameter, see the description
of the System.Management.Automation.Runspaces.AuthenticationMechanism
enumeration in MSDN.

CAUTION: Credential Security Service Provider (CredSSP) authentication,
in which the user's credentials are passed to a remote computer to be
authenticated, is designed for commands that require authentication on
more than one resource, such as accessing a remote network share. This
mechanism increases the security risk of the remote operation. If the r
emote computer is compromised, the credentials that are passed to it ca
n be used to control the network session.

-CertificateThumbprint <string>
Specifies the digital public key certificate (X509) of a user account t
hat has permission to perform this action. Enter the certificate thumbp
rint of the certificate.

Certificates are used in client certificate-based authentication. They
can only be mapped to local user accounts; they do not work with domain
accounts.

To get a certificate thumbprint, use the Get-Item or Get-ChildItem comm
ands in the Windows PowerShell Cert: drive.

-ComputerName <string[]>
Specifies the computers on which the command runs. The default is the l
ocal computer.

When you use the ComputerName parameter, Windows PowerShell creates a t
emporary connection that is used only to run the specified command and
is then closed. If you need a persistent connection, use the Session pa
rameter.

Type the NETBIOS name, IP address, or fully-qualified domain name of on
e or more computers in a comma-separated list. To specify the local com
puter, type the computer name, "localhost", or a dot (.).

To use an IP address in the value of the ComputerName parameter, the co
mmand must include the Credential parameter. Also, the computer must be
configured for HTTPS transport or the IP address of the remote compute
r must be included in the WinRM TrustedHosts list on the local computer
. For instructions for adding a computer name to the TrustedHosts list,
see "How to Add a Computer to the Trusted Host List" in about_Remote_
Troubleshooting.

Note: On Windows Vista, and later versions of Windows, to include the
local computer in the value of the ComputerName parameter, you must ope
n Windows PowerShell with the "Run as administrator" option.

-ConfigurationName <string>
Specifies the session configuration that is used for the new PSSession.


Enter a configuration name or the fully qualified resource URI for a se
ssion configuration. If you specify only the configuration name, the fo
llowing schema URI is prepended: http://schemas.microsoft.com/powershe
ll.

The session configuration for a session is located on the remote comput
er. If the specified session configuration does not exist on the remote
computer, the command fails.

The default value is the value of the $PSSessionConfigurationName prefe
rence variable on the local computer. If this preference variable is no
t set, the default is Microsoft.PowerShell. For more information, see a
bout_preference_variables.

-ConnectionURI <Uri[]>
Specifies a Uniform Resource Identifier (URI) that defines the connecti
on endpoint. The URI must be fully qualified.

The format of this string is:
<Transport>://<ComputerName>:<Port>/<ApplicationName>

The default value is:
http://localhost:80/WSMAN

Valid values for the Transport segment of the URI are HTTP and HTTPS. I
f you do not specify a ConnectionURI, you can use the UseSSL, ComputerN
ame, Port, and ApplicationName parameters to specify the URI values.

If the destination computer redirects the connection to a different URI
, Windows PowerShell prevents the redirection unless you use the AllowR
edirection parameter in the command.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a var
iable that contains a PSCredential object, such as one generated by the
Get-Credential cmdlet. When you type a user name, you will be prompted
for a password.

-FilePath <string>
Runs the specified local script on one or more remote computers. Enter
the path and file name of the script, or pipe a script path to Invoke-C
ommand. The script must reside on the local computer or in a directory
that the local computer can access. Use the ArgumentList parameter to s
pecify the values of parameters in the script.

When you use this parameter, Windows PowerShell converts the contents o
f the specified script file to a script block, transmits the script blo
ck to the remote computer, and runs it on the remote computer.

-HideComputerName [<SwitchParameter>]
Omits the computer name of each object from the output display. By defa
ult, the name of the computer that generated the object appears in the
display.

This parameter affects only the output display. It does not change the
object.

-InputObject <psobject>
Specifies input to the command. Enter a variable that contains the obje
cts or type a command or expression that gets the objects.

When using InputObject, use the $input automatic variable in the value
of the ScriptBlock parameter to represent the input objects.

-JobName <string>
Specifies a friendly name for the background job. By default, jobs are
named "Job<n>", where <n> is an ordinal number. This parameter is vali
d only with the AsJob parameter.

If you use the JobName parameter in a command, the command is run as a
job, and Invoke-Command returns a job object, even if you do not includ
e the AsJob parameter in the command.

For more information about Windows PowerShell background jobs, see abou
t_Jobs.

-Port <int>
Specifies the network port on the remote computer used for this comman
d. The default is port 80 (the HTTP port).

Before using an alternate port, you must configure the WinRM listener o
n the remote computer to listen at that port. To configure the listener
, type the following two commands at the Windows PowerShell prompt:

remove-item -path wsman:\Localhost\listener\listener* -recurse
new-item -path wsman:\Localhost\listener -Transport http -Address * -po
rt <port-number>

Do not use the Port parameter unless you must. The Port set in the comm
and applies to all computers or sessions on which the command runs. An
alternate port setting might prevent the command from running on all co
mputers.

-ScriptBlock <scriptblock>
Specifies the commands to run. Enclose the commands in curly braces ( {
} ) to create a script block. This parameter is required.

By default, any variables in the command are evaluated on the remote co
mputer. To include local variables in the command, use the ArgumentList
parameter.

-Session <PSSession[]>
Runs the command in the specified Windows PowerShell sessions (PSSessio
ns). Enter a variable that contains the PSSessions or a command that cr
eates or gets the PSSessions, such as a New-PSSession or Get-PSSession
command.

When you create a PSSession, Windows PowerShell establishes a persisten
t connection to the remote computer. Use a PSSession to run a series of
related commands that share data. To run a single command or a series
of unrelated commands, use the ComputerName parameter.

To create a PSSession, use the New-PSSession cmdlet. For more informati
on, see about_PSSessions.

-SessionOption <PSSessionOption>
Sets advanced options for the session. Enter a SessionOption object tha
t you create by using the New-PSSessionOption cmdlet.

The default values for the options are determined by the value of the $
PSSessionOption preference variable, if it is set. Otherwise, the sessi
on uses the system defaults.

For a description of the session options, including the default values,
see the help topic for the New-PSSessionOption cmdlet. For information
about the $PSSessionOption preference variable, see about_Preference_V
ariables.

-ThrottleLimit <int>
Specifies the maximum number of concurrent connections that can be esta
blished to run this command. If you omit this parameter or enter a valu
e of 0, the default value, 32, is used.

The throttle limit applies only to the current command, not to the sess
ion or to the computer.

-UseSSL [<SwitchParameter>]
Uses the Secure Sockets Layer (SSL) protocol to establish a connection
to the remote computer. By default, SSL is not used.

WS-Management encrypts all Windows PowerShell content transmitted over
the network. UseSSL is an additional protection that sends the data acr
oss an HTTPS, instead of HTTP.

If you use this parameter, but SSL is not available on the port used fo
r the command, the command fails.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>invoke-command -filepath c:\scripts\test.ps1 -computerName Server01

Disks: C:, D:, E:
Status: Warning, Normal, Normal

Description
-----------
This command runs the Test.ps1 script on the Server01 computer.

The command uses the FilePath parameter to specify a script that is located
on the local computer. The script runs on the remote computer and the resu
lts are returned to the local computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>invoke-command -computername server01 -credential domain01\user01 -sc
riptblock {get-culture}

Description
-----------
This command runs a Get-Culture command on the Server01 remote computer.

It uses the ComputerName parameter to specify the computer name and the Cre
dential parameter to run the command in the security context of "Domain01\U
ser01," a user with permission to run commands. It uses the ScriptBlock par
ameter to specify the command to be run on the remote computer.

In response, Windows PowerShell displays a dialog box that requests the pas
sword and an authentication method for the User01 account. It then runs the
command on the Server01 computer and returns the result.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$s = new-pssession -computername server02 -credential domain01\user01

C:\PS> invoke-command -session $s -scriptblock {get-culture}

Description
-----------
This example runs the same "Get-Culture" command in a session (a persistent
connection) on the Server02 remote computer. Typically, you create a sessi
on only when you are running a series of commands on the remote computer.

The first command uses the New-PSSession cmdlet to create a session on the
Server02 remote computer. Then, it saves the session in the $s variable.

The second command uses the Invoke-Command cmdlet to run the Get-Culture co
mmand on Server02. It uses the Session parameter to specify the session sa
ved in the $s variable.

In response, Windows PowerShell runs the command in the session on the Serv
er02 computer.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>invoke-command -computername Server02 -scriptblock {$p = get-process
powershell}

C:\PS> invoke-command -computername Server02 -scriptblock {$p.virtualmemory
size}
C:\PS>

C:\PS> $s = new-pssession -computername Server02
C:\PS> invoke-command -session $s -scriptblock {$p = get-process powershell
}
C:\PS> invoke-command -session $s -scriptblock {$p.virtualmemorysize}
17930240

Description
-----------
This example compares the effects of using ComputerName and Session paramet
ers of Invoke-Command. It shows how to use a session to run a series of com
mands that share the same data.

The first two commands use the ComputerName parameter of Invoke-Command to
run commands on the Server02 remote computer. The first command uses the Ge
t-Process command to get the PowerShell process on the remote computer and
to save it in the $p variable. The second command gets the value of the Vir
tualMemorySize property of the PowerShell process.

The first command succeeds. But, the second command fails because when you
use the ComputerName parameter, Windows PowerShell creates a connection jus
t to run the command. Then, it closes the connection when the command is co
mplete. The $p variable was created in one connection, but it does not exis
t in the connection created for the second command.

The problem is solved by creating a session (a persistent connection) on th
e remote computer and by running both of the related commands in the same s
ession.

The third command uses the New-PSSession cmdlet to create a session on the
Server02 computer. Then it saves the session in the $s variable. The fourth
and fifth commands repeat the series of commands used in the first set, bu
t in this case, the Invoke-Command command uses the Session parameter to ru
n both of the commands in the same session.

In this case, because both commands run in the same session, the commands s
ucceed, and the $p value remains active in the $s session for later use.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>$command = { get-eventlog -log "windows powershell" | where {$_.messa
ge -like "*certificate*"} }

C:\PS> invoke-command -computername S1, S2 -scriptblock $command

Description
-----------
This example shows how to enter a command that is saved in a local variable
.

When the entire command is saved in a local variable, you can specify the v
ariable as the value of the ScriptBlock parameter. You do not have to use t
he "param" keyword or the ArgumentList variable to submit the value of the
local variable.

The first command saves a Get-Eventlog command in the $command variable. Th
e command is formatted as a script block.

The second command uses the Invoke-Command cmdlet to run the command in $co
mmand on the S1 and S2 remote computers.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>invoke-command -computername server01, server02, TST-0143, localhost
-configurationname MySession.PowerShell -scriptblock {get-eventlog "windows
powershell"}

Description
-----------
This example demonstrates how to use the Invoke-Command cmdlet to run a sin
gle command on multiple computers.

The command uses the ComputerName parameter to specify the computers. The c
omputer names are presented in a comma-separated list. The list of computer
s includes the "localhost" value, which represents the local computer.

The command uses the ConfigurationName parameter to specify an alternate se
ssion configuration for Windows PowerShell and the ScriptBlock parameter to
specify the command.

In this example, the command in the script block gets the events in the Win
dows PowerShell event log on each remote computer.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>$version = invoke-command -computername (get-content machines.txt) -s
criptblock {(get-host).version}

Description
-----------
This command gets the version of the Windows PowerShell host running on 200
remote computers.

Because only one command is run, it is not necessary to create persistent c
onnections (sessions) to each of the computers. Instead, the command uses t
he ComputerName parameter to indicate the computers.

The command uses the Invoke-Command cmdlet to run a Get-Host command. It us
es dot notation to get the Version property of the Windows PowerShell host.

To specify the computers, it uses the Get-Content cmdlet to get the content
s of the Machine.txt file, a file of computer names.

These commands run synchronously (one at a time). When the commands complet
e, the output of the commands from all of the computers is saved in the $ve
rsion variable. The output includes the name of the computer from which the
data originated.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>$s = new-pssession -computername Server01, Server02

C:\PS> invoke-command -session $s -scriptblock {get-eventlog system} -AsJob

Id Name State HasMoreData Location Command
--- ---- ----- ----- ----------- --------
-------
1 Job1 Running True Server01,Server02 get-eventlog syste
m


C:\PS> $j = Get-Job

C:\PS> $j | format-list -property *

HasMoreData : True
StatusMessage :
Location : Server01,Server02
Command : get-eventlog system
JobStateInfo : Running
Finished : System.Threading.ManualResetEvent
InstanceId : e124bb59-8cb2-498b-a0d2-2e07d4e030ca
Id : 1
Name : Job1
ChildJobs : {Job2, Job3}
Output : {}
Error : {}
Progress : {}
Verbose : {}
Debug : {}
Warning : {}
StateChanged :

C:\PS> $results = $j | Receive-Job

Description
-----------
These commands run a background job on two remote computers. Because the In
voke-Command command uses the AsJob parameter, the commands run on the remo
te computers, but the job actually resides on the local computer and the re
sults are transmitted to the local computer.

The first command uses the New-PSSession cmdlet to create sessions on the S
erver01 and Server02 remote computers.

The second command uses the Invoke-Command cmdlet to run a background job i
n each of the sessions. The command uses the AsJob parameter to run the com
mand as a background job. This command returns a job object that contains t
wo child job objects, one for each of the jobs run on the two remote comput
ers.

The third command uses a Get-Job command to save the job object in the $j v
ariable.

The fourth command uses a pipeline operator (|) to send the value of the $j
variable to the Format-List cmdlet, which displays all properties of the j
ob object in a list.

The fifth command gets the results of the jobs. It pipes the job object in
$j to the Receive-Job cmdlet and stores the results in the $results variabl
e.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>$MWFO-LOg = Microsoft-Windows-Forwarding/Operational

C:\PS> invoke-command -computername server01 -scriptblock {param($log, $num
) get-eventlog -logname $log -newest $num} -ArgumentList $MWFO-log, 10

Description
-----------
This example shows how to include the values of local variables in a comman
d run on a remote computer.

The first command saves the name of the Microsoft-Windows-Forwarding/Operat
ional event log in the $MWFO-Log variable.

The second command uses the Invoke-Command cmdlet to run a Get-EventLog com
mand on the Server01 remote computer that gets the 10 newest events from th
e Microsoft-Windows-Forwarding/Operational event log on Server01.

This command uses the "param" keyword to create two variables, $log and $nu
m, that are used as placeholders in the Get-EventLog command. These placeho
lders have arbitrary names that do not need to match the names of the local
variables that supply their values.

The values of the ArgumentList parameter demonstrate the two different ways
to specify values in the argument list. The value of the $log placeholder
is the $MFWO-Log variable, which is defined in the first command. The value
of the $num variable is 10.

Before the command is sent to the remote computer, the variables are replac
ed with the specified values.




-------------------------- EXAMPLE 10 --------------------------

C:\PS>invoke-command -computername S1, S2 -scriptblock {get-process powersh
ell}

PSComputerName Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id
ProcessName
-------------- ------- ------ ----- ----- ----- ------ --
-----------
S1 575 15 45100 40988 200 4.68 13
92 powershell
S2 777 14 35100 30988 150 3.68 67
powershell


C:\PS> invoke-command -computername S1, S2 -scriptblock {get-process powers
hell} -HideComputerName

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
575 15 45100 40988 200 4.68 1392 powershell
777 14 35100 30988 150 3.68 67 powershell

Description
-----------
This example shows the effect of using the HideComputerName parameter of In
voke-Command.

The first two commands use the Invoke-Command cmdlet to run a Get-Process c
ommand for the PowerShell process. The output of the first command includes
the PsComputerName property, which contains the name of the computer on wh
ich the command ran. The output of the second command, which uses the HideC
omputerName parameter, does not include the PsComputerName column.

Using the HideComputerName parameter does not change the object. You can st
ill use the Format cmdlets to display the PsComputerName property of any of
the affected objects.




-------------------------- EXAMPLE 11 --------------------------

C:\PS>invoke-command -comp (get-content servers.txt) -filepath c:\scripts\s
ample.ps1 -argumentlist Process, Service

Description
-----------
This example uses the Invoke-Command cmdlet to run the Sample.ps1 script on
all of the computers listed in the Servers.txt file. The command uses the
FilePath parameter to specify the script file. This command allows you to r
un the script on the remote computers, even if the script file is not acces
sible to the remote computers.

When you submit the command, the content of the Sample.ps1 file is copied i
nto a script block and the script block is run on each of the remote comput
ers. This procedure is equivalent to using the ScriptBlock parameter to sub
mit the contents of the script.




-------------------------- EXAMPLE 12 --------------------------

C:\PS>$LiveCred = Get-Credential

C:\PS> Invoke-Command -ConfigurationName Microsoft.Exchange `
-ConnectionUri https://ps.exchangelabs.com/powershell `
-Credential $LiveCred -Authentication Basic `
-scriptblock {Invoke-Command {Set-Mailbox dan -DisplayName "Dan Pa
rk"}

Description
-----------
This example shows how to run a command on a remote computer that is identi
fied by a URI (Internet address). This particular example runs a Set-Mailbo
x command on a remote Exchange server. The backtick (`) in the command is t
he Windows PowerShell continuation character.

The first command uses the Get-Credential cmdlet to store Windows Live ID c
redentials in the $LiveCred variab the credentials dialog box appears, ente
r Windows Live ID credentials.

The second command uses the Invoke-Command cmdlet to run a Set-Mailbox comm
and. The command uses the ConfigurationName parameter to specify that the c
ommand should run in a session that uses the Microsoft.Exchange session con
figuration. The ConnectionURI parameter specifies the URL of the Exchange s
erver endpoint.

The credential parameter specifies tle. Whenhe Windows Live credentials sto
red in the $LiveCred variable. The AuthenticationMechanism parameter specif
ies the use of basic authentication. The ScriptBlock parameter specifies a
script block that contains the command.




-------------------------- EXAMPLE 13 --------------------------

C:\PS>$max = New-PSSessionOption -MaximumRedirection 1

C:\PS> Invoke-Command -ConnectionUri https://ps.exchangelabs.com/powershell
`
-scriptblock {Invoke-Command {Get-Mailbox dan} `
-AllowRedirection -SessionOption $max

Description
-----------
This command shows how to use the AllowRedirection and SessionOption parame
ters to manage URI redirection in a remote command.

The first command uses the New-PSSessionOption cmdlet to create a PSSession
Opption object that it saves in the $max variable. The command uses the Max
imumRedirection parameter to set the MaximumConnectionRedirectionCount prop
erty of the PSSessionOption object to 1.

The second command uses the Invoke-Command cmdlet to run a Get-Mailbox comm
and on a remote server running Microsoft Exchange Server. The command uses
the AllowRedirection parameter to provide explicit permission to redirect t
he connection to an alternate endpoint. It also uses the SessionOption para
meter to specify the session object in the $max variable.

As a result, if the remote computer specified by the ConnectionURI paramete
r returns a redirection message, Windows PowerShell will redirect the conne
ction, but if the new destination returns another redirection message, the
redirection count value of 1 is exceeded, and Invoke-Command returns a non-
terminating error.




-------------------------- EXAMPLE 14 --------------------------

C:\PS>$so = New-PSSessionOption -SkipCACheck

PS C:\> invoke-command $s { get-hotfix } -SessionOption $so -credential ser
ver01\user01

Description
-----------
This example shows how to create and use a SessionOption parameter.

The first command uses the New-PSSessionOption cmdlet to create a session o
ption. It saves the resulting SessionOption object in the $so parameter.

The second command uses the Invoke-Command cmdlet to run a Get-Hotfix comma
nd remotely. The value of the SessionOption parameter is the SessionOption
object in the $so variable.




-------------------------- EXAMPLE 15 --------------------------

C:\PS>enable-wsmanCredSSP -delegate server02

C:\PS> connect-wsman Server02

C:\PS> set-item wsman:\server02*\service\auth\credSSP -value $true

C:\PS> $s = new-pssession server02

C:\PS> invoke-command -session $s -script {get-item \\Net03\Scripts\LogFile
s.ps1} -authentication credssp -credential domain01\admin01

Description
-----------
This example shows how to access a network share from within a remote sessi
on.

The command requires that CredSSP delegation be enabled in the client setti
ngs on the local computer and in the service settings on the remote compute
r. To run the commands in this example, you must be a member of the Adminis
trators group on the local computer and the remote computer.

The first command uses the Enable-WSManCredSSP cmdlet to enable CredSSP del
egation from the Server01 local computer to the Server02 remote computer. T
his configures the CredSSP client setting on the local computer.

The second command uses the Connect-WSman cmdlet to connect to the Server02
computer. This action adds a node for the Server02 computer to the WSMan:
drive on the local computer, allowing you to view and change the WS-Managem
ent settings on the Server02 computer.

The third command uses the Set-Item cmdlet to change the value of the CredS
SP item in the Service node of the Server02 computer to True. This action e
nables CredSSP in the service settings on the remote computer.

The fourth command uses the New-PSSession cmdlet to create a PSSession on t
he Server02 computer. It saves the PSSession in the $s variable.

The fifth command uses the Invoke-Command cmdlet to run a Get-Item command
in the session in $s that gets a script from the Net03\Scripts network shar
e. The command uses the Credential parameter and it uses the Authentication
parameter with a value of CredSSP.




REMARKS
To see the examples, type: "get-help Invoke-Command -examples".
For more information, type: "get-help Invoke-Command -detailed".
For technical information, type: "get-help Invoke-Command -full".

NAME
Invoke-Expression

SYNOPSIS
Runs commands or expressions on the local computer.


SYNTAX
Invoke-Expression [-Command] <string> [<CommonParameters>]


DESCRIPTION
The Invoke-Expression cmdlet evaluates or runs a specified string as a comm
and and returns the results of the expression or command. Without Invoke-Ex
pression, a string submitted at the command line would be returned (echoed)
unchanged.

PARAMETERS
-Command <string>
Specifies the command or expression to run. Type the command or express
ion or enter a variable that contains the command or expression. The Co
mmand parameter is required.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$command = "Get-Process"

C:\PS> $command
Get-Process


C:\PS> invoke-expression $command

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
296 4 1572 1956 20 0.53 1348 AdtAgent
270 6 1328 800 34 0.06 2396 alg
67 2 620 484 20 0.22 716 ati2evxx
1060 15 12904 11840 74 11.48 892 CcmExec
1400 33 25280 37544 223 38.44 2564 communicator
...

Description
-----------
This example demonstrates the use of Invoke-Expression to evaluate an expre
ssion. Without Invoke-Expression, the expression is printed, but not evalua
ted.

The first command assigns a value of "Get-Process" (a string) to the $comma
nd variable.

The second command shows the effect of typing the variable name at the comm
and line. Windows PowerShell echoes the string.

The third command uses Invoke-Expression to evaluate the string.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>invoke-expression -command "C:\ps-test\testscript.ps1"

C:\PS> "C:\ps-test\testscript.ps1" | invoke-expression

Description
-----------
These commands use Invoke-Expression to run a script, TestScript.ps1, on th
e local computer. The two commands are equivalent. The first uses the Comma
nd parameter to specify the command to run. The second uses a pipeline oper
ator (|) to send the command string to Invoke-Expression.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$cmd = 'get-process | where {$_.cpu -gt 1000}'

C:\PS> iex $command

Description
-----------
This example runs a command string that is saved in the $cmd variable.

The command string is enclosed in single quotation marks because it include
s a variable, $_, which represents the current object. If it were enclosed
in double quotation marks, the $_ variable would be replaced by its value b
efore it was saved in the $command string.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$cmdlet_name = "get-eventlog"

C:\PS> $example_number = 1

C:\PS> $example_code = (get-help $cmdlet_name).examples.example[($example_n
umber-1)].code

C:\PS> invoke-expression $example_code

Description
-----------
This command retrieves and runs the first example in the Get-EventLog cmdle
t help topic.

To run an example of a different cmdlet, change the value of the $cmdlet_na
me variable to the name of the cmdlet. And, change the $example_number vari
able to the example number you want to run. The command will fail if the ex
ample number is not valid.




REMARKS
To see the examples, type: "get-help Invoke-Expression -examples".
For more information, type: "get-help Invoke-Expression -detailed".
For technical information, type: "get-help Invoke-Expression -full".

NAME
Invoke-History

SYNOPSIS
Runs commands from the session history.


SYNTAX
Invoke-History [[-Id] <string>] [-Confirm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Invoke-History cmdlet runs commands from the session history. You can p
ass objects representing the commands from Get-History to Invoke-History, o
r you can identify commands in the current history by using their ID number
. To find the identification number of a command, use Get-History.

PARAMETERS
-Id <string>
Identifies a command in the history. You can type the ID number of the
command or the first few characters of the command.

If you type characters, Invoke-History matches the most recent commands
first. If you omit this parameter, Invoke-History runs the last (most
recent) command. The parameter name ("id") is optional. To find the ID
number of a command, use Get-History.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>invoke-history

Description
-----------
This command runs the last (most recent) command in the session history. Yo
u can abbreviate this command as "r" (think "repeat" or "rerun"), the alias
for Invoke-History.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>invoke-history -id 132

Description
-----------
This command runs the command in the session history with ID 132. Because t
he name of the Id parameter is optional, you can abbreviate this command as
"Invoke-History 132", "ihy 132", or "r 132".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>invoke-history get-pr

Description
-----------
This command runs the most recent Get-Process command in the session histor
y. When you type characters for the Id parameter, Invoke-History runs the f
irst command that it finds that matches the pattern, beginning with the mos
t recent commands. This command uses the ID parameter, but it omits the opt
ional parameter name.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>invoke-history (16..24), 27

Description
-----------
This command runs commands 16 through 24 and 27. You can list multiple IDs
and ID ranges separated by commas.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-history -id 255 -count 7 | invoke-history

Description
-----------
This command runs the 7 commands in the history that end with command 255 (
typically 249 through 255). It uses the Get-History cmdlet to retrieve the
commands. The pipeline operator (|) passes the commands to Invoke-History,
which executes them.




REMARKS
To see the examples, type: "get-help Invoke-History -examples".
For more information, type: "get-help Invoke-History -detailed".
For technical information, type: "get-help Invoke-History -full".

NAME
Invoke-Item

SYNOPSIS
Performs the default action on the specified item.


SYNTAX
Invoke-Item [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Exclud
e <string[]>] [-Filter <string>] [-Include <string[]>] [-Confirm] [-WhatIf]
[-UseTransaction] [<CommonParameters>]

Invoke-Item [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <stri
ng[]>] [-Filter <string>] [-Include <string[]>] [-Confirm] [-WhatIf] [-UseT
ransaction] [<CommonParameters>]


DESCRIPTION
The Invoke-Item cmdlet performs the default action on the specified item. F
or example, it runs an executable file or opens a document file in the appl
ication associated with the document file type. The default action depends
on the type of item and is determined by the Windows PowerShell provider th
at provides access to the data.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects rather than having Windows PowerShell filter
the objects after they are retrieved.

-Include <string[]>
Performs the default action only on the specified items. The value of t
his parameter qualifies the Path parameter. Enter a path element or pat
tern, such as "*.txt". Wildcards are permitted.

-LiteralPath <string[]>
Specifies a path to the item. The value of LiteralPath is used exactly
as it is typed. No characters are interpreted as wildcards. If the path
includes escape characters, enclose it in single quotation marks. Sing
le quotation marks tell Windows PowerShell not to interpret any charact
ers as escape sequences.

-Path <string[]>
Specifies the path to the selected item.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>invoke-item C:\Test\aliasApr04.doc

Description
-----------
This command opens the file aliasApr04.doc in Microsoft Office Word. In thi
s case, opening in Word is the default action for .doc files.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>invoke-item "C:\Documents and Settings\Lister\My Documents\*.xls"

Description
-----------
This command opens all of the Microsoft Office Excel spreadsheets in the C:
\Documents and Settings\Lister\My Documents folder. Each spreadsheet is ope
ned in a new instance of Excel. In this case, opening in Excel is the defau
lt action for .xls files.




REMARKS
To see the examples, type: "get-help Invoke-Item -examples".
For more information, type: "get-help Invoke-Item -detailed".
For technical information, type: "get-help Invoke-Item -full".

NAME
Import-Alias

SYNOPSIS
Imports an alias list from a file.


SYNTAX
Import-Alias [-Path] <string> [-Force] [-PassThru] [-Scope <string>] [-Conf
irm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Import-Alias cmdlet imports an alias list from a file.

PARAMETERS
-Force [<SwitchParameter>]
Allows the cmdlet to import an alias that is already defined and is rea
d only. You can use the following command to display information about
the currently-defined aliases:

get-alias | select-object name,Options
The value of the Options property will include "ReadOnly" if the corres
ponding alias is read only.

-PassThru [<SwitchParameter>]
Returns an object representing the alias. By default, this cmdlet does
not generate any output.

-Path <string>
Specifies the path to a file that includes exported alias information.
Wildcards are allowed but they must resolve to a single name.

-Scope <string>
Specifies the scope into which the aliases are imported. Valid values a
re "Global", "Local", or "Script", or a number relative to the current
scope (0 through the number of scopes, where 0 is the current scope and
1 is its parent). "Local" is the default. For more information, see ab
out_Scopes.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>import-alias test.txt

Description
-----------
This command imports alias information from a file named test.txt.




REMARKS
To see the examples, type: "get-help Import-Alias -examples".
For more information, type: "get-help Import-Alias -detailed".
For technical information, type: "get-help Import-Alias -full".

NAME
Import-Clixml

SYNOPSIS
Imports a CLIXML file and creates corresponding objects within Windows Powe
rShell.


SYNTAX
Import-Clixml [-Path] <string[]> [<CommonParameters>]


DESCRIPTION
The Import-Clixml cmdlet imports a CLIXML file with data that represents Mi
crosoft .NET Framework objects and creates the objects in Windows PowerShel
l.

PARAMETERS
-Path <string[]>
Specifies the location of the XML files to be converted into Windows Po
werShell objects.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-process | export-clixml pi.xml

C:\PS> $processes = import-clixml pi.xml

Description
-----------
This command uses the Export-Clixml cmdlet to save a serialized copy of the
process information returned by Get-Process. It then uses Import-Clixml to
retrieve the contents of the serialized file and re-create an object that
is stored in the $processes variable.




REMARKS
To see the examples, type: "get-help Import-Clixml -examples".
For more information, type: "get-help Import-Clixml -detailed".
For technical information, type: "get-help Import-Clixml -full".

NAME
Import-Counter

SYNOPSIS
Imports performance counter log files (.blg, .csv, .tsv) and creates the ob
jects that represent each counter sample in the log.


SYNTAX
Import-Counter [-Path] <string[]> [-Counter <string[]>] [-EndTime <DateTime
>] [-MaxSamples <Int64>] [-StartTime <DateTime>] [<CommonParameters>]

Import-Counter [-Path] <string[]> -ListSet <string[]> [<CommonParameters>]

Import-Counter [-Path] <string[]> -Summary <switch> [<CommonParameters>]


DESCRIPTION
The Import-Counter cmdlet imports performance counter data from performance
counter log files and creates objects for each counter sample in the file.
The PerformanceCounterSampleSet objects that it creates are identical to t
he objects that Get-Counter returns when it collects performance counter da
ta.

You can import data from comma-separated value (.csv), tab-separated value
( .tsv), and binary performance log (.blg) performance log files. If you ar
e using .blg files, you can import multiple files (up to 32 different files
) in each command. And, you can use the parameters of Import-Counter to fil
ter the data that you import.

Along with Get-Counter and Export-Counter, this feature lets you collect, e
xport, import, combine, filter, manipulate, and re-export performance count
er data within Windows PowerShell.

PARAMETERS
-Counter <string[]>
Imports data only for the specified performance counters. By default, I
mport-Counter imports all data from all counters in the input files. E
nter one or more counter paths. Wildcards are permitted in the Instance
part of the path.

Each counter path has the following format. Notice that the ComputerNam
e value is required in the path, even on the local computer.
"\\<ComputerName>\<CounterSet>(<Instance>)\<CounterName>"

For example:
"\\Server01\Processor(2)\% User Time"
"\Processor(*)\% Processor Time

-EndTime <DateTime>
Imports only counter data with a timestamp less than or equal to the sp
ecified date and time. Enter a DateTime object, such as one created by
the Get-Date cmdlet. By default, Import-Counter imports all counter dat
a in the files specified by the Path parameter.

-ListSet <string[]>
Gets the performance counter sets that are represented in the exported
files. Commands with this parameter do not import any data.

Enter one or more counter set names. Wildcards are permitted. To get a
ll counter sets in the file, type "import-counter -listset *".

-MaxSamples <Int64>
Specifies the maximum number of samples of each counter to import. By d
efault, Get-Counter imports all of the data in the files specified by t
he Path parameter.

-Path <string[]>
Specifies the file paths of the files to be imported. This parameter is
required.

Enter the path and file name of a, .csv,, .tsv, or .blg file that you e
xported by using the Export-Counter cmdlet. You can specify only one .c
sv or .tsv file, but you can specify multiple .blg files (up to 32) in
each command. You can also pipe file path strings (in quotation marks)
to Import-Counter.

-StartTime <DateTime>
Imports only counter data with a timestamp greater than or equal to the
specified date and time. Enter a DateTime object, such as one created
by the Get-Date cmdlet. By default, Import-Counter imports all counter
data in the files specified by the Path parameter.

-Summary <switch>
Gets a summary of the imported data, instead of getting individual coun
ter data samples.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS># Import-Counter

Description
-----------
This command imports all of the counter data from the ProcessorData.csv fil
e into the $data variable.

C:\PS> $data = import-counter -path ProcessorData.csv




-------------------------- EXAMPLE 2 --------------------------

C:\PS># Import-Counter

Description
-----------
This command imports only the Processor(_total)\Interrupts\sec counter data
from the ProcessorData.blg file into the $i variable.

C:\PS> $i = import-counter -path ProcessorData.blg -counter "\\SERVER01\Pro
cessor(_Total)\Interrupts/sec"




-------------------------- EXAMPLE 3 --------------------------

C:\PS># Import-Counter

Description
-----------
This example shows how to select data from a performance counter log file (
.blg) and then export the selected data to a .csv file.

The first four commands get the counter paths from the file and save them i
n a variable. The last two commands import selected data and then export on
ly the selected data.


The first command uses Import-Counter to import all of the performance coun
ter data from the ProcessorData.blg files. The command saves the data in th
e $data variable.

C:\PS> $data = import-counter .\processordata.blg



The second command displays the counter paths in the $data variable. The di
splay is shown in the command output.

C:\PS> $data[0].countersamples | format-table path

Path
----
\\SERVER01\Processor(_Total)\DPC Rate
\\SERVER01\Processor(1)\DPC Rate
\\SERVER01\Processor(0)\DPC Rate
\\SERVER01\Processor(_Total)\% Idle Time
\\SERVER01\Processor(1)\% Idle Time
\\SERVER01\Processor(0)\% Idle Time
\\SERVER01\Processor(_Total)\% C3 Time
\\SERVER01\Processor(1)\% C3 Time
...


The third command gets the counter paths that end in "Interrupts/sec" and s
aves the paths in the $IntCtrs variable.

C:\PS> $IntCtrs = $data[0].countersamples | where {$_.path -like "*interrup
ts/sec"} | foreach {$_.path}



The fourth command displays the selected counter paths.

C:\PS> $IntCtrs

\\SERVER01\Processor(_Total)\Interrupts/sec
\\SERVER01\Processor(1)\Interrupts/sec
\\SERVER01\Processor(0)\Interrupts/sec



The fifth command uses the Import-Counter cmdlet to import the data. It use
s the Counter parameter with the $IntCtrs variable to import only data for
the counter paths in $IntCtrs.

C:\PS> $i = import-counter -path .\processordata.blg -counter $intCtrs



The sixth command uses the Export-Counter cmdlet to export the data.

C:\PS> $i | export-counter -path .\interrupts.csv -format CSV




-------------------------- EXAMPLE 4 --------------------------

C:\PS># Import-Counter

Description
-----------
This example shows how to display all the counter paths in a group of impor
ted counter sets.

The first command uses the ListSet parameter to get all of the counter sets
that are represented in a counter data file.

C:\PS> import-counter -path processordata.csv -listset *

CounterSetName : Processor
MachineName : \\SERVER01
CounterSetType : MultiInstance
Description :
Paths : {\\SERVER01\Processor(*)\DPC Rate, \\SERVER01\Processo
r(*)\% Idle Time, \\SERVER01
\Processor(*)\% C3 Time, \\SERVER01\Processor(*)\% Int
errupt Time...}
PathsWithInstances : {\\SERVER01\Processor(_Total)\DPC Rate, \\SERVER01\Pro
cessor(1)\DPC Rate, \\SERVER01
\Processor(0)\DPC Rate, \\SERVER01\Processor(_Total)\%
Idle Time...}
Counter : {\\SERVER01\Processor(*)\DPC Rate, \\SERVER01\Processo
r(*)\% Idle Time, \\SERVER01
\Processor(*)\% C3 Time, \\SERVER01\Processor(*)\% Int
errupt Time...}



The second command gets all of the counter paths from the list set.

C:\PS> import-counter -path processordata.csv -listset * | foreach {$_.path
s}

\\SERVER01\Processor(*)\DPC Rate
\\SERVER01\Processor(*)\% Idle Time
\\SERVER01\Processor(*)\% C3 Time
\\SERVER01\Processor(*)\% Interrupt Time
\\SERVER01\Processor(*)\% C2 Time
\\SERVER01\Processor(*)\% User Time
\\SERVER01\Processor(*)\% C1 Time
\\SERVER01\Processor(*)\% Processor Time
\\SERVER01\Processor(*)\C1 Transitions/sec
\\SERVER01\Processor(*)\% DPC Time
\\SERVER01\Processor(*)\C2 Transitions/sec
\\SERVER01\Processor(*)\% Privileged Time
\\SERVER01\Processor(*)\C3 Transitions/sec
\\SERVER01\Processor(*)\DPCs Queued/sec
\\SERVER01\Processor(*)\Interrupts/sec




-------------------------- EXAMPLE 5 --------------------------

C:\PS># Import-Counter

Description
-----------
This example imports only the counter data that has a time stamp between th
e starting an ending ranges specified in the command.

The first command lists the time stamps of all of the data in the Processor
Data.blg file.

C:\PS> import-counter -path .\disk.blg | format-table timestamp


The second and third commands save particular time stamps in the $start and
$end variables. The strings are cast to DateTime objects.

C:\PS> $start = [datetime]"7/9/2008 3:47:00 PM"
C:\PS> $end = [datetime]"7/9/2008 3:47:59 PM"


The fourth command uses Import-Counter to get only counter data that has a
time stamp between the start and end times (inclusive). The command uses th
e StartTime and EndTime parameters to specify the range.

C:\PS> $t-data = import-counter -path disk.blg -starttime $start -endtime
$end




-------------------------- EXAMPLE 6 --------------------------

C:\PS># Import-Counter

Description
-----------
This example shows how to import the five oldest and five newest samples fr
om a performance counter log file.

The first command uses the Import-Counter cmdlet to import data from the Di
sk.blg file. The command uses the MaxSamples parameter to limit the import
to five counter samples. This command gets the first (oldest) five samples
in the file.

C:\PS> import-counter -path disk.blg -maxSamples 5

The second command uses array notation and the Windows PowerShell range ope
rator (..) to get the last five counter samples from the file. These are th
e five newest samples.

C:\PS> (import-counter -path disk.blg)[-1 .. -5]




-------------------------- EXAMPLE 7 --------------------------

C:\PS># Import-Counter

Description
-----------
This command uses the Summary parameter to get a summary of the counter dat
a from the Memory.blg file.

C:\PS> import-counter D:\Samples\memory.blg -summary

OldestRecord NewestRecord SampleCount
------------ ------------ -----------
7/10/2008 2:59:18 PM 7/10/2008 3:00:27 PM 1000




-------------------------- EXAMPLE 8 --------------------------

C:\PS># Import-Counter

Description
-----------
This example updates a performance counter log file.

The first command uses the ListSet parameter of Import-Counter to get the c
ounters in OldData.blg, an existing counter log file. The command uses a pi
peline operator (|) to send the data to a Foreach-Object command that gets
only the values of the PathsWithInstances property of each object.

C:\PS> $counters = import-counter olddata.blg -ListSet * | foreach {$_.Path
sWithInstances}


The second command uses those same counters in a new Get-Counter command to
get a current sample, and export it to the NewData.blg file.

C:\PS> get-counter -counter $counters -maxSamples 20 | export-counter c:\Lo
gs\newdata.blg




-------------------------- EXAMPLE 9 --------------------------

C:\PS># Import-Counter

Description
-----------
This command imports performance log data from two logs and saves the data
in the $counters variable. The command uses a pipeline operator to send per
formance log paths to Import-Counter.

C:\PS> $counters = "d:\test\pdata.blg", "d:\samples\netlog.blg" | import-co
unter

Notice that each path is enclosed in quotation marks and that the paths are
separated from each other by a comma.




REMARKS
To see the examples, type: "get-help Import-Counter -examples".
For more information, type: "get-help Import-Counter -detailed".
For technical information, type: "get-help Import-Counter -full".

NAME
Import-CSV

SYNOPSIS
Converts object properties in a comma-separated value (CSV) file into CSV v
ersions of the original objects.


SYNTAX
Import-CSV [[-Delimiter] <char>] [-Path] <string[]> [-Header <string[]>] [<
CommonParameters>]

Import-CSV -UseCulture [-Path] <string[]> [-Header <string[]>] [<CommonPara
meters>]


DESCRIPTION
The Import-CSV cmdlet creates objects from CSV variable-length files that a
re generated by the Export-CSV cmdlet.

You can use the parameters of the Import-CSV cmdlet to specify the column h
eader row, which determines the property names of the resulting objects; to
specify the item delimiter; or to direct Import-CSV to use the list separa
tor for the current culture as the item delimiter.

The objects that Import-CSV creates are CSV versions of the original object
s. The property values of the CSV objects are string versions of the proper
ty values of the original objects. The CSV versions of the objects do not h
ave any methods.

You can also use the ConvertTo-CSV and ConvertFrom-CSV cmdlets to convert o
bjects to CSV strings (and back). These cmdlets are the same as the Export-
CSV and Import-CSV cmdlets, except that they do not save the CSV strings in
a file.

PARAMETERS
-Delimiter <char>
Specifies the delimiter that separates the property values in the CSV f
ile. The default is a comma (,). Enter a character, such as a colon (:)
. To specify a semicolon (;), enclose it in quotation marks.

If you specify a character other than the actual string delimiter in th
e file, Import-CSV cannot create objects from the CSV strings. Instead,
it returns the strings.

-Header <string[]>
Specifies an alternate column header row for the imported file. The col
umn header determines the names of the properties of the object that Im
port-CSV creates.

Enter a comma-separated list of the column headers. Enclose each item i
n quotation marks (single or double). Do not enclose the header string
in quotation marks. If you enter fewer column headers than there are co
lumns, the remaining columns will have no header. If you enter more hea
ders than there are columns, the extra headers are ignored.

When using the Header parameter, delete the original header row from th
e CSV file. Otherwise, Import-CSV creates an extra object from the item
s in the header row.

-Path <string[]>
Specifies the path to the CSV file to import. You can also pipe a path
to Import-CSV.

-UseCulture [<SwitchParameter>]
Use the list separator for the current culture as the item delimiter. T
he default is a comma (,).

To find the list separator for a culture, use the following command: (G
et-Culture).TextInfo.ListSeparator. If you specify a character other th
an the delimiter used in the CSV strings, ConvertFrom-CSV cannot create
objects from the CSV strings. Instead, it returns the strings.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-process | export-csv processes.csv

C:\PS> $p = import-CSV processes.csv

C:\PS> $p | get-member

TypeName: CSV:System.Diagnostics.Process

Name MemberType Definition
---- ---------- ----------
Equals Method System.Boolean Equals(Object obj)
GetHashCode Method System.Int32 GetHashCode()
GetType Method System.Type GetType()
ToString Method System.String ToString()
BasePriority NoteProperty System.String BasePriority=8
Company NoteProperty System.String Company=Microsoft Cor
poration
...

C:\PS> $p | out-gridview

Description
-----------
This example shows how to export and then import a CSV file of Microsoft .N
ET Framework objects.

The first command uses the Get-Process cmdlet to get the process on the loc
al computer. It uses a pipeline operator (|) to send the process objects to
the Export-CSV cmdlet, which exports the process objects to the Processes.
csv file in the current directory.

The second command uses the Import-CSV cmdlet to import the processes in th
e Import-CSV file. Then it saves the resulting process objects in the $p va
riable.

The third command uses a pipeline operator to pipe the imported objects to
the Get-Member cmdlets. The result shows that they are CSV:System.Diagnosti
c.Process objects, not the System.Diagnostic.Process objects that Get-Proce
ss returns.

Also, because there is no entry type in the formatting files for the CSV ve
rsion of the process objects, these objects are not formatted in the same w
ay that standard process objects are formatted.

To display the objects, use the formatting cmdlets, such as Format-Table an
d Format-List, or pipe the objects to Out-GridView.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-process | export-csv processes.csv -Delimiter :

C:\PS> $p = import-csv processes.csv -Delimiter :

Description
-----------
This example shows how to use the Delimiter parameter of Import-CSV. In thi
s example, the processes are exported to a file that uses a colon (:) as a
delimiter.

When importing, the Import-CSV file uses the Delimiter parameter to indicat
e the delimiter that is used in the file.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$p = import-csv processes.csv -UseCulture

C:\PS> (get-culture).textinfo.listseparator

,

Description
-----------
This example shows how to use the UseCulture parameter of Import-CSV.

The first command imports the objects in the Processes.csv file into the $p
variable. It uses the UseCulture parameter to direct Import-CSV to use the
list separator defined for the current culture.

The second command displays the list separator for the current culture. It
uses the Get-Culture cmdlet to get the current culture. It uses the dot (.)
method to get the TextInfo property of the current culture and the ListSep
arator property of the object in TextInfo. In this example, the command ret
urns a comma.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>start-job -scriptblock { get-process } | export-csv jobs.csv

C:\PS> $header = "MoreData","StatusMessage","Location","Command","State","F
inished","InstanceId","SessionId","Name","ChildJobs","Output","Error","Prog
ress","Verbose","Debug","Warning","StateChanged"

# Delete header from file
C:\PS> $a = (get-content jobs.csv)
C:\PS> $a = $a[0], $a[2..($a.count - 1)]
C:\PS> $a > jobs.csv

C:\PS> $j = import-csv jobs.csv -header $header

C:\PS> $j

MoreData : True
StatusMessage :
Location : localhost
Command : get-process
State : Running
Finished : System.Threading.ManualResetEvent
InstanceId : 135bdd25-40d6-4a20-bd68-05282a59abd6
SessionId : 1
Name : Job1
ChildJobs : System.Collections.Generic.List`1[System.Management.Automat
ion.Job]
Output : System.Management.Automation.PSDataCollection`1[System.Mana
gement.Automation.PSObject]
Error : System.Management.Automation.PSDataCollection`1[System.Mana
gement.Automation.ErrorRecord]
Progress : System.Management.Automation.PSDataCollection`1[System.Mana
gement.Automation.ProgressRecord]
Verbose : System.Management.Automation.PSDataCollection`1[System.Stri
ng]
Debug : System.Management.Automation.PSDataCollection`1[System.Stri
ng]
Warning : System.Management.Automation.PSDataCollection`1[System.Stri
ng]
StateChanged :

Description
-----------
This example shows how to use the Header parameter of Import-CSV to change
the names of properties in the resulting imported object.

The first command uses the Start-Job cmdlet to start a background job that
runs a Get-Process command on the local computer. A pipeline operator (|) s
ends the resulting job object to the Export-CSV cmdlet, which converts the
job object to CSV format. An assignment operator (=) saves the resulting CS
V in the Jobs.csv file.

The second command saves a header in the $header variable. Unlike the defau
lt header, this header uses "MoreData" instead of "HasMoreData" and "State"
instead of "JobStateInfo".

The next three commands delete the original header (the second line) from t
he Jobs.csv file.

The sixth command uses the Import-CSV cmdlet to import the Jobs.csv file an
d convert the CSV strings into a CSV version of the job object. The command
uses the Header parameter to submit the alternate header. The results are
stored in the $j variable.

The seventh command displays the object in the $j variable. The resulting o
bject has "MoreData" and "State" properties, as shown in the command output
.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>".\processes.csv" | import-csv

Description
-----------
This command imports the objects from the Processes.csv file.




REMARKS
To see the examples, type: "get-help Import-CSV -examples".
For more information, type: "get-help Import-CSV -detailed".
For technical information, type: "get-help Import-CSV -full".

NAME
Import-LocalizedData

SYNOPSIS
Imports language-specific data into scripts and functions based on the UI c
ulture that is selected for the operating system.


SYNTAX
Import-LocalizedData [-BindingVariable] <string> [[-UICulture] <string>] [-
BaseDirectory <string>] [-FileName <string>] [-SupportedCommand <string[]>]
[<CommonParameters>]


DESCRIPTION
The Import-LocalizedData cmdlet dynamically retrieves strings from a subdir
ectory whose name matches the UI language set for the current user of the o
perating system. It is designed to enable scripts to display user messages
in the UI language selected by the current user.

Import-LocalizedData imports data from .psd1 files in language-specific sub
directories of the script directory and saves them in a local variable that
is specified in the command. The cmdlet selects the subdirectory and file
based on the value of the $PSUICulture automatic variable. When you use the
local variable in the script to display a user message, the message appear
s in the user's UI language.

You can use the parameters of Import-LocalizedData to specify an alternate
UI culture, path, and file name, to add supported commands, and to suppress
the error message that appears if the .psd1 files are not found.

The Import-LocalizedData cmdlet supports script internationalization in Win
dows PowerShell 2.0. This initiative aims to better serve users worldwide b
y making it easy for scripts to display user messages in the UI language of
the current user. For more information about this and about the format of
the .psd1 files, see about_Script_Internationalization.

PARAMETERS
-BaseDirectory <string>
Specifies the base directory where the .psd1 files are located. The def
ault is the directory where the script is located. Import-LocalizedData
searches for the .psd1 file for the script in a language-specific subd
irectory of the base directory.

-BindingVariable <string>
Specifies a variable into which the text strings are imported. Enter a
variable name without a dollar sign ($).

When using Import-LocalizedData to replace default text strings specifi
ed in the DATA section of a script, assign the DATA section to a variab
le and enter the name of the DATA section variable in the value of the
BindingVariable parameter. Then, when Import-LocalizedData saves the im
ported content in the BindingVariable, the imported data will replace t
he default text strings. If you are not specifying default text strings
, you can select any variable name.

-FileName <string>
Specifies the name of the .psd1 file to be imported. Enter a file name
without the .psd1 file name extension.

The default is the name of the script. For example, if the script is Fi
ndFiles.ps1, Import-LocalizedData searches for FindFiles.psd1. You can
use this parameter to direct Import-LocalizedData to search for a diffe
rent .psd1 file.

-SupportedCommand <string[]>
Specifies cmdlets and functions that generate only data.

Use this parameter to include cmdlets and functions that you have writt
en or tested. For more information, see about_Script_Internationalizati
on.

-UICulture <string>
Specifies an alternate UI culture. The default is the value of the $PsU
ICulture automatic variable. Enter a UI culture in "<language>-<region>
" format, such as en-US, de-DE, or ar-SA.

The value of the UICulture parameter determines the language-specific s
ubdirectory (within the base directory) from which Import-LocalizedData
gets the .psd1 file for the script.

The cmdlet searches for a subdirectory with the same name as the value
of the UICulture parameter or the $PsUICulture automatic variable, suc
h as "de-DE" or "ar-SA". If it cannot find the directory, or the direct
ory does not contain a .psd1 file for the script, it searches for a sub
directory with the name of the language code, such as "de" or "ar". If
it cannot find the subdirectory or .psd1 file, the command fails and th
e data is displayed in the default language specified in the script.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>import-localizeddata -bindingVariable messages

Description
-----------
This command imports text strings into the $messages variable. It uses all
of the default values for the cmdlet parameters.

If the command is included in the Archives.ps1 script in the C:\test direct
ory, and the value of the $PsUICulture automatic variable is zh-CN, Import-
LocalizedData imports the Archives.psd1 file in the C:\test\zh-CN directory
.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>import-localizeddata -bindingVariable msgTbl -uiculture ar-SA -filena
me Simple -baseDirectory C:\Data\Localized

Description
-----------
This command imports text strings into the $msgTbl variable of a script.

It uses the UICulture parameter to direct the cmdlet to import data from th
e Simple.psd1 file in the ar-SA subdirectory of C:\Data\Localized.




-------------------------- EXAMPLE 3 --------------------------

C:\PS># In C:\Test\en-US\test.psd1:

ConvertFrom-StringData @'
# English strings
Msg1 = "The Name parameter is missing from the command."
Msg2 = "This command requires the credentials of a member of the Administra
tors group on the computer."
Msg3 = "Use $_ to represent the object that is being processed."
'@

# In C:\Test\Test.ps1

import-localizeddata -bindingvariable messages
write-host $messages.msg2

# In Windows PowerShell

C:\PS> .\test.ps1
This command requires the credentials of a member of the Administrators gro
up on the computer.

Description
-----------
This example shows how to use localized data in a simple script.

The first part of the example shows the contents of the Test.psd1 file. It
contains a ConvertFrom-StringData command that converts a series of named t
ext strings into a hash table. The test.psd1 file is located in the en-US s
ubdirectory of the C:\Test directory that contains the script.

The second part of the example shows the contents of the Test.ps1 script. I
t contains an Import-LocalizedData command that imports the data from the m
atching .psd1 file into the $Messages variable and a Write-Host command tha
t writes one of the messages in the $Messages variable to the host program.

The last part of the example runs the script. The output shows that it disp
lays the correct user message in the UI language set for the current user o
f the operating system.




-------------------------- EXAMPLE 4 --------------------------

C:\PS># In TestScript.ps1

$UserMessages = DATA {
ConvertFrom-StringData @'
# English strings
Msg1 = "Enter a name."
Msg2 = "Enter your employee ID."
Msg3 = "Enter your building number."
'@ }

Import-LocalizedData -bindingVariable UserMessages

$UserMessages.Msg1
...

Description
-----------
This example shows how to use Import-LocalizedData to replace default text
strings defined in the DATA section of a script.

In this example, the DATA section of the TestScript.ps1 script contains a C
onvertFrom-StringData command that converts the contents of the DATA sectio
n to a hash table and stores in the value of the $UserMessages variable.

The script also includes an Import-LocalizedData command, which imports a h
ash table of translated text strings from the TestScript.psd1 file in the s
ubdirectory specified by the value of the $PsUICulture variable. If the com
mand finds the .psd1 file, it saves the translated strings from the file in
the value of the same $UserMessages variable, overwriting the hash table s
aved by the DATA section logic.

The third command displays the first message in the $UserMessages variable.

If the Import-LocalizedData command finds a .psd1 file for the $PsUICulture
language, the value of the $UserMessages variable contains the translated
text strings. If the command fails for any reason, the command displays the
default text strings defined in the DATA section of the script.




-------------------------- EXAMPLE 5 --------------------------

C:\PS># In Day1.ps1
Import-LocalizedData -bindingVariable Day
Day.MessageDate

# In Day2.ps1
Import-LocalizedData -bindingVariable Day -errorAction:silentlycontinue
Day.MessageDate

C:\PS> .\Day1.ps1

Import-LocalizedData : Cannot find PowerShell data file 'Day1.psd1' in dire
ctory 'C:\ps-test\fr-BE\' or any parent culture directories.
At C:\ps-test\Day1.ps1:17 char:21
+ Import-LocalizedData <<<< Day
Today is Tuesday


C:\PS> .\Day2.ps1

Today is Tuesday

Description
-----------
This example shows how to suppress the error messages that appear when Impo
rt-LocalizedData cannot find the directories that match the user's UI cultu
re or cannot find a .psd1 file for the script in those directories.

You can use the ErrorAction common parameter with a value of "SilentlyConti
nue" to suppress the error message. This is especially useful when you have
provided user messages in a default or "fallback" language, and no error m
essage is needed.

This example compares two scripts, Day1.ps1 and Day2.ps1, that include an I
mport-LocalizedData command. The scripts are identical, except that Day2 us
es the ErrorAction common parameter with a value of SilentlyContinue.

The sample output shows the results of running both scripts when the UI cul
ture is set to fr-BE and there are no matching files or directories for tha
t UI culture. Day1.ps1 displays an error message and English output. Day2.p
s1 just displays the English output.




REMARKS
To see the examples, type: "get-help Import-LocalizedData -examples".
For more information, type: "get-help Import-LocalizedData -detailed".
For technical information, type: "get-help Import-LocalizedData -full".

NAME
Import-Module

SYNOPSIS
Adds modules to the current session.


SYNTAX
Import-Module [-Name] <string[]> [-Alias <string[]>] [-ArgumentList <Object
[]>] [-AsCustomObject] [-Cmdlet <string[]>] [-Force] [-Function <string[]>]
[-Global] [-PassThru] [-Prefix <string>] [-Variable <string[]>] [-Version
<Version>] [<CommonParameters>]

Import-Module [-Assembly] <Assembly[]> [-Alias <string[]>] [-ArgumentList <
Object[]>] [-AsCustomObject] [-Cmdlet <string[]>] [-Force] [-Function <stri
ng[]>] [-Global] [-PassThru] [-Prefix <string>] [-Variable <string[]>] [-Ve
rsion <Version>] [<CommonParameters>]

Import-Module [-ModuleInfo] <PSModuleInfo[]> [-Alias <string[]>] [-Argument
List <Object[]>] [-AsCustomObject] [-Cmdlet <string[]>] [-Force] [-Function
<string[]>] [-Global] [-PassThru] [-Prefix <string>] [-Variable <string[]>
] [-Version <Version>] [<CommonParameters>]


DESCRIPTION
The Import-Module cmdlet adds one or more modules to the current session.

A module is a package that contains members (such as cmdlets, providers, sc
ripts, functions, variables, and other tools and files) that can be used in
Windows PowerShell. After a module is imported, you can use the module mem
bers in your session.

To import a module, use the Name, Assembly, or ModuleInfo parameter to iden
tify the module to import. By default, Import-Module imports all members th
at the module exports, but you can use the Alias, Function, Cmdlet, and Var
iable parameters to restrict the members that are imported.

Import-Module imports a module only into the current session. To import the
module into all sessions, add an Import-Module command to your Windows Pow
erShell profile. For more information about profiles, see about_Profiles.

For more information about modules, see about_Modules.

PARAMETERS
-Alias <string[]>
Imports only the specified aliases from the module into the current ses
sion. Enter a comma-separated list of aliases. Wildcard characters are
permitted.

Some modules automatically export selected aliases into your session wh
en you import the module. This parameter lets you select from among the
exported aliases.

-ArgumentList <Object[]>
Specifies arguments (parameter values) that are passed to a script modu
le during the Import-Module command. This parameter is valid only when
you are importing a script module.

You can also refer to ArgumentList by its alias, "args". For more infor
mation, see about_Aliases.

-AsCustomObject [<SwitchParameter>]
Returns a custom object with members that represent the imported module
members. This parameter is valid only for script modules.

When you use the AsCustomObject parameter, Import-Module imports the mo
dule members into the session and then returns a PSCustomObject object
instead of a PSModuleInfo object. You can save the custom object in a v
ariable and use dot notation to invoke the members.

-Assembly <Assembly[]>
Imports the cmdlets and providers implemented in the specified assembly
objects. Enter a variable that contains assembly objects or a command
that creates assembly objects. You can also pipe an assembly object to
Import-Module.

When you use this parameter, only the cmdlets and providers implemented
by the specified assemblies are imported. If the module contains other
files, they are not imported, and you might be missing important membe
rs of the module. Use this parameter for debugging and testing the modu
le, or when you are instructed to use it by the module author.

-Cmdlet <string[]>
Imports only the specified cmdlets from the module into the current ses
sion. Enter a list of cmdlets. Wildcard characters are permitted.

Some modules automatically export selected cmdlets into your session wh
en you import the module. This parameter lets you select from among the
exported cmdlets.

-Force [<SwitchParameter>]
Re-imports a module and its members, even if the module or its members
have an access mode of read-only.

-Function <string[]>
Imports only the specified functions from the module into the current s
ession. Enter a list of functions. Wildcard characters are permitted.

Some modules automatically export selected functions into your session
when you import the module. This parameter lets you select from among t
he exported functions.

-Global [<SwitchParameter>]
When used in a script module (.psm1), this parameter imports modules in
to the global session state.

This parameter is effective only when it appears in a script module. Ot
herwise, it is ignored.

By default, the commands in a script module, including commands from ne
sted modules, are imported into the caller's session state. To restrict
the commands that a module exports, use an Export-ModuleMember command
in the script module.

-ModuleInfo <PSModuleInfo[]>
Specifies module objects to import. Enter a variable that contains the
module objects, or a command that gets the module objects, such as a "g
et-module -listavailable" command. You can also pipe module objects to
Import-Module.

-Name <string[]>
Specifies the names of the modules to import. Enter the name of the mod
ule or the name of a file in the module, such as a .psd1, .psm1, .dll,
or ps1 file. File paths are optional. Wildcards are not permitted. You
can also pipe module names and file names to Import-Module.

If you omit a path, Import-Module looks for the module in the paths sav
ed in the PSModulePath environment variable ($env:PSModulePath).

Specify only the module name whenever possible. When you specify a file
name, only the members that are implemented in that file are imported.
If the module contains other files, they are not imported, and you mig
ht be missing important members of the module.

-PassThru [<SwitchParameter>]
Returns objects that represent the modules that were imported. By defau
lt, this cmdlet does not generate any output.

Notes
-- When you pipe the output of a "get-module -listavailable" command to
an Import-Module command with the PassThru parameter, Import-Module re
turns the object that Get-Module passed to it without updating the obje
ct. As a result, the Exported and NestedModules properties are not yet
populated.

-- When you use the Prefix parameter to specify a prefix for the member
, the prefix does not appear in the member names in the properties of t
he module object. The object records what was exported before the prefi
x was applied.

-Prefix <string>
Adds the specified prefix to the nouns in the names of imported module
members.

Use this parameter to avoid name conflicts that might occur when differ
ent members in the session have the same name. This parameter does not
change the module, and it does not affect files that the module imports
for its own use (known as "nested modules"). It affects only the names
of members in the current session.

For example, if you specify the prefix "UTC" and then import a Get-Date
cmdlet, the cmdlet is known in the session as Get-UTCDate, and it is n
ot confused with the original Get-Date cmdlet.

-Variable <string[]>
Imports only the specified variables from the module into the current s
ession. Enter a list of variables. Wildcard characters are permitted.

Some modules automatically export selected variables into your session
when you import the module. This parameter lets you select from among t
he exported variables.

-Version <Version>
Specifies the version of the module to import. Use this parameter when
you have different versions of the same module on your system.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>import-module -name BitsTransfer

Description
-----------
This command imports the members of the BitsTransfer module into the curren
t session.

The Name parameter name (-Name) is optional and can be omitted.

By default, Import-Module does not generate any output when it imports a mo
dule. To request output, use the PassThru or AsCustomObject parameter, or t
he Verbose common parameter.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-module -listAvailable | import-module

Description
-----------
This command imports all available modules in the path specified by the PSM
odulePath environment variable ($env:psmodulepath) into the current session
.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$m = get-module -ListAvailable BitsTransfer, ServerBackup

C:\PS> import-module -moduleInfo $m

Description
-----------
These commands import the members of the BitsTransfer and ServerBackup modu
les into the current session.

The first command uses the Get-Module cmdlet to get PSModuleInfo objects th
at represent the BitsTransfer and ServerBackup modules. It saves the object
s in the $m variable. The ListAvailable parameter is required when you are
getting modules that are not yet imported into the session.

The second command uses the ModuleInfo parameter of Import-Module to import
the modules into the current session.

These commands are equivalent to using a pipeline operator (|) to send the
output of a Get-Module command to Import-Module.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>import-module -name c:\ps-test\modules\test -verbose

VERBOSE: Loading module from path 'C:\ps-test\modules\Test\Test.psm1'.
VERBOSE: Exporting function 'my-parm'.
VERBOSE: Exporting function 'get-parm'.
VERBOSE: Exporting function 'get-spec'.
VERBOSE: Exporting function 'get-specDetails'.

Description
-----------
This command uses an explicit path to identify the module to import.

It also uses the Verbose common parameter to get a list of the items import
ed from the module. Without the Verbose, PassThru, or AsCustomObject parame
ter, Import-Module does not generate any output when it imports a module.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>import-module BitsTransfer -cmdlet Add-BitsTransferFile, Get-BitsTran
sfer

C:\PS> get-module BitsTransfer

Name : BitsTransfer
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Bits
Transfer\BitsTransfer.psd1
Description :
Guid : 8fa5064b-8479-4c5c-86ea-0d311fe48875
Version : 1.0.0.0
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Bits
Transfer
ModuleType : Manifest
PrivateData :
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {[Add-BitsTransfer, Add-BitsTransfer], [Complete-BitsTr
ansfer, Complete-BitsTransfer], [Get-BitsTransfer, Get-BitsTransfer], [Rem
ove-BitsTransfer, Remove-BitsTransfer]...}
ExportedFunctions : {}
ExportedVariables : {}
NestedModules : {Microsoft.BackgroundIntelligentTransfer.Management}


C:\PS> get-command -module BitsTransfer

CommandType Name Definition
----------- ---- ----------
Cmdlet Add-BitsTransfer Add-BitsTransfer [-BitsJob] <BitsJob[]> [-S
ource] <String[]> [[-Destination] <String[]>] [-Verbose] [-Debug] [-ErrorA.
..
Cmdlet Get-BitsTransfer Get-BitsTransfer [[-Name] <String[]>] [-All
Users] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-WarningActi.
..

Description
-----------
This example shows how to restrict the module members that are imported int
o the session and the effect of this command on the session.

The first command imports only the Add-BitsTransfer and Get-BitsTransfer cm
dlets from the BitsTransfer module. The command uses the Cmdlet parameter t
o restrict the cmdlets that the module imports. You can also use the Alias,
Variable, and Function parameters to restrict other members that a module
imports.

The second command uses the Get-Module cmdlet to get the object that repres
ents the BitsTransfer module. The ExportedCmdlets property lists all of the
cmdlets that the module exports, even when they were not all imported.

The third command uses the Module parameter of the Get-Command cmdlet to ge
t the commands that were imported from the BitsTransfer module. The results
confirm that only the Add-BitsTransfer and Get-BitsTransfer cmdlets were i
mported.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>import-module BitsTransfer -prefix PS -passthru

Name : bitstransfer
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\bits
transfer\bitstransfer.psd1
Description :
Guid : 8fa5064b-8479-4c5c-86ea-0d311fe48875
Version : 1.0.0.0
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\bits
transfer
ModuleType : Manifest
PrivateData :
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {[Add-BitsTransfer, Add-BitsTransfer], [Remove-BitsTran
sfer, Remove-BitsTransfer], [Complete-BitsTransfer, Complete-BitsTransfer]
, [Get-BitsTransfer, Get-BitsTransfer]...}
ExportedFunctions : {}
ExportedVariables : {}
NestedModules : {Microsoft.BackgroundIntelligentTransfer.Management}


C:\PS> get-command -module bitstransfer

CommandType Name Definition
----------- ---- ----------
Cmdlet Add-PSBitsTransfer Add-PSBitsTransfer [-BitsJob] <
BitsJob[]> [-Source] <String[]> ...
Cmdlet Complete-PSBitsTransfer Complete-PSBitsTransfer [-BitsJ
ob] <BitsJob[]> [-Verbose] [-Deb...
Cmdlet Get-PSBitsTransfer Get-PSBitsTransfer [[-Name] <St
ring[]>] [-AllUsers] [-Verbose] ...
Cmdlet Remove-PSBitsTransfer Remove-PSBitsTransfer [-BitsJob
] <BitsJob[]> [-Verbose] [-Debug...
Cmdlet Resume-PSBitsTransfer Resume-PSBitsTransfer [-BitsJob
] <BitsJob[]> [-Asynchronous] [-...
Cmdlet Set-PSBitsTransfer Set-PSBitsTransfer [-BitsJob] <
BitsJob[]> [-DisplayName <String...
Cmdlet Start-PSBitsTransfer Start-PSBitsTransfer [[-Source]
<String[]>] [[-Destination] <St...
Cmdlet Suspend-PSBitsTransfer Suspend-PSBitsTransfer [-BitsJo
b] <BitsJob[]> [-Verbose] [-Debu...

Description
-----------
These commands import the BitsTransfer module into the current session, add
a prefix to the member names, and then display the prefixed member names.

The first command uses the Import-Module cmdlet to import the BitsTransfer
module. It uses the Prefix parameter to add the PS prefix to all members th
at are imported from the module and the PassThru parameter to return a modu
le object that represents the imported module.

The module object that the command returns has an ExportedCmdlets property
that lists the exported members. The prefix does not appear in the cmdlet n
ames, because it is applied after the members are exported (but before they
are imported).

The second command uses the Get-Command cmdlet to get the members that have
been imported from the module. It uses the Module parameter to specify the
module. The output shows that the module members were correctly prefixed.

The prefix that you use applies only to the members in the current session.
It does not change the module.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-module -list | format-table -property name, moduletype -auto

Name ModuleType
---- ----------
Show-Calendar Script
BitsTransfer Manifest
PSDiagnostics Manifest
TestCmdlets Script

C:\PS> $a = import-module -name Show-Calendar -asCustomObject

C:\PS> $a | get-member


TypeName: System.Management.Automation.PSCustomObject

Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Show-Calendar ScriptMethod System.Object Show-Calendar();

C:\PS> $a."show-calendar"()

Description
-----------
These commands demonstrate how to get and use the custom object that Import
-Module returns.

Custom objects include synthetic members that represent each of the importe
d module members. For example, the cmdlets and functions in a module are co
nverted to script methods of the custom object.

Custom objects are very useful in scripting. They are also useful when seve
ral imported objects have the same names. Using the script method of an obj
ect is equivalent to specifying the fully qualified name of an imported mem
ber, including its module name.

The AsCustomObject parameter can be used only with a script module, so the
first task is to determine which of the available modules is a script modul
e.

The first command uses the Get-Module cmdlet to get the available modules.
The command uses a pipeline operator (|) to pass the module objects to the
Format-Table cmdlet, which lists the Name and ModuleType of each module in
a table.

The second command uses the Import-Module cmdlet to import the Show-Calenda
r script module. The command uses the AsCustomObject parameter to request a
custom object. The command saves the resulting custom object in the $a var
iable.

The third command uses a pipeline operator to send the $a variable to the G
et-Member cmdlet, which gets the properties and methods of the PSCustomObje
ct in $a. The output shows a Show-Calendar script method.

The last command uses the Show-Calendar script method. The method name must
be enclosed in quotation marks, because it includes a hyphen.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>import-module BitsTransfer

C:\PS> import-module BitsTransfer -force -prefix PS

Description
-----------
This example shows how to use the Force parameter of Import-Module when you
are re-importing a module into the same session.

The first command imports the BitsTransfer module. The second command impor
ts the module again, this time using the Prefix parameter.

The second command also includes the Force parameter, which removes the mod
ule and then imports it again. Without this parameter, the session would in
clude two copies of each BitsTransfer cmdlet, one with the standard name an
d one with the prefixed name.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>get-date

Saturday, September 12, 2009 6:47:04 PM

C:\PS> import-module TestModule

C:\PS> get-date
09255

C:\PS> get-command get-date | format-table -property commandtype, name, pss
napin, module -auto

CommandType Name pssnapin Module
----------- ---- -------- ------
Function Get-Date TestModule
Cmdlet Get-Date Microsoft.PowerShell.Utility


C:\PS> Microsoft.PowerShell.Utility\get-date

Saturday, September 12, 2009 6:33:23 PM

Description
-----------
This example shows how to run commands that have been hidden by imported co
mmands.

The first command run the Get-Date cmdlet that comes with Windows PowerShel
l. It returns a DateTime object with the current date.

The second command imports the TestModule module. This module includes a fu
nction named Get-Date that returns the Julian date.

The third command runs the Get-Date command again. Because functions take p
recedence over cmdlets, the Get-Date function from the TestModule module ra
n, instead of the Get-Date cmdlet.

The fourth command shows that there are two Get-Date commands in the sessio
n, a function from the TestModule module and a cmdlet from the Microsoft.Po
werShell.Utility snap-in.

The fifth command runs the hidden cmdlet by qualifying the command name wit
h the snap-in name.

For more information about command precedence in Windows PowerShell, see ab
out_command_precedence.




REMARKS
To see the examples, type: "get-help Import-Module -examples".
For more information, type: "get-help Import-Module -detailed".
For technical information, type: "get-help Import-Module -full".

NAME
Import-PSSession

SYNOPSIS
Imports commands from another session into the current session.


SYNTAX
Import-PSSession [-Session] <PSSession> [[-CommandName] <string[]>] [[-Form
atTypeName] <string[]>] [-AllowClobber] [-ArgumentList <Object[]>] [-Comman
dType {Alias | Function | Filter | Cmdlet | ExternalScript | Application |
Script | All}] [-Module <string[]>] [-Prefix <string>] [<CommonParameters>]


DESCRIPTION
The Import-PSSession cmdlet imports commands (such as cmdlets, functions, a
nd aliases) from a PSSession on a local or remote computer into the current
session. You can import any command that Get-Command can find in the PSSes
sion.

Use an Import-PSSession command to import commands from a customized shell,
such as a Microsoft Exchange Server shell, or from a session that includes
Windows PowerShell modules and snap-ins or other elements that are not in
the current session.

To import commands, first use the New-PSSession cmdlet to create a PSSessio
n. Then, use the Import-PSSession cmdlet to import the commands. By default
, Import-PSSession imports all commands except for commands that have the s
ame names as commands in the current session. To import all the commands, u
se the AllowClobber parameter.

You can use imported commands just as you would use any command in the sess
ion. When you use an imported command, the imported part of the command run
s implicitly in the session from which it was imported. However, the remote
operations are handled entirely by Windows PowerShell. You need not even b
e aware of them, except that you must keep the connection to the other sess
ion (PSSession) open. If you close it, the imported commands are no longer
available.

Because imported commands might take longer to run than local commands, Imp
ort-PSSession adds an AsJob parameter to every imported command. This param
eter allows you to run the command as a Windows PowerShell background job.
For more information, see about_Jobs.

When you use Import-PSSession, Windows PowerShell adds the imported command
s to a temporary module that exists only in your session and returns an obj
ect that represents the module. To create a persistent module that you can
use in future sessions, use the Export-PSSession cmdlet.

The Import-PSSession cmdlet uses the implicit remoting feature of Windows P
owerShell. When you import commands into the current session, they run impl
icitly in the original session or in a similar session on the originating
computer.

PARAMETERS
-AllowClobber [<SwitchParameter>]
Imports the specified commands, even if they have the same names as com
mands in the current session.

If you import a command with the same name as a command in the current
session, the imported command hides or replaces the original commands.
For more information, see about_Command_Precedence.

By default, Import-PSSession does not import commands that have the sam
e name as commands in the current session.

-ArgumentList <Object[]>
Imports the variant of the command that results from using the specifie
d arguments (parameter values).

For example, to import the variant of the Get-Item command in the certi
ficate (Cert:) drive in the PSSession in $s, type "import-pssession -se
ssion $s -command get-item -argumentlist cert:".

-CommandName <string[]>
Imports only the commands with the specified names or name patterns. Wi
ldcards are permitted. Use "CommandName" or its alias, "Name".

By default, Import-PSSession imports all commands from the session, exc
ept for commands that have the same names as commands in the current se
ssion. This prevents imported commands from hiding or replacing command
s in the session. To import all commands, even those that hide or repla
ce other commands, use the AllowClobber parameter.

If you use the CommandName parameter, the formatting files for the comm
ands are not imported unless you use the FormatTypeName parameter. Simi
larly, if you use the FormatTypeName parameter, no commands are importe
d unless you use the CommandName parameter.

-CommandType <CommandTypes>
Imports only the specified types of command objects. The default value
is Cmdlet. Use "CommandType" or its alias, "Type".

Valid values are:
-- Alias: The Windows PowerShell aliases in the remote session.
-- All: The cmdlets and functions in the remote session.
-- Application: All the files other than Windows-PowerShell files in th
e paths that are listed in the Path environment variable ($env:path) in
the remote session, including .txt, .exe, and .dll files.
-- Cmdlet: The cmdlets in the remote session. "Cmdlet" is the default.
-- ExternalScript: The .ps1 files in the paths listed in the Path envir
onment variable ($env:path) in the remote session.
-- Filter and Function: The Windows PowerShell functions in the remote
session.
-- Script: The script blocks in the remote session.

-FormatTypeName <string[]>
Imports formatting instructions for the specified Microsoft .NET Framew
ork types. Enter the type names. Wildcards are permitted.

The value of this parameter must be the name of a type that is returned
by a Get-FormatData command in the session from which the commands are
being imported. To get all of the formatting data in the remote sessio
n, type *.

If the command does not include either the CommandName or FormatTypeNam
e parameters, Import-PSSession
imports formatting instructions for all .NET Framework types returned b
y a Get-FormatData command in the remote session.

If you use the FormatTypeName parameter, no commands are imported unles
s you use the CommandName parameter.
Similarly, if you use the CommandName parameter, the formatting files f
or the commands are not imported unless you use the FormatTypeName para
meter.

-Module <string[]>
Imports only the commands in the specified Windows PowerShell snap-ins
and modules. Enter the snap-in and module names. Wildcards are not perm
itted.

For more information, see about_PSSnapins and Import-Module.

-Prefix <string>
Adds the specified prefix to the nouns in the names of imported command
s.

Use this parameter to avoid name conflicts that might occur when differ
ent commands in the session have the same name.
For example, if you specify the prefix "Remote" and then import a Get-D
ate cmdlet, the cmdlet is known in the session as Get-RemoteDate and it
is not confused with the original Get-Date cmdlet.

-Session <PSSession>
Specifies the PSSession from which the cmdlets are imported. Enter a va
riable that contains a session object or a command that gets a session
object, such as a New-PSSession or Get-PSSession command. You can speci
fy only one session. This parameter is required.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$s = new-pssession -computername Server01

C:\PS> import-pssession -session $s

Description
-----------
This command imports all commands from a PSSession on the Server01 computer
into the current session, except for commands that have the same names as
commands in the current session.

Because this command does not use the CommandName parameter, it also import
s all of the formatting data required for the imported commands.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$s = new-pssession https://ps.testlabs.com/powershell

C:\PS> import-pssession -session $s -commandname *-test -formatTypeName *

C:\PS> new-test -name test1

C:\PS> get-test test1 | run-test

Description
-----------
These commands import the commands with names that end in "-test" from a PS
Session into the local session, and then they show how to use an imported c
mdlet.

The first command uses the New-PSSession cmdlet to create a PSSession. It s
aves the PSSession in the $s variable.

The second command uses the Import-PSSession cmdlet to import commands from
the PSSession in $s into the current session. It uses the CommandName para
meter to specify commands with the Test noun and the FormatTypeName paramet
er to import the formatting data for the Test commands.

The third and fourth commands use the imported commands in the current sess
ion. Because imported commands are actually added to the current session, y
ou use the local syntax to run them. You do not need to use the Invoke-Comm
and cmdlet to run an imported command.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$s1 = new-pssession -computername s1

C:\PS> $s2 = new-pssession -computername s2

C:\PS> import-pssession -session s1 -type cmdlet -name New-Test, Get-Test -
FormatTypeName *

C:\PS> import-pssession -session s2 -type cmdlet -name Set-Test -FormatType
Name *

C:\PS> new-test Test1 | set-test -runtype full

Description
-----------
This example shows that you can use imported cmdlets just as you would use
local cmdlets.

These commands import the New-Test and Get-Test cmdlets from a PSSession on
the Server01 computer and the Set-Test cmdlet from a PSSession on the Serv
er02 computer.

Even though the cmdlets were imported from different PSSessions, you can pi
pe an object from one cmdlet to another without error.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$s = new-pssession -computername Server01

C:\PS> import-pssession -session $s -commandname *-test* -formattypename *

C:\PS> $batch = new-test -name Batch -asjob

C:\PS> receive-job $batch

Description
-----------
This example shows how to run an imported command as a background job.

Because imported commands might take longer to run than local commands, Imp
ort-PSSession adds an AsJob parameter to every imported command. The AsJob
parameter lets you run the command as a background job.

The first command creates a PSSession on the Server01 computer and saves th
e PSSession object in the $s variable.

The second command uses Import-PSSession to import the Test cmdlets from th
e PSSession in $s into the current session.

The third command uses the AsJob parameter of the imported New-Test cmdlet
to run a New-Test command as a background job. The command saves the job ob
ject that New-Test returns in the $batch variable.

The fourth command uses the Receive-Job cmdlet to get the results of the jo
b in the $batch variable.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>$s = new-pssession -comp Server01

C:\PS> invoke-command -session $s {import-module TestManagement}

C:\PS> import-pssession -session $s -module TestManagement

Description
-----------
This example shows how to import the cmdlets and functions from a Windows P
owerShell module on a remote computer into the current session.

The first command creates a PSSession on the Server01 computer and saves it
in the $s variable.

The second command uses the Invoke-Command cmdlet to run an Import-Module c
ommand in the PSSession in $s.

Typically, the module would be added to all sessions by an Import-Module co
mmand in a Windows PowerShell profile, but profiles are not run in PSSessio
ns.

The third command uses the Module parameter of Import-PSSession to import t
he cmdlets and functions in the module into the current session.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>import-pssession $s -CommandName Get-Date, SearchHelp -formatTypeNam
e * -AllowClobber


Name : tmp_79468106-4e1d-4d90-af97-1154f9317239_tcw1zunz.ttf
Path : C:\Users\User01\AppData\Local\Temp\tmp_79468106-4e1d-4d
90-af97-1154f9317239_tcw1zunz.ttf\tmp_79468106-4e1d-4d90-af97-1154f9317239_
tcw1zunz.ttf.psm1
Description : Implicit remoting for http://server01.corp.fabrikam.com
/wsman
Guid : 79468106-4e1d-4d90-af97-1154f9317239
Version : 1.0
ModuleBase : C:\Users\User01\AppData\Local\Temp\tmp_79468106-4e1d-4d
90-af97-1154f9317239_tcw1zunz.ttf
ModuleType : Script
PrivateData : {ImplicitRemoting}
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {}
ExportedFunctions : {[Get-Date, Get-Date], [SearchHelp, SearchHelp]}
ExportedVariables : {}
NestedModules : {}

Description
-----------
This example shows that Import-PSSession creates a module in a temporary fi
le on disk. It also shows that all commands are converted into functions be
fore they are imported into the current session.

The command uses the Import-PSSession cmdlet to import a Get-Date cmdlet an
d a SearchHelp function into the current session.

The Import-PSSession cmdlet returns a PSModuleInfo object that represents t
he temporary module. The value of the Path property shows that Import-PSSes
sion created a script module (.psm1) file in a temporary location. The Expo
rtedFunctions property shows that the Get-Date cmdlet and the SearchHelp fu
nction were both imported as functions.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>import-pssession $s -CommandName Get-Date -formatTypeName * -AllowClo
bber

C:\PS> get-command get-date

CommandType Name Definition
----------- ---- ----------
Function Get-Date ...
Cmdlet Get-Date Get-Date [[-Date] <DateTime>] [-Year <Int32>] [-Mo
nth <Int32>]

C:\PS> Get-Date
09074

C:\PS> (get-command -type cmdlet -name get-date).pssnapin.name
Microsoft.PowerShell.Utility

C:\PS> Microsoft.PowerShell.Utility\get-date

Sunday, March 15, 2009 2:08:26 PM

Description
-----------
This example shows how to run a command that is hidden by an imported comma
nd.

The first command imports a Get-Date cmdlet from the PSSession in the $s va
riable. Because the current session includes a Get-Date cmdlet, the AllowCl
obber parameter is required in the command.

The second command uses the Get-Command cmdlet to get the Get-Date commands
in the current session. The output shows that the session includes the ori
ginal Get-Date cmdlet and a Get-Date function. The Get-Date function runs t
he imported Get-Date cmdlet in the PSSession in $s.

The third command runs a Get-Date command. Because functions take precedenc
e over cmdlets, Windows PowerShell runs the imported Get-Date function, whi
ch returns a Julian date.

The fourth and fifth commands show how to use a qualified name to run a com
mand that is hidden by an imported command.

The fourth command gets the name of the Windows PowerShell snap-in that add
ed the original Get-Date cmdlet to the current session.

The fifth command uses the snap-in-qualified name of the Get-Date cmdlet to
run a Get-Date command.

For more information about command precedence and hidden commands, see abou
t_Command_Precedence.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>import-pssession -session $s -commandName *Item* -AllowClobber

Description
-----------
This command imports commands whose names include "Item" from the PSSession
in $s. Because the command includes the CommandName parameter but not the
FormatTypeData parameter, only the command is imported.

Use this command when you are using Import-PSSession to run a command on a
remote computer and you already have the formatting data for the command in
the current session.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>$m = import-pssession -session $s -CommandName *bits* -formattypename
*bits*

C:\PS> get-command -module $m

CommandType Name
----------- ----
Function Add-BitsFile
Function Complete-BitsTransfer
Function Get-BitsTransfer
Function Remove-BitsTransfer
Function Resume-BitsTransfer
Function Set-BitsTransfer
Function Start-BitsTransfer
Function Suspend-BitsTransfer

Description
-----------
This command shows how to use the Module parameter of Get-Command to find o
ut which commands were imported into the session by an Import-PSSession com
mand.

The first command uses the Import-PSSession cmdlet to import commands whose
names include "bits" from the PSSession in the $s variable. The Import-PSS
ession command returns a temporary module, and the command saves the module
in the $m variable.

The second command uses the Get-Command cmdlet to get the commands that are
exported by the module in the $m variable.

The Module parameter takes a string value, which is designed for the module
name. However, when you submit a module object, Windows PowerShell uses th
e ToString method on the module object, which returns the module name.

The Get-Command command is the equivalent of "get-command $m.name".




REMARKS
To see the examples, type: "get-help Import-PSSession -examples".
For more information, type: "get-help Import-PSSession -detailed".
For technical information, type: "get-help Import-PSSession -full".

ImportSystemModules

NAME
Invoke-Command

SYNOPSIS
Runs commands on local and remote computers.


SYNTAX
Invoke-Command [-ScriptBlock] <scriptblock> [[-ComputerName] <string[]>] [-
ApplicationName <string>] [-AsJob] [-Authentication {Default | Basic | Nego
tiate | NegotiateWithImplicitCredential | Credssp | Digest | Kerberos}] [-C
ertificateThumbprint <string>] [-ConfigurationName <string>] [-Credential <
PSCredential>] [-HideComputerName] [-JobName <string>] [-Port <int>] [-Sess
ionOption <PSSessionOption>] [-ThrottleLimit <int>] [-UseSSL] [-ArgumentLis
t <Object[]>] [-InputObject <psobject>] [<CommonParameters>]

Invoke-Command [-FilePath] <string> [[-ComputerName] <string[]>] [-Applicat
ionName <string>] [-AsJob] [-Authentication {Default | Basic | Negotiate |
NegotiateWithImplicitCredential | Credssp | Digest | Kerberos}] [-Configura
tionName <string>] [-Credential <PSCredential>] [-HideComputerName] [-JobNa
me <string>] [-Port <int>] [-SessionOption <PSSessionOption>] [-ThrottleLim
it <int>] [-UseSSL] [-ArgumentList <Object[]>] [-InputObject <psobject>] [<
CommonParameters>]

Invoke-Command [-FilePath] <string> [[-Session] <PSSession[]>] [-AsJob] [-H
ideComputerName] [-JobName <string>] [-ThrottleLimit <int>] [-ArgumentList
<Object[]>] [-InputObject <psobject>] [<CommonParameters>]

Invoke-Command [-FilePath] <string> [[-ConnectionURI] <Uri[]>] [-AllowRedir
ection] [-AsJob] [-Authentication {Default | Basic | Negotiate | NegotiateW
ithImplicitCredential | Credssp | Digest | Kerberos}] [-ConfigurationName <
string>] [-Credential <PSCredential>] [-HideComputerName] [-JobName <string
>] [-SessionOption <PSSessionOption>] [-ThrottleLimit <int>] [-ArgumentList
<Object[]>] [-InputObject <psobject>] [<CommonParameters>]

Invoke-Command [-ScriptBlock] <scriptblock> [-ArgumentList <Object[]>] [-In
putObject <psobject>] [<CommonParameters>]

Invoke-Command [-ScriptBlock] <scriptblock> [[-Session] <PSSession[]>] [-As
Job] [-HideComputerName] [-JobName <string>] [-ThrottleLimit <int>] [-Argum
entList <Object[]>] [-InputObject <psobject>] [<CommonParameters>]

Invoke-Command [-ScriptBlock] <scriptblock> [[-ConnectionURI] <Uri[]>] [-Al
lowRedirection] [-AsJob] [-Authentication {Default | Basic | Negotiate | Ne
gotiateWithImplicitCredential | Credssp | Digest | Kerberos}] [-Certificate
Thumbprint <string>] [-ConfigurationName <string>] [-Credential <PSCredenti
al>] [-HideComputerName] [-JobName <string>] [-SessionOption <PSSessionOpti
on>] [-ThrottleLimit <int>] [-ArgumentList <Object[]>] [-InputObject <psobj
ect>] [<CommonParameters>]


DESCRIPTION
The Invoke-Command cmdlet runs commands on a local or remote computer and r
eturns all output from the commands, including errors. With a single Invoke
-Command command, you can run commands on multiple computers.

To run a single command on a remote computer, use the ComputerName paramete
r. To run a series of related commands that share data, create a PSSession
(a persistent connection) on the remote computer, and then use the Session
parameter of Invoke-Command to run the command in the PSSession.

You can also use Invoke-Command on a local computer to evaluate or run a st
ring in a script block as a command. Windows PowerShell converts the script
block to a command and runs the command immediately in the current scope,
instead of just echoing the string at the command line.

Before using Invoke-Command to run commands on a remote computer, read abou
t_Remote.

PARAMETERS
-AllowRedirection [<SwitchParameter>]
Allows redirection of this connection to an alternate URI.

When you use the ConnectionURI parameter, the remote destination can re
turn an instruction to redirect to a different URI. By default, Windows
PowerShell does not redirect connections, but you can use the AllowRed
irection parameter to allow it to redirect the connection.

You can also limit the number of times that the connection is redirecte
d by setting the MaximumConnectionRedirectionCount property of the $PSS
essionOption preference variable, or the MaximumConnectionRedirectionCo
unt property of the value of the SessionOption parameter. The default v
alue is 5. For more information, see the description of the SessionOpti
on parameter and the help topic for the New-PSSessionOption cmdlet.

-ApplicationName <string>
Specifies the application name segment of the connection URI. Use this
parameter to specify the application name when you are not using the Co
nnectionURI parameter in the command.

The default value is the value of the $PSSessionApplicationName prefere
nce variable on the local computer. If this preference variable is not
defined, the default value is WSMAN. This value is appropriate for most
uses. For more information, see about_Preference_Variables.

The WinRM service uses the application name to select a listener to ser
vice the connection request. The value of this parameter should match t
he value of the URLPrefix property of a listener on the remote computer
.

-ArgumentList <Object[]>
Supplies the values of local variables in the command. The variables in
the command are replaced by these values before the command is run on
the remote computer. Enter the values in a comma-separated list. Values
are associated with variables in the order that they are listed. The a
lias for ArgumentList is "Args".

The values in ArgumentList can be actual values, such as "1024", or the
y can be references to local variables, such as "$max".

To use local variables in a command, use the following command format:
{param($<name1>[, $<name2>]...) <command-with-local-variables>} -Argume
ntList <value | $local-variable>

The "param" keyword lists the local variables that are used in the comm
and. The ArgumentList parameter supplies the values of the variables, i
n the order that they are listed.

-AsJob [<SwitchParameter>]
Runs the command as a background job on a remote computer. Use this par
ameter to run commands that take an extensive time to complete.

When you use AsJob, the command returns an object that represents the j
ob, and then displays the command prompt. You can continue to work in t
he session while the job completes. To manage the job, use the Job cmd
lets. To get the job results, use Receive-Job.

The AsJob parameter is similar to using Invoke-Command to run a Start-J
ob command remotely. However, with AsJob, the job is created on the loc
al computer, even though the job runs on a remote computer, and the res
ults of the remote job are automatically returned to the local computer
.

For more information about Windows PowerShell background jobs, see abou
t_Jobs and about_Remote_Jobs.

-Authentication <AuthenticationMechanism>
Specifies the mechanism that is used to authenticate the user's credent
ials. Valid values are Default, Basic, Credssp, Digest, Kerberos, Neg
otiate, and NegotiateWithImplicitCredential. The default value is Defa
ult.

CredSSP authentication is available only in Windows Vista, Windows Serv
er 2008, and later versions of Windows.

For information about the values of this parameter, see the description
of the System.Management.Automation.Runspaces.AuthenticationMechanism
enumeration in MSDN.

CAUTION: Credential Security Service Provider (CredSSP) authentication,
in which the user's credentials are passed to a remote computer to be
authenticated, is designed for commands that require authentication on
more than one resource, such as accessing a remote network share. This
mechanism increases the security risk of the remote operation. If the r
emote computer is compromised, the credentials that are passed to it ca
n be used to control the network session.

-CertificateThumbprint <string>
Specifies the digital public key certificate (X509) of a user account t
hat has permission to perform this action. Enter the certificate thumbp
rint of the certificate.

Certificates are used in client certificate-based authentication. They
can only be mapped to local user accounts; they do not work with domain
accounts.

To get a certificate thumbprint, use the Get-Item or Get-ChildItem comm
ands in the Windows PowerShell Cert: drive.

-ComputerName <string[]>
Specifies the computers on which the command runs. The default is the l
ocal computer.

When you use the ComputerName parameter, Windows PowerShell creates a t
emporary connection that is used only to run the specified command and
is then closed. If you need a persistent connection, use the Session pa
rameter.

Type the NETBIOS name, IP address, or fully-qualified domain name of on
e or more computers in a comma-separated list. To specify the local com
puter, type the computer name, "localhost", or a dot (.).

To use an IP address in the value of the ComputerName parameter, the co
mmand must include the Credential parameter. Also, the computer must be
configured for HTTPS transport or the IP address of the remote compute
r must be included in the WinRM TrustedHosts list on the local computer
. For instructions for adding a computer name to the TrustedHosts list,
see "How to Add a Computer to the Trusted Host List" in about_Remote_
Troubleshooting.

Note: On Windows Vista, and later versions of Windows, to include the
local computer in the value of the ComputerName parameter, you must ope
n Windows PowerShell with the "Run as administrator" option.

-ConfigurationName <string>
Specifies the session configuration that is used for the new PSSession.


Enter a configuration name or the fully qualified resource URI for a se
ssion configuration. If you specify only the configuration name, the fo
llowing schema URI is prepended: http://schemas.microsoft.com/powershe
ll.

The session configuration for a session is located on the remote comput
er. If the specified session configuration does not exist on the remote
computer, the command fails.

The default value is the value of the $PSSessionConfigurationName prefe
rence variable on the local computer. If this preference variable is no
t set, the default is Microsoft.PowerShell. For more information, see a
bout_preference_variables.

-ConnectionURI <Uri[]>
Specifies a Uniform Resource Identifier (URI) that defines the connecti
on endpoint. The URI must be fully qualified.

The format of this string is:
<Transport>://<ComputerName>:<Port>/<ApplicationName>

The default value is:
http://localhost:80/WSMAN

Valid values for the Transport segment of the URI are HTTP and HTTPS. I
f you do not specify a ConnectionURI, you can use the UseSSL, ComputerN
ame, Port, and ApplicationName parameters to specify the URI values.

If the destination computer redirects the connection to a different URI
, Windows PowerShell prevents the redirection unless you use the AllowR
edirection parameter in the command.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a var
iable that contains a PSCredential object, such as one generated by the
Get-Credential cmdlet. When you type a user name, you will be prompted
for a password.

-FilePath <string>
Runs the specified local script on one or more remote computers. Enter
the path and file name of the script, or pipe a script path to Invoke-C
ommand. The script must reside on the local computer or in a directory
that the local computer can access. Use the ArgumentList parameter to s
pecify the values of parameters in the script.

When you use this parameter, Windows PowerShell converts the contents o
f the specified script file to a script block, transmits the script blo
ck to the remote computer, and runs it on the remote computer.

-HideComputerName [<SwitchParameter>]
Omits the computer name of each object from the output display. By defa
ult, the name of the computer that generated the object appears in the
display.

This parameter affects only the output display. It does not change the
object.

-InputObject <psobject>
Specifies input to the command. Enter a variable that contains the obje
cts or type a command or expression that gets the objects.

When using InputObject, use the $input automatic variable in the value
of the ScriptBlock parameter to represent the input objects.

-JobName <string>
Specifies a friendly name for the background job. By default, jobs are
named "Job<n>", where <n> is an ordinal number. This parameter is vali
d only with the AsJob parameter.

If you use the JobName parameter in a command, the command is run as a
job, and Invoke-Command returns a job object, even if you do not includ
e the AsJob parameter in the command.

For more information about Windows PowerShell background jobs, see abou
t_Jobs.

-Port <int>
Specifies the network port on the remote computer used for this comman
d. The default is port 80 (the HTTP port).

Before using an alternate port, you must configure the WinRM listener o
n the remote computer to listen at that port. To configure the listener
, type the following two commands at the Windows PowerShell prompt:

remove-item -path wsman:\Localhost\listener\listener* -recurse
new-item -path wsman:\Localhost\listener -Transport http -Address * -po
rt <port-number>

Do not use the Port parameter unless you must. The Port set in the comm
and applies to all computers or sessions on which the command runs. An
alternate port setting might prevent the command from running on all co
mputers.

-ScriptBlock <scriptblock>
Specifies the commands to run. Enclose the commands in curly braces ( {
} ) to create a script block. This parameter is required.

By default, any variables in the command are evaluated on the remote co
mputer. To include local variables in the command, use the ArgumentList
parameter.

-Session <PSSession[]>
Runs the command in the specified Windows PowerShell sessions (PSSessio
ns). Enter a variable that contains the PSSessions or a command that cr
eates or gets the PSSessions, such as a New-PSSession or Get-PSSession
command.

When you create a PSSession, Windows PowerShell establishes a persisten
t connection to the remote computer. Use a PSSession to run a series of
related commands that share data. To run a single command or a series
of unrelated commands, use the ComputerName parameter.

To create a PSSession, use the New-PSSession cmdlet. For more informati
on, see about_PSSessions.

-SessionOption <PSSessionOption>
Sets advanced options for the session. Enter a SessionOption object tha
t you create by using the New-PSSessionOption cmdlet.

The default values for the options are determined by the value of the $
PSSessionOption preference variable, if it is set. Otherwise, the sessi
on uses the system defaults.

For a description of the session options, including the default values,
see the help topic for the New-PSSessionOption cmdlet. For information
about the $PSSessionOption preference variable, see about_Preference_V
ariables.

-ThrottleLimit <int>
Specifies the maximum number of concurrent connections that can be esta
blished to run this command. If you omit this parameter or enter a valu
e of 0, the default value, 32, is used.

The throttle limit applies only to the current command, not to the sess
ion or to the computer.

-UseSSL [<SwitchParameter>]
Uses the Secure Sockets Layer (SSL) protocol to establish a connection
to the remote computer. By default, SSL is not used.

WS-Management encrypts all Windows PowerShell content transmitted over
the network. UseSSL is an additional protection that sends the data acr
oss an HTTPS, instead of HTTP.

If you use this parameter, but SSL is not available on the port used fo
r the command, the command fails.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>invoke-command -filepath c:\scripts\test.ps1 -computerName Server01

Disks: C:, D:, E:
Status: Warning, Normal, Normal

Description
-----------
This command runs the Test.ps1 script on the Server01 computer.

The command uses the FilePath parameter to specify a script that is located
on the local computer. The script runs on the remote computer and the resu
lts are returned to the local computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>invoke-command -computername server01 -credential domain01\user01 -sc
riptblock {get-culture}

Description
-----------
This command runs a Get-Culture command on the Server01 remote computer.

It uses the ComputerName parameter to specify the computer name and the Cre
dential parameter to run the command in the security context of "Domain01\U
ser01," a user with permission to run commands. It uses the ScriptBlock par
ameter to specify the command to be run on the remote computer.

In response, Windows PowerShell displays a dialog box that requests the pas
sword and an authentication method for the User01 account. It then runs the
command on the Server01 computer and returns the result.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$s = new-pssession -computername server02 -credential domain01\user01

C:\PS> invoke-command -session $s -scriptblock {get-culture}

Description
-----------
This example runs the same "Get-Culture" command in a session (a persistent
connection) on the Server02 remote computer. Typically, you create a sessi
on only when you are running a series of commands on the remote computer.

The first command uses the New-PSSession cmdlet to create a session on the
Server02 remote computer. Then, it saves the session in the $s variable.

The second command uses the Invoke-Command cmdlet to run the Get-Culture co
mmand on Server02. It uses the Session parameter to specify the session sa
ved in the $s variable.

In response, Windows PowerShell runs the command in the session on the Serv
er02 computer.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>invoke-command -computername Server02 -scriptblock {$p = get-process
powershell}

C:\PS> invoke-command -computername Server02 -scriptblock {$p.virtualmemory
size}
C:\PS>

C:\PS> $s = new-pssession -computername Server02
C:\PS> invoke-command -session $s -scriptblock {$p = get-process powershell
}
C:\PS> invoke-command -session $s -scriptblock {$p.virtualmemorysize}
17930240

Description
-----------
This example compares the effects of using ComputerName and Session paramet
ers of Invoke-Command. It shows how to use a session to run a series of com
mands that share the same data.

The first two commands use the ComputerName parameter of Invoke-Command to
run commands on the Server02 remote computer. The first command uses the Ge
t-Process command to get the PowerShell process on the remote computer and
to save it in the $p variable. The second command gets the value of the Vir
tualMemorySize property of the PowerShell process.

The first command succeeds. But, the second command fails because when you
use the ComputerName parameter, Windows PowerShell creates a connection jus
t to run the command. Then, it closes the connection when the command is co
mplete. The $p variable was created in one connection, but it does not exis
t in the connection created for the second command.

The problem is solved by creating a session (a persistent connection) on th
e remote computer and by running both of the related commands in the same s
ession.

The third command uses the New-PSSession cmdlet to create a session on the
Server02 computer. Then it saves the session in the $s variable. The fourth
and fifth commands repeat the series of commands used in the first set, bu
t in this case, the Invoke-Command command uses the Session parameter to ru
n both of the commands in the same session.

In this case, because both commands run in the same session, the commands s
ucceed, and the $p value remains active in the $s session for later use.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>$command = { get-eventlog -log "windows powershell" | where {$_.messa
ge -like "*certificate*"} }

C:\PS> invoke-command -computername S1, S2 -scriptblock $command

Description
-----------
This example shows how to enter a command that is saved in a local variable
.

When the entire command is saved in a local variable, you can specify the v
ariable as the value of the ScriptBlock parameter. You do not have to use t
he "param" keyword or the ArgumentList variable to submit the value of the
local variable.

The first command saves a Get-Eventlog command in the $command variable. Th
e command is formatted as a script block.

The second command uses the Invoke-Command cmdlet to run the command in $co
mmand on the S1 and S2 remote computers.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>invoke-command -computername server01, server02, TST-0143, localhost
-configurationname MySession.PowerShell -scriptblock {get-eventlog "windows
powershell"}

Description
-----------
This example demonstrates how to use the Invoke-Command cmdlet to run a sin
gle command on multiple computers.

The command uses the ComputerName parameter to specify the computers. The c
omputer names are presented in a comma-separated list. The list of computer
s includes the "localhost" value, which represents the local computer.

The command uses the ConfigurationName parameter to specify an alternate se
ssion configuration for Windows PowerShell and the ScriptBlock parameter to
specify the command.

In this example, the command in the script block gets the events in the Win
dows PowerShell event log on each remote computer.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>$version = invoke-command -computername (get-content machines.txt) -s
criptblock {(get-host).version}

Description
-----------
This command gets the version of the Windows PowerShell host running on 200
remote computers.

Because only one command is run, it is not necessary to create persistent c
onnections (sessions) to each of the computers. Instead, the command uses t
he ComputerName parameter to indicate the computers.

The command uses the Invoke-Command cmdlet to run a Get-Host command. It us
es dot notation to get the Version property of the Windows PowerShell host.

To specify the computers, it uses the Get-Content cmdlet to get the content
s of the Machine.txt file, a file of computer names.

These commands run synchronously (one at a time). When the commands complet
e, the output of the commands from all of the computers is saved in the $ve
rsion variable. The output includes the name of the computer from which the
data originated.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>$s = new-pssession -computername Server01, Server02

C:\PS> invoke-command -session $s -scriptblock {get-eventlog system} -AsJob

Id Name State HasMoreData Location Command
--- ---- ----- ----- ----------- --------
-------
1 Job1 Running True Server01,Server02 get-eventlog syste
m


C:\PS> $j = Get-Job

C:\PS> $j | format-list -property *

HasMoreData : True
StatusMessage :
Location : Server01,Server02
Command : get-eventlog system
JobStateInfo : Running
Finished : System.Threading.ManualResetEvent
InstanceId : e124bb59-8cb2-498b-a0d2-2e07d4e030ca
Id : 1
Name : Job1
ChildJobs : {Job2, Job3}
Output : {}
Error : {}
Progress : {}
Verbose : {}
Debug : {}
Warning : {}
StateChanged :

C:\PS> $results = $j | Receive-Job

Description
-----------
These commands run a background job on two remote computers. Because the In
voke-Command command uses the AsJob parameter, the commands run on the remo
te computers, but the job actually resides on the local computer and the re
sults are transmitted to the local computer.

The first command uses the New-PSSession cmdlet to create sessions on the S
erver01 and Server02 remote computers.

The second command uses the Invoke-Command cmdlet to run a background job i
n each of the sessions. The command uses the AsJob parameter to run the com
mand as a background job. This command returns a job object that contains t
wo child job objects, one for each of the jobs run on the two remote comput
ers.

The third command uses a Get-Job command to save the job object in the $j v
ariable.

The fourth command uses a pipeline operator (|) to send the value of the $j
variable to the Format-List cmdlet, which displays all properties of the j
ob object in a list.

The fifth command gets the results of the jobs. It pipes the job object in
$j to the Receive-Job cmdlet and stores the results in the $results variabl
e.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>$MWFO-LOg = Microsoft-Windows-Forwarding/Operational

C:\PS> invoke-command -computername server01 -scriptblock {param($log, $num
) get-eventlog -logname $log -newest $num} -ArgumentList $MWFO-log, 10

Description
-----------
This example shows how to include the values of local variables in a comman
d run on a remote computer.

The first command saves the name of the Microsoft-Windows-Forwarding/Operat
ional event log in the $MWFO-Log variable.

The second command uses the Invoke-Command cmdlet to run a Get-EventLog com
mand on the Server01 remote computer that gets the 10 newest events from th
e Microsoft-Windows-Forwarding/Operational event log on Server01.

This command uses the "param" keyword to create two variables, $log and $nu
m, that are used as placeholders in the Get-EventLog command. These placeho
lders have arbitrary names that do not need to match the names of the local
variables that supply their values.

The values of the ArgumentList parameter demonstrate the two different ways
to specify values in the argument list. The value of the $log placeholder
is the $MFWO-Log variable, which is defined in the first command. The value
of the $num variable is 10.

Before the command is sent to the remote computer, the variables are replac
ed with the specified values.




-------------------------- EXAMPLE 10 --------------------------

C:\PS>invoke-command -computername S1, S2 -scriptblock {get-process powersh
ell}

PSComputerName Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id
ProcessName
-------------- ------- ------ ----- ----- ----- ------ --
-----------
S1 575 15 45100 40988 200 4.68 13
92 powershell
S2 777 14 35100 30988 150 3.68 67
powershell


C:\PS> invoke-command -computername S1, S2 -scriptblock {get-process powers
hell} -HideComputerName

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
575 15 45100 40988 200 4.68 1392 powershell
777 14 35100 30988 150 3.68 67 powershell

Description
-----------
This example shows the effect of using the HideComputerName parameter of In
voke-Command.

The first two commands use the Invoke-Command cmdlet to run a Get-Process c
ommand for the PowerShell process. The output of the first command includes
the PsComputerName property, which contains the name of the computer on wh
ich the command ran. The output of the second command, which uses the HideC
omputerName parameter, does not include the PsComputerName column.

Using the HideComputerName parameter does not change the object. You can st
ill use the Format cmdlets to display the PsComputerName property of any of
the affected objects.




-------------------------- EXAMPLE 11 --------------------------

C:\PS>invoke-command -comp (get-content servers.txt) -filepath c:\scripts\s
ample.ps1 -argumentlist Process, Service

Description
-----------
This example uses the Invoke-Command cmdlet to run the Sample.ps1 script on
all of the computers listed in the Servers.txt file. The command uses the
FilePath parameter to specify the script file. This command allows you to r
un the script on the remote computers, even if the script file is not acces
sible to the remote computers.

When you submit the command, the content of the Sample.ps1 file is copied i
nto a script block and the script block is run on each of the remote comput
ers. This procedure is equivalent to using the ScriptBlock parameter to sub
mit the contents of the script.




-------------------------- EXAMPLE 12 --------------------------

C:\PS>$LiveCred = Get-Credential

C:\PS> Invoke-Command -ConfigurationName Microsoft.Exchange `
-ConnectionUri https://ps.exchangelabs.com/powershell `
-Credential $LiveCred -Authentication Basic `
-scriptblock {Invoke-Command {Set-Mailbox dan -DisplayName "Dan Pa
rk"}

Description
-----------
This example shows how to run a command on a remote computer that is identi
fied by a URI (Internet address). This particular example runs a Set-Mailbo
x command on a remote Exchange server. The backtick (`) in the command is t
he Windows PowerShell continuation character.

The first command uses the Get-Credential cmdlet to store Windows Live ID c
redentials in the $LiveCred variab the credentials dialog box appears, ente
r Windows Live ID credentials.

The second command uses the Invoke-Command cmdlet to run a Set-Mailbox comm
and. The command uses the ConfigurationName parameter to specify that the c
ommand should run in a session that uses the Microsoft.Exchange session con
figuration. The ConnectionURI parameter specifies the URL of the Exchange s
erver endpoint.

The credential parameter specifies tle. Whenhe Windows Live credentials sto
red in the $LiveCred variable. The AuthenticationMechanism parameter specif
ies the use of basic authentication. The ScriptBlock parameter specifies a
script block that contains the command.




-------------------------- EXAMPLE 13 --------------------------

C:\PS>$max = New-PSSessionOption -MaximumRedirection 1

C:\PS> Invoke-Command -ConnectionUri https://ps.exchangelabs.com/powershell
`
-scriptblock {Invoke-Command {Get-Mailbox dan} `
-AllowRedirection -SessionOption $max

Description
-----------
This command shows how to use the AllowRedirection and SessionOption parame
ters to manage URI redirection in a remote command.

The first command uses the New-PSSessionOption cmdlet to create a PSSession
Opption object that it saves in the $max variable. The command uses the Max
imumRedirection parameter to set the MaximumConnectionRedirectionCount prop
erty of the PSSessionOption object to 1.

The second command uses the Invoke-Command cmdlet to run a Get-Mailbox comm
and on a remote server running Microsoft Exchange Server. The command uses
the AllowRedirection parameter to provide explicit permission to redirect t
he connection to an alternate endpoint. It also uses the SessionOption para
meter to specify the session object in the $max variable.

As a result, if the remote computer specified by the ConnectionURI paramete
r returns a redirection message, Windows PowerShell will redirect the conne
ction, but if the new destination returns another redirection message, the
redirection count value of 1 is exceeded, and Invoke-Command returns a non-
terminating error.




-------------------------- EXAMPLE 14 --------------------------

C:\PS>$so = New-PSSessionOption -SkipCACheck

PS C:\> invoke-command $s { get-hotfix } -SessionOption $so -credential ser
ver01\user01

Description
-----------
This example shows how to create and use a SessionOption parameter.

The first command uses the New-PSSessionOption cmdlet to create a session o
ption. It saves the resulting SessionOption object in the $so parameter.

The second command uses the Invoke-Command cmdlet to run a Get-Hotfix comma
nd remotely. The value of the SessionOption parameter is the SessionOption
object in the $so variable.




-------------------------- EXAMPLE 15 --------------------------

C:\PS>enable-wsmanCredSSP -delegate server02

C:\PS> connect-wsman Server02

C:\PS> set-item wsman:\server02*\service\auth\credSSP -value $true

C:\PS> $s = new-pssession server02

C:\PS> invoke-command -session $s -script {get-item \\Net03\Scripts\LogFile
s.ps1} -authentication credssp -credential domain01\admin01

Description
-----------
This example shows how to access a network share from within a remote sessi
on.

The command requires that CredSSP delegation be enabled in the client setti
ngs on the local computer and in the service settings on the remote compute
r. To run the commands in this example, you must be a member of the Adminis
trators group on the local computer and the remote computer.

The first command uses the Enable-WSManCredSSP cmdlet to enable CredSSP del
egation from the Server01 local computer to the Server02 remote computer. T
his configures the CredSSP client setting on the local computer.

The second command uses the Connect-WSman cmdlet to connect to the Server02
computer. This action adds a node for the Server02 computer to the WSMan:
drive on the local computer, allowing you to view and change the WS-Managem
ent settings on the Server02 computer.

The third command uses the Set-Item cmdlet to change the value of the CredS
SP item in the Service node of the Server02 computer to True. This action e
nables CredSSP in the service settings on the remote computer.

The fourth command uses the New-PSSession cmdlet to create a PSSession on t
he Server02 computer. It saves the PSSession in the $s variable.

The fifth command uses the Invoke-Command cmdlet to run a Get-Item command
in the session in $s that gets a script from the Net03\Scripts network shar
e. The command uses the Credential parameter and it uses the Authentication
parameter with a value of CredSSP.




REMARKS
To see the examples, type: "get-help Invoke-Command -examples".
For more information, type: "get-help Invoke-Command -detailed".
For technical information, type: "get-help Invoke-Command -full".

NAME
Invoke-Expression

SYNOPSIS
Runs commands or expressions on the local computer.


SYNTAX
Invoke-Expression [-Command] <string> [<CommonParameters>]


DESCRIPTION
The Invoke-Expression cmdlet evaluates or runs a specified string as a comm
and and returns the results of the expression or command. Without Invoke-Ex
pression, a string submitted at the command line would be returned (echoed)
unchanged.

PARAMETERS
-Command <string>
Specifies the command or expression to run. Type the command or express
ion or enter a variable that contains the command or expression. The Co
mmand parameter is required.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$command = "Get-Process"

C:\PS> $command
Get-Process


C:\PS> invoke-expression $command

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
296 4 1572 1956 20 0.53 1348 AdtAgent
270 6 1328 800 34 0.06 2396 alg
67 2 620 484 20 0.22 716 ati2evxx
1060 15 12904 11840 74 11.48 892 CcmExec
1400 33 25280 37544 223 38.44 2564 communicator
...

Description
-----------
This example demonstrates the use of Invoke-Expression to evaluate an expre
ssion. Without Invoke-Expression, the expression is printed, but not evalua
ted.

The first command assigns a value of "Get-Process" (a string) to the $comma
nd variable.

The second command shows the effect of typing the variable name at the comm
and line. Windows PowerShell echoes the string.

The third command uses Invoke-Expression to evaluate the string.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>invoke-expression -command "C:\ps-test\testscript.ps1"

C:\PS> "C:\ps-test\testscript.ps1" | invoke-expression

Description
-----------
These commands use Invoke-Expression to run a script, TestScript.ps1, on th
e local computer. The two commands are equivalent. The first uses the Comma
nd parameter to specify the command to run. The second uses a pipeline oper
ator (|) to send the command string to Invoke-Expression.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$cmd = 'get-process | where {$_.cpu -gt 1000}'

C:\PS> iex $command

Description
-----------
This example runs a command string that is saved in the $cmd variable.

The command string is enclosed in single quotation marks because it include
s a variable, $_, which represents the current object. If it were enclosed
in double quotation marks, the $_ variable would be replaced by its value b
efore it was saved in the $command string.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$cmdlet_name = "get-eventlog"

C:\PS> $example_number = 1

C:\PS> $example_code = (get-help $cmdlet_name).examples.example[($example_n
umber-1)].code

C:\PS> invoke-expression $example_code

Description
-----------
This command retrieves and runs the first example in the Get-EventLog cmdle
t help topic.

To run an example of a different cmdlet, change the value of the $cmdlet_na
me variable to the name of the cmdlet. And, change the $example_number vari
able to the example number you want to run. The command will fail if the ex
ample number is not valid.




REMARKS
To see the examples, type: "get-help Invoke-Expression -examples".
For more information, type: "get-help Invoke-Expression -detailed".
For technical information, type: "get-help Invoke-Expression -full".

NAME
Invoke-History

SYNOPSIS
Runs commands from the session history.


SYNTAX
Invoke-History [[-Id] <string>] [-Confirm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Invoke-History cmdlet runs commands from the session history. You can p
ass objects representing the commands from Get-History to Invoke-History, o
r you can identify commands in the current history by using their ID number
. To find the identification number of a command, use Get-History.

PARAMETERS
-Id <string>
Identifies a command in the history. You can type the ID number of the
command or the first few characters of the command.

If you type characters, Invoke-History matches the most recent commands
first. If you omit this parameter, Invoke-History runs the last (most
recent) command. The parameter name ("id") is optional. To find the ID
number of a command, use Get-History.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>invoke-history

Description
-----------
This command runs the last (most recent) command in the session history. Yo
u can abbreviate this command as "r" (think "repeat" or "rerun"), the alias
for Invoke-History.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>invoke-history -id 132

Description
-----------
This command runs the command in the session history with ID 132. Because t
he name of the Id parameter is optional, you can abbreviate this command as
"Invoke-History 132", "ihy 132", or "r 132".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>invoke-history get-pr

Description
-----------
This command runs the most recent Get-Process command in the session histor
y. When you type characters for the Id parameter, Invoke-History runs the f
irst command that it finds that matches the pattern, beginning with the mos
t recent commands. This command uses the ID parameter, but it omits the opt
ional parameter name.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>invoke-history (16..24), 27

Description
-----------
This command runs commands 16 through 24 and 27. You can list multiple IDs
and ID ranges separated by commas.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-history -id 255 -count 7 | invoke-history

Description
-----------
This command runs the 7 commands in the history that end with command 255 (
typically 249 through 255). It uses the Get-History cmdlet to retrieve the
commands. The pipeline operator (|) passes the commands to Invoke-History,
which executes them.




REMARKS
To see the examples, type: "get-help Invoke-History -examples".
For more information, type: "get-help Invoke-History -detailed".
For technical information, type: "get-help Invoke-History -full".

NAME
Invoke-Item

SYNOPSIS
Performs the default action on the specified item.


SYNTAX
Invoke-Item [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Exclud
e <string[]>] [-Filter <string>] [-Include <string[]>] [-Confirm] [-WhatIf]
[-UseTransaction] [<CommonParameters>]

Invoke-Item [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <stri
ng[]>] [-Filter <string>] [-Include <string[]>] [-Confirm] [-WhatIf] [-UseT
ransaction] [<CommonParameters>]


DESCRIPTION
The Invoke-Item cmdlet performs the default action on the specified item. F
or example, it runs an executable file or opens a document file in the appl
ication associated with the document file type. The default action depends
on the type of item and is determined by the Windows PowerShell provider th
at provides access to the data.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects rather than having Windows PowerShell filter
the objects after they are retrieved.

-Include <string[]>
Performs the default action only on the specified items. The value of t
his parameter qualifies the Path parameter. Enter a path element or pat
tern, such as "*.txt". Wildcards are permitted.

-LiteralPath <string[]>
Specifies a path to the item. The value of LiteralPath is used exactly
as it is typed. No characters are interpreted as wildcards. If the path
includes escape characters, enclose it in single quotation marks. Sing
le quotation marks tell Windows PowerShell not to interpret any charact
ers as escape sequences.

-Path <string[]>
Specifies the path to the selected item.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>invoke-item C:\Test\aliasApr04.doc

Description
-----------
This command opens the file aliasApr04.doc in Microsoft Office Word. In thi
s case, opening in Word is the default action for .doc files.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>invoke-item "C:\Documents and Settings\Lister\My Documents\*.xls"

Description
-----------
This command opens all of the Microsoft Office Excel spreadsheets in the C:
\Documents and Settings\Lister\My Documents folder. Each spreadsheet is ope
ned in a new instance of Excel. In this case, opening in Excel is the defau
lt action for .xls files.




REMARKS
To see the examples, type: "get-help Invoke-Item -examples".
For more information, type: "get-help Invoke-Item -detailed".
For technical information, type: "get-help Invoke-Item -full".

NAME
Invoke-WmiMethod

SYNOPSIS
Calls Windows Management Instrumentation (WMI) methods.


SYNTAX
Invoke-WmiMethod [-Class] <string> [[-ArgumentList] <Object[]>] [-Authentic
ation {Default | None | Connect | Call | Packet | PacketIntegrity | PacketP
rivacy | Unchanged}] [-Authority <string>] [-ComputerName <string[]>] [-Cre
dential <PSCredential>] [-EnableAllPrivileges] [-Impersonation {Default | A
nonymous | Identify | Impersonate | Delegate}] [-Locale <string>] [-Namespa
ce <string>] [-Name] <string> [-AsJob] [-ThrottleLimit <int>] [-Confirm] [-
WhatIf] [<CommonParameters>]

Invoke-WmiMethod [-Authentication {Default | None | Connect | Call | Packet
| PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority <string>] [-Co
mputerName <string[]>] [-Credential <PSCredential>] [-EnableAllPrivileges]
[-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}]
[-Locale <string>] [-Namespace <string>] [-Name] <string> [-AsJob] [-Thrott
leLimit <int>] [-Confirm] [-WhatIf] [<CommonParameters>]

Invoke-WmiMethod -InputObject <ManagementObject> [-ArgumentList <Object[]>]
[-Name] <string> [-AsJob] [-ThrottleLimit <int>] [-Confirm] [-WhatIf] [<Co
mmonParameters>]

Invoke-WmiMethod -Path <string> [-ArgumentList <Object[]>] [-Authentication
{Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivac
y | Unchanged}] [-Authority <string>] [-ComputerName <string[]>] [-Credenti
al <PSCredential>] [-EnableAllPrivileges] [-Impersonation {Default | Anonym
ous | Identify | Impersonate | Delegate}] [-Locale <string>] [-Namespace <s
tring>] [-Name] <string> [-AsJob] [-ThrottleLimit <int>] [-Confirm] [-WhatI
f] [<CommonParameters>]

Invoke-WmiMethod [-Authentication {Default | None | Connect | Call | Packet
| PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority <string>] [-Co
mputerName <string[]>] [-Credential <PSCredential>] [-EnableAllPrivileges]
[-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}]
[-Locale <string>] [-Namespace <string>] [-Name] <string> [-AsJob] [-Thrott
leLimit <int>] [-Confirm] [-WhatIf] [<CommonParameters>]

Invoke-WmiMethod [-Authentication {Default | None | Connect | Call | Packet
| PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority <string>] [-Co
mputerName <string[]>] [-Credential <PSCredential>] [-EnableAllPrivileges]
[-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}]
[-Locale <string>] [-Namespace <string>] [-Name] <string> [-AsJob] [-Thrott
leLimit <int>] [-Confirm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Invoke-WmiMethod cmdlet calls WMI methods.

PARAMETERS
-ArgumentList <Object[]>
Specifies the parameters to pass to the called method. The value of thi
s parameter must be an array of objects and they must appear in the ord
er required by the called method.

Important: A second value of $null is required, otherwise the command w
ill generate an error, such as "Unable to cast object of type 'System.B
yte' to type 'System.Array'.".

An example using an array of objects ($binSD) followed by a null value
($null) follows:

PS C:\> $acl = get-acl test.txt
PS C:\> $binSD = $acl.GetSecurityDescriptorBinaryForm()
PS C:\> invoke-wmimethod -class Win32_SecurityDescriptorHelper -Name Bi
narySDToSDDL -argumentlist $binSD, $null

-AsJob [<SwitchParameter>]
Runs the command as a background job. Use this parameter to run command
s that take a long time to finish.

When you use the AsJob parameter, the command returns an object that re
presents the background job and then displays the command prompt. You c
an continue to work in the session while the job finishes. If Invoke-Wm
iMethod is used against a remote computer, the job is created on the lo
cal computer, and the results from remote computers are automatically r
eturned to the local computer. To manage the job, use the cmdlets that
contain the Job noun (the Job cmdlets). To get the job results, use the
Receive-Job cmdlet.

Note: To use this parameter with remote computers, the local and remote
computers must be configured for remoting. Additionally, you must star
t Windows PowerShell by using the "Run as administrator" option in Wind
ows Vista and later versions of Windows. For more information, see abou
t_Remote_Requirements.

For more information about Windows PowerShell background jobs, see abou
t_Jobs and about_Remote_Jobs.

-Authentication <AuthenticationLevel>
Specifies the authentication level to be used with the WMI connection.
Valid values are:

-1: Unchanged
0: Default
1: None (No authentication in performed.)
2: Connect (Authentication is performed only when the client establishe
s a relationship with the application.)
3: Call (Authentication is performed only at the beginning of each call
when the application receives the request.)
4: Packet (Authentication is performed on all the data that is received
from the client.)
5: PacketIntegrity (All the data that is transferred between the client
and the application is authenticated and verified.)
6: PacketPrivacy (The properties of the other authentication levels are
used, and all the data is encrypted.)

-Authority <string>
Specifies the authority to use to authenticate the WMI connection. You
can specify standard NTLM or Kerberos authentication. To use NTLM, set
the authority setting to ntlmdomain:<DomainName>, where <DomainName> id
entifies a valid NTLM domain name. To use Kerberos, specify kerberos:<D
omainName\ServerName>. You cannot include the authority setting when yo
u connect to the local computer.

-Class <string>
Specifies the WMI class that contains a static method to call.

-ComputerName <string[]>
Specifies the computer against which you want to run the management ope
ration. The value can be a fully qualified domain name, a NetBIOS name,
or an Internet Protocol (IP) address. Use the local computer name, use
localhost, or use a dot (.) to specify the local computer. The local c
omputer is the default. When the remote computer is in a different dom
ain from the user, a fully qualified domain name is required. You can a
lso set the value of this parameter by piping the value to the paramete
r.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user. Type a user name, such as "User01", "Dom
ain01\User01", or User@Contoso.com. Or, enter a PSCredential object, su
ch as an object that is returned by the Get-Credential cmdlet. When you
type a user name, you will be prompted for a password.

-EnableAllPrivileges [<SwitchParameter>]
Enables all the privileges of the current user before the command makes
the WMI call.

-Impersonation <ImpersonationLevel>
Specifies the impersonation level to use. Valid values are:

0: Default (Reads the local registry for the default impersonation leve
l, which is usually set to "3: Impersonate".)
1: Anonymous (Hides the credentials of the caller.)
2: Identify (Allows objects to query the credentials of the caller.)
3: Impersonate (Allows objects to use the credentials of the caller.)
4: Delegate (Allows objects to permit other objects to use the credenti
als of the caller.)

-InputObject <ManagementObject>
Specifies a ManagementObject object to use as input. When this paramete
r is used, all other parameters except the Flag and Argument parameters
are ignored.

-Locale <string>
Specifies the preferred locale for WMI objects. Specify the value of th
e Locale parameter as an array in the MS_<LCID> format in the preferred
order.

-Name <string>
Specifies the name of the method to be invoked. This parameter is manda
tory and cannot be null or empty.

-Namespace <string>
When used with the Class parameter, this parameter specifies the WMI re
pository namespace where the referenced WMI class or object is located.

-Path <string>
Specifies the WMI object path of a WMI class, or specifies the WMI obje
ct path of an instance of a WMI class. The class or the instance that y
ou specify must contain the method that is specified in the Name parame
ter.

-ThrottleLimit <int>
Allows the user to specify a throttling value for the number of WMI ope
rations that can be executed simultaneously. This parameter is used tog
ether with the AsJob parameter. The throttle limit applies only to the
current command, not to the session or to the computer.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>invoke-wmimethod -path win32_process -name create -argumentlist notep
ad.exe

__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ProcessId : 4844
ReturnValue : 0

Description
-----------
This command starts an instance of Notepad by calling the Create method of
the Win32_Process class.

Note: The ReturnValue property is populated with a 0, and the ProcessId pro
perty is populated with an integer (the next process ID number) if the comm
and is completed.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>invoke-wmimethod -path "CIM_DataFile.Name='C:\scripts\test.txt'" -Nam
e Rename -ArgumentList "C:\scripts\test_bu.txt"

__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0

Description
-----------
This command renames a file. It uses the Path parameter to reference an ins
tance of the CIM_DataFile class. Then, it applies the Rename method to that
particular instance.

Note: The ReturnValue property is populated with a 0 if the command is comp
leted.




REMARKS
To see the examples, type: "get-help Invoke-WmiMethod -examples".
For more information, type: "get-help Invoke-WmiMethod -detailed".
For technical information, type: "get-help Invoke-WmiMethod -full".

NAME
Invoke-WSManAction

SYNOPSIS
Invokes an action on the object that is specified by the Resource URI and b
y the selectors.


SYNTAX
Invoke-WSManAction [-ApplicationName <string>] [-ComputerName <string>] [-C
redential <PSCredential>] [-Credential <PSCredential>] [-Credential <PSCred
ential>] [-Credential <PSCredential>] [-Credential <PSCredential>] [-Creden
tial <PSCredential>] [-Credential <PSCredential>] [-Credential <PSCredentia
l>] [-Credential <PSCredential>] [-Port <int>] [-Port <int>] [-Port <int>]
[-Port <int>] [-Port <int>] [-Port <int>] [-Port <int>] [-Port <int>] [-Por
t <int>] [-UseSSL] [-ResourceURI] <Uri> [-Action] <string> [-Authentication
<AuthenticationMechanism>] [-FilePath <File>] [-OptionSet <hashtable>] [-S
electorSet <hashtable>] [-SessionOption <hashtable>] [-ValueSet <hashtable>
] [<CommonParameters>]

Invoke-WSManAction [-ConnectionURI <Uri>] [-ResourceURI] <Uri> [-Action] <s
tring> [-Authentication <AuthenticationMechanism>] [-FilePath <File>] [-Opt
ionSet <hashtable>] [-SelectorSet <hashtable>] [-SessionOption <hashtable>]
[-ValueSet <hashtable>] [<CommonParameters>]


DESCRIPTION
The Invoke-WSManAction runs an action on the object that is specified by RE
SOURCE_URI, where parameters are specified by key value pairs.

This cmdlet uses the WSMan connection/transport layer to run the action.

PARAMETERS
-Action <string>
Indicates the method to run on the management object specified by the R
esourceURI and selectors.

-ApplicationName <string>
Specifies the application name in the connection. The default value of
the ApplicationName parameter is WSMAN. The complete identifier for the
remote endpoint is in the following format:

<transport>://<server>:<port>/<ApplicationName>

For example:

http://server01:8080/WSMAN

Internet Information Services (IIS), which hosts the session, forwards
requests with this endpoint to the specified application. This default
setting of "WSMAN" is appropriate for most uses. This parameter is desi
gned to be used when numerous computers establish remote connections to
one computer running Windows PowerShell. In this case, IIS hosts Web S
ervices for Management (WS-Management) for efficiency.

-Authentication <AuthenticationMechanism>
Specifies the authentication mechanism to be used at the server. Possib
le values are:

- Basic: Basic is a scheme in which the user name and password are sent
in clear text to the server or proxy.
- Default : Use the authentication method implemented by the WS-Managem
ent protocol. This is the default.
- Digest: Digest is a challenge-response scheme that uses a server-spec
ified data string for the challenge.
- Kerberos: The client computer and the server mutually authenticate by
using Kerberos certificates.
- Negotiate: Negotiate is a challenge-response scheme that negotiates w
ith the server or proxy to determine the scheme to use for authenticati
on. For example, this parameter value allows negotiation to determine w
hether the Kerberos protocol or NTLM is used.
- CredSSP: Use Credential Security Service Provider (CredSSP) authentic
ation, which allows the user to delegate credentials. This option is de
signed for commands that run on one remote computer but collect data fr
om or run additional commands on other remote computers.

Caution: CredSSP delegates the user's credentials from the local comput
er to a remote computer. This practice increases the security risk of t
he remote operation. If the remote computer is compromised, when creden
tials are passed to it, the credentials can be used to control the netw
ork session.

-ComputerName <string>
Specifies the computer against which you want to run the management ope
ration. The value can be a fully qualified domain name, a NetBIOS name,
or an IP address. Use the local computer name, use localhost, or use a
dot (.) to specify the local computer. The local computer is the defau
lt. When the remote computer is in a different domain from the user, yo
u must use a fully qualified domain name must be used. You can pipe a v
alue for this parameter to the cmdlet.

-ConnectionURI <Uri>
Specifies the connection endpoint. The format of this string is:

<Transport>://<Server>:<Port>/<ApplicationName>

The following string is a properly formatted value for this parameter:

http://Server01:8080/WSMAN

The URI must be fully qualified.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user. Type a user name, such as "User01", "Dom
ain01\User01", or User@Domain.com. Or, enter a PSCredential object, suc
h as one returned by the Get-Credential cmdlet. When you type a user na
me, you will be prompted for a password.

-FilePath <File>
Specifies the path of a file that is used to update a management resour
ce. You specify the management resource by using the ResourceURI parame
ter and the SelectorSet parameter. For example, the following command u
ses the FilePath parameter:

invoke-wsmanaction -action stopservice -resourceuri wmicimv2/Win32_Serv
ice -SelectorSet @{Name="spooler"} -FilePath:c:\input.xml -authenticati
on default

This command calls the StopService method on the Spooler service by usi
ng input from a file. The file, Input.xml, contains the following conte
nt:

<p:StopService_INPUT xmlns:p="http://schemas.microsoft.com/wbem/wsman/1
/wmi/root/cimv2/Win32_Service"/>

-OptionSet <hashtable>
Passes a set of switches to a service to modify or refine the nature o
f the request. These are similar to switches used in command-line shell
s because they are service specific. Any number of options can be spec
ified.

The following example demonstrates the syntax that passes the values 1,
2, and 3 for the a, b, and c parameters:

-OptionSet @{a=1;b=2;c=3}

-Port <int>
Specifies the port to use when the client connects to the WinRM service
. When the transport is HTTP, the default port is 80. When the transpor
t is HTTPS, the default port is 443. When you use HTTPS as the transpor
t, the value of the ComputerName parameter must match the server's cert
ificate common name (CN). However, if the SkipCNCheck parameter is spec
ified as part of the SessionOption parameter, then the certificate comm
on name of the server does not have to match the host name of the serve
r. The SkipCNCheck parameter should be used only for trusted machines.

-ResourceURI <Uri>
Contains the Uniform Resource Identifier (URI) of the resource class or
instance. The URI is used to identify a specific type of resource, suc
h as disks or processes, on a computer.

A URI consists of a prefix and a path to a resource. For example:

http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Log
icalDisk
http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_NumericSenso
r

-SelectorSet <hashtable>
Specifies a set of value pairs that are used to select particular manag
ement resource instances. The SelectorSet parameter is used when more t
han one instance of the resource exists. The value of the SelectorSet p
arameter must be a hash table.

The following example shows how to enter a value for this parameter:

-SelectorSet @{Name="WinRM";ID="yyy"}

-SessionOption <hashtable>
Defines a set of extended options for the WS-Management session. Enter
a SessionOption object that you create by using the New-WSManSessionOpt
ion cmdlet. For more information about the options that are available,
see New-WSManSessionOption.

-UseSSL [<SwitchParameter>]
Specifies that the Secure Sockets Layer (SSL) protocol should be used t
o establish a connection to the remote computer. By default, SSL is not
used.

WS-Management encrypts all the Windows PowerShell content that is tran
smitted over the network. The UseSSL parameter lets you specify the add
itional protection of HTTPS instead of HTTP. If SSL is not available on
the port that is used for the connection and you specify this paramete
r, the command fails.

-ValueSet <hashtable>
Specifies a hash table that helps modify a management resource. You spe
cify the management resource by using the ResourceURI parameter and the
SelectorSet parameter. The value of the ValueSet parameter must be a h
ash table.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>invoke-wsmanaction -action startservice -resourceuri wmicimv2/win32_s
ervice -selectorset @{name="spooler"} -authentication default

xsi : http://www.w3.org/2001/XMLSchema-instance
p : http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win3
2_Service
cim : http://schemas.dmtf.org/wbem/wscim/1/common
lang : en-US
ReturnValue : 0

Description
-----------
This command calls the StartService method of the Win32_Service WMI class i
nstance that corresponds to the Spooler service.

The return value indicates whether the action was successful. In this case,
a return value of 0 indicates success. A return value of 5 indicates that
the service is already started.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>invoke-wsmanaction -action stopservice -resourceuri wmicimv2/Win32_Se
rvice -SelectorSet @{Name="spooler"} -FilePath:input.xml -authentication de
fault

xsi : http://www.w3.org/2001/XMLSchema-instance
p : http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win3
2_Service
cim : http://schemas.dmtf.org/wbem/wscim/1/common
lang : en-US
ReturnValue : 0

Description
-----------
This command calls the StopService method on the Spooler service by using i
nput from a file. The file, Input.xml, contains the following content:

<p:StopService_INPUT xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wm
i/root/cimv2/Win32_Service"/>

The return value indicates whether the action was successful. In this case,
a return value of 0 indicates success. A return value of 5 indicates that
the service is already started.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>invoke-wsmanaction -action create -resourceuri wmicimv2/win32_process
-valueset @{commandline="notepad.exe";currentdirectory="C:\"}

xsi : http://www.w3.org/2001/XMLSchema-instance
p : http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win3
2_Process
cim : http://schemas.dmtf.org/wbem/wscim/1/common
lang : en-US
ProcessId : 6356
ReturnValue : 0

Description
-----------
This command calls the Create method of the Win32_Process class. It passes
the method two parameter values, Notepad.exe and "C:\". As a result, a new
process is created to run Notepad, and the current directory of the new pro
cess is set to "C:\".




-------------------------- EXAMPLE 4 --------------------------

C:\PS>invoke-wsmanaction -action startservice -resourceuri wmicimv2/win32_s
ervice -selectorset @{name="spooler"} -computername server01 -authenticati
on default

xsi : http://www.w3.org/2001/XMLSchema-instance
p : http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win3
2_Service
cim : http://schemas.dmtf.org/wbem/wscim/1/common
lang : en-US
ReturnValue : 0

Description
-----------
This command calls the StartService method of the Win32_Service WMI class i
nstance that corresponds to the Spooler service. Because the ComputerName p
arameter is specified, the command runs against the remote server01 compute
r.

The return value indicates whether the action was successful. In this case,
a return value of 0 indicates success. A return value of 5 indicates that
the service is already started.




REMARKS
To see the examples, type: "get-help Invoke-WSManAction -examples".
For more information, type: "get-help Invoke-WSManAction -detailed".
For technical information, type: "get-help Invoke-WSManAction -full".

NAME
Import-Alias

SYNOPSIS
Imports an alias list from a file.


SYNTAX
Import-Alias [-Path] <string> [-Force] [-PassThru] [-Scope <string>] [-Conf
irm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Import-Alias cmdlet imports an alias list from a file.

PARAMETERS
-Force [<SwitchParameter>]
Allows the cmdlet to import an alias that is already defined and is rea
d only. You can use the following command to display information about
the currently-defined aliases:

get-alias | select-object name,Options
The value of the Options property will include "ReadOnly" if the corres
ponding alias is read only.

-PassThru [<SwitchParameter>]
Returns an object representing the alias. By default, this cmdlet does
not generate any output.

-Path <string>
Specifies the path to a file that includes exported alias information.
Wildcards are allowed but they must resolve to a single name.

-Scope <string>
Specifies the scope into which the aliases are imported. Valid values a
re "Global", "Local", or "Script", or a number relative to the current
scope (0 through the number of scopes, where 0 is the current scope and
1 is its parent). "Local" is the default. For more information, see ab
out_Scopes.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>import-alias test.txt

Description
-----------
This command imports alias information from a file named test.txt.




REMARKS
To see the examples, type: "get-help Import-Alias -examples".
For more information, type: "get-help Import-Alias -detailed".
For technical information, type: "get-help Import-Alias -full".

NAME
Import-CSV

SYNOPSIS
Converts object properties in a comma-separated value (CSV) file into CSV v
ersions of the original objects.


SYNTAX
Import-CSV [[-Delimiter] <char>] [-Path] <string[]> [-Header <string[]>] [<
CommonParameters>]

Import-CSV -UseCulture [-Path] <string[]> [-Header <string[]>] [<CommonPara
meters>]


DESCRIPTION
The Import-CSV cmdlet creates objects from CSV variable-length files that a
re generated by the Export-CSV cmdlet.

You can use the parameters of the Import-CSV cmdlet to specify the column h
eader row, which determines the property names of the resulting objects; to
specify the item delimiter; or to direct Import-CSV to use the list separa
tor for the current culture as the item delimiter.

The objects that Import-CSV creates are CSV versions of the original object
s. The property values of the CSV objects are string versions of the proper
ty values of the original objects. The CSV versions of the objects do not h
ave any methods.

You can also use the ConvertTo-CSV and ConvertFrom-CSV cmdlets to convert o
bjects to CSV strings (and back). These cmdlets are the same as the Export-
CSV and Import-CSV cmdlets, except that they do not save the CSV strings in
a file.

PARAMETERS
-Delimiter <char>
Specifies the delimiter that separates the property values in the CSV f
ile. The default is a comma (,). Enter a character, such as a colon (:)
. To specify a semicolon (;), enclose it in quotation marks.

If you specify a character other than the actual string delimiter in th
e file, Import-CSV cannot create objects from the CSV strings. Instead,
it returns the strings.

-Header <string[]>
Specifies an alternate column header row for the imported file. The col
umn header determines the names of the properties of the object that Im
port-CSV creates.

Enter a comma-separated list of the column headers. Enclose each item i
n quotation marks (single or double). Do not enclose the header string
in quotation marks. If you enter fewer column headers than there are co
lumns, the remaining columns will have no header. If you enter more hea
ders than there are columns, the extra headers are ignored.

When using the Header parameter, delete the original header row from th
e CSV file. Otherwise, Import-CSV creates an extra object from the item
s in the header row.

-Path <string[]>
Specifies the path to the CSV file to import. You can also pipe a path
to Import-CSV.

-UseCulture [<SwitchParameter>]
Use the list separator for the current culture as the item delimiter. T
he default is a comma (,).

To find the list separator for a culture, use the following command: (G
et-Culture).TextInfo.ListSeparator. If you specify a character other th
an the delimiter used in the CSV strings, ConvertFrom-CSV cannot create
objects from the CSV strings. Instead, it returns the strings.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-process | export-csv processes.csv

C:\PS> $p = import-CSV processes.csv

C:\PS> $p | get-member

TypeName: CSV:System.Diagnostics.Process

Name MemberType Definition
---- ---------- ----------
Equals Method System.Boolean Equals(Object obj)
GetHashCode Method System.Int32 GetHashCode()
GetType Method System.Type GetType()
ToString Method System.String ToString()
BasePriority NoteProperty System.String BasePriority=8
Company NoteProperty System.String Company=Microsoft Cor
poration
...

C:\PS> $p | out-gridview

Description
-----------
This example shows how to export and then import a CSV file of Microsoft .N
ET Framework objects.

The first command uses the Get-Process cmdlet to get the process on the loc
al computer. It uses a pipeline operator (|) to send the process objects to
the Export-CSV cmdlet, which exports the process objects to the Processes.
csv file in the current directory.

The second command uses the Import-CSV cmdlet to import the processes in th
e Import-CSV file. Then it saves the resulting process objects in the $p va
riable.

The third command uses a pipeline operator to pipe the imported objects to
the Get-Member cmdlets. The result shows that they are CSV:System.Diagnosti
c.Process objects, not the System.Diagnostic.Process objects that Get-Proce
ss returns.

Also, because there is no entry type in the formatting files for the CSV ve
rsion of the process objects, these objects are not formatted in the same w
ay that standard process objects are formatted.

To display the objects, use the formatting cmdlets, such as Format-Table an
d Format-List, or pipe the objects to Out-GridView.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-process | export-csv processes.csv -Delimiter :

C:\PS> $p = import-csv processes.csv -Delimiter :

Description
-----------
This example shows how to use the Delimiter parameter of Import-CSV. In thi
s example, the processes are exported to a file that uses a colon (:) as a
delimiter.

When importing, the Import-CSV file uses the Delimiter parameter to indicat
e the delimiter that is used in the file.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$p = import-csv processes.csv -UseCulture

C:\PS> (get-culture).textinfo.listseparator

,

Description
-----------
This example shows how to use the UseCulture parameter of Import-CSV.

The first command imports the objects in the Processes.csv file into the $p
variable. It uses the UseCulture parameter to direct Import-CSV to use the
list separator defined for the current culture.

The second command displays the list separator for the current culture. It
uses the Get-Culture cmdlet to get the current culture. It uses the dot (.)
method to get the TextInfo property of the current culture and the ListSep
arator property of the object in TextInfo. In this example, the command ret
urns a comma.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>start-job -scriptblock { get-process } | export-csv jobs.csv

C:\PS> $header = "MoreData","StatusMessage","Location","Command","State","F
inished","InstanceId","SessionId","Name","ChildJobs","Output","Error","Prog
ress","Verbose","Debug","Warning","StateChanged"

# Delete header from file
C:\PS> $a = (get-content jobs.csv)
C:\PS> $a = $a[0], $a[2..($a.count - 1)]
C:\PS> $a > jobs.csv

C:\PS> $j = import-csv jobs.csv -header $header

C:\PS> $j

MoreData : True
StatusMessage :
Location : localhost
Command : get-process
State : Running
Finished : System.Threading.ManualResetEvent
InstanceId : 135bdd25-40d6-4a20-bd68-05282a59abd6
SessionId : 1
Name : Job1
ChildJobs : System.Collections.Generic.List`1[System.Management.Automat
ion.Job]
Output : System.Management.Automation.PSDataCollection`1[System.Mana
gement.Automation.PSObject]
Error : System.Management.Automation.PSDataCollection`1[System.Mana
gement.Automation.ErrorRecord]
Progress : System.Management.Automation.PSDataCollection`1[System.Mana
gement.Automation.ProgressRecord]
Verbose : System.Management.Automation.PSDataCollection`1[System.Stri
ng]
Debug : System.Management.Automation.PSDataCollection`1[System.Stri
ng]
Warning : System.Management.Automation.PSDataCollection`1[System.Stri
ng]
StateChanged :

Description
-----------
This example shows how to use the Header parameter of Import-CSV to change
the names of properties in the resulting imported object.

The first command uses the Start-Job cmdlet to start a background job that
runs a Get-Process command on the local computer. A pipeline operator (|) s
ends the resulting job object to the Export-CSV cmdlet, which converts the
job object to CSV format. An assignment operator (=) saves the resulting CS
V in the Jobs.csv file.

The second command saves a header in the $header variable. Unlike the defau
lt header, this header uses "MoreData" instead of "HasMoreData" and "State"
instead of "JobStateInfo".

The next three commands delete the original header (the second line) from t
he Jobs.csv file.

The sixth command uses the Import-CSV cmdlet to import the Jobs.csv file an
d convert the CSV strings into a CSV version of the job object. The command
uses the Header parameter to submit the alternate header. The results are
stored in the $j variable.

The seventh command displays the object in the $j variable. The resulting o
bject has "MoreData" and "State" properties, as shown in the command output
.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>".\processes.csv" | import-csv

Description
-----------
This command imports the objects from the Processes.csv file.




REMARKS
To see the examples, type: "get-help Import-CSV -examples".
For more information, type: "get-help Import-CSV -detailed".
For technical information, type: "get-help Import-CSV -full".

NAME
Import-Module

SYNOPSIS
Adds modules to the current session.


SYNTAX
Import-Module [-Name] <string[]> [-Alias <string[]>] [-ArgumentList <Object
[]>] [-AsCustomObject] [-Cmdlet <string[]>] [-Force] [-Function <string[]>]
[-Global] [-PassThru] [-Prefix <string>] [-Variable <string[]>] [-Version
<Version>] [<CommonParameters>]

Import-Module [-Assembly] <Assembly[]> [-Alias <string[]>] [-ArgumentList <
Object[]>] [-AsCustomObject] [-Cmdlet <string[]>] [-Force] [-Function <stri
ng[]>] [-Global] [-PassThru] [-Prefix <string>] [-Variable <string[]>] [-Ve
rsion <Version>] [<CommonParameters>]

Import-Module [-ModuleInfo] <PSModuleInfo[]> [-Alias <string[]>] [-Argument
List <Object[]>] [-AsCustomObject] [-Cmdlet <string[]>] [-Force] [-Function
<string[]>] [-Global] [-PassThru] [-Prefix <string>] [-Variable <string[]>
] [-Version <Version>] [<CommonParameters>]


DESCRIPTION
The Import-Module cmdlet adds one or more modules to the current session.

A module is a package that contains members (such as cmdlets, providers, sc
ripts, functions, variables, and other tools and files) that can be used in
Windows PowerShell. After a module is imported, you can use the module mem
bers in your session.

To import a module, use the Name, Assembly, or ModuleInfo parameter to iden
tify the module to import. By default, Import-Module imports all members th
at the module exports, but you can use the Alias, Function, Cmdlet, and Var
iable parameters to restrict the members that are imported.

Import-Module imports a module only into the current session. To import the
module into all sessions, add an Import-Module command to your Windows Pow
erShell profile. For more information about profiles, see about_Profiles.

For more information about modules, see about_Modules.

PARAMETERS
-Alias <string[]>
Imports only the specified aliases from the module into the current ses
sion. Enter a comma-separated list of aliases. Wildcard characters are
permitted.

Some modules automatically export selected aliases into your session wh
en you import the module. This parameter lets you select from among the
exported aliases.

-ArgumentList <Object[]>
Specifies arguments (parameter values) that are passed to a script modu
le during the Import-Module command. This parameter is valid only when
you are importing a script module.

You can also refer to ArgumentList by its alias, "args". For more infor
mation, see about_Aliases.

-AsCustomObject [<SwitchParameter>]
Returns a custom object with members that represent the imported module
members. This parameter is valid only for script modules.

When you use the AsCustomObject parameter, Import-Module imports the mo
dule members into the session and then returns a PSCustomObject object
instead of a PSModuleInfo object. You can save the custom object in a v
ariable and use dot notation to invoke the members.

-Assembly <Assembly[]>
Imports the cmdlets and providers implemented in the specified assembly
objects. Enter a variable that contains assembly objects or a command
that creates assembly objects. You can also pipe an assembly object to
Import-Module.

When you use this parameter, only the cmdlets and providers implemented
by the specified assemblies are imported. If the module contains other
files, they are not imported, and you might be missing important membe
rs of the module. Use this parameter for debugging and testing the modu
le, or when you are instructed to use it by the module author.

-Cmdlet <string[]>
Imports only the specified cmdlets from the module into the current ses
sion. Enter a list of cmdlets. Wildcard characters are permitted.

Some modules automatically export selected cmdlets into your session wh
en you import the module. This parameter lets you select from among the
exported cmdlets.

-Force [<SwitchParameter>]
Re-imports a module and its members, even if the module or its members
have an access mode of read-only.

-Function <string[]>
Imports only the specified functions from the module into the current s
ession. Enter a list of functions. Wildcard characters are permitted.

Some modules automatically export selected functions into your session
when you import the module. This parameter lets you select from among t
he exported functions.

-Global [<SwitchParameter>]
When used in a script module (.psm1), this parameter imports modules in
to the global session state.

This parameter is effective only when it appears in a script module. Ot
herwise, it is ignored.

By default, the commands in a script module, including commands from ne
sted modules, are imported into the caller's session state. To restrict
the commands that a module exports, use an Export-ModuleMember command
in the script module.

-ModuleInfo <PSModuleInfo[]>
Specifies module objects to import. Enter a variable that contains the
module objects, or a command that gets the module objects, such as a "g
et-module -listavailable" command. You can also pipe module objects to
Import-Module.

-Name <string[]>
Specifies the names of the modules to import. Enter the name of the mod
ule or the name of a file in the module, such as a .psd1, .psm1, .dll,
or ps1 file. File paths are optional. Wildcards are not permitted. You
can also pipe module names and file names to Import-Module.

If you omit a path, Import-Module looks for the module in the paths sav
ed in the PSModulePath environment variable ($env:PSModulePath).

Specify only the module name whenever possible. When you specify a file
name, only the members that are implemented in that file are imported.
If the module contains other files, they are not imported, and you mig
ht be missing important members of the module.

-PassThru [<SwitchParameter>]
Returns objects that represent the modules that were imported. By defau
lt, this cmdlet does not generate any output.

Notes
-- When you pipe the output of a "get-module -listavailable" command to
an Import-Module command with the PassThru parameter, Import-Module re
turns the object that Get-Module passed to it without updating the obje
ct. As a result, the Exported and NestedModules properties are not yet
populated.

-- When you use the Prefix parameter to specify a prefix for the member
, the prefix does not appear in the member names in the properties of t
he module object. The object records what was exported before the prefi
x was applied.

-Prefix <string>
Adds the specified prefix to the nouns in the names of imported module
members.

Use this parameter to avoid name conflicts that might occur when differ
ent members in the session have the same name. This parameter does not
change the module, and it does not affect files that the module imports
for its own use (known as "nested modules"). It affects only the names
of members in the current session.

For example, if you specify the prefix "UTC" and then import a Get-Date
cmdlet, the cmdlet is known in the session as Get-UTCDate, and it is n
ot confused with the original Get-Date cmdlet.

-Variable <string[]>
Imports only the specified variables from the module into the current s
ession. Enter a list of variables. Wildcard characters are permitted.

Some modules automatically export selected variables into your session
when you import the module. This parameter lets you select from among t
he exported variables.

-Version <Version>
Specifies the version of the module to import. Use this parameter when
you have different versions of the same module on your system.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>import-module -name BitsTransfer

Description
-----------
This command imports the members of the BitsTransfer module into the curren
t session.

The Name parameter name (-Name) is optional and can be omitted.

By default, Import-Module does not generate any output when it imports a mo
dule. To request output, use the PassThru or AsCustomObject parameter, or t
he Verbose common parameter.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-module -listAvailable | import-module

Description
-----------
This command imports all available modules in the path specified by the PSM
odulePath environment variable ($env:psmodulepath) into the current session
.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$m = get-module -ListAvailable BitsTransfer, ServerBackup

C:\PS> import-module -moduleInfo $m

Description
-----------
These commands import the members of the BitsTransfer and ServerBackup modu
les into the current session.

The first command uses the Get-Module cmdlet to get PSModuleInfo objects th
at represent the BitsTransfer and ServerBackup modules. It saves the object
s in the $m variable. The ListAvailable parameter is required when you are
getting modules that are not yet imported into the session.

The second command uses the ModuleInfo parameter of Import-Module to import
the modules into the current session.

These commands are equivalent to using a pipeline operator (|) to send the
output of a Get-Module command to Import-Module.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>import-module -name c:\ps-test\modules\test -verbose

VERBOSE: Loading module from path 'C:\ps-test\modules\Test\Test.psm1'.
VERBOSE: Exporting function 'my-parm'.
VERBOSE: Exporting function 'get-parm'.
VERBOSE: Exporting function 'get-spec'.
VERBOSE: Exporting function 'get-specDetails'.

Description
-----------
This command uses an explicit path to identify the module to import.

It also uses the Verbose common parameter to get a list of the items import
ed from the module. Without the Verbose, PassThru, or AsCustomObject parame
ter, Import-Module does not generate any output when it imports a module.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>import-module BitsTransfer -cmdlet Add-BitsTransferFile, Get-BitsTran
sfer

C:\PS> get-module BitsTransfer

Name : BitsTransfer
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Bits
Transfer\BitsTransfer.psd1
Description :
Guid : 8fa5064b-8479-4c5c-86ea-0d311fe48875
Version : 1.0.0.0
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Bits
Transfer
ModuleType : Manifest
PrivateData :
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {[Add-BitsTransfer, Add-BitsTransfer], [Complete-BitsTr
ansfer, Complete-BitsTransfer], [Get-BitsTransfer, Get-BitsTransfer], [Rem
ove-BitsTransfer, Remove-BitsTransfer]...}
ExportedFunctions : {}
ExportedVariables : {}
NestedModules : {Microsoft.BackgroundIntelligentTransfer.Management}


C:\PS> get-command -module BitsTransfer

CommandType Name Definition
----------- ---- ----------
Cmdlet Add-BitsTransfer Add-BitsTransfer [-BitsJob] <BitsJob[]> [-S
ource] <String[]> [[-Destination] <String[]>] [-Verbose] [-Debug] [-ErrorA.
..
Cmdlet Get-BitsTransfer Get-BitsTransfer [[-Name] <String[]>] [-All
Users] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-WarningActi.
..

Description
-----------
This example shows how to restrict the module members that are imported int
o the session and the effect of this command on the session.

The first command imports only the Add-BitsTransfer and Get-BitsTransfer cm
dlets from the BitsTransfer module. The command uses the Cmdlet parameter t
o restrict the cmdlets that the module imports. You can also use the Alias,
Variable, and Function parameters to restrict other members that a module
imports.

The second command uses the Get-Module cmdlet to get the object that repres
ents the BitsTransfer module. The ExportedCmdlets property lists all of the
cmdlets that the module exports, even when they were not all imported.

The third command uses the Module parameter of the Get-Command cmdlet to ge
t the commands that were imported from the BitsTransfer module. The results
confirm that only the Add-BitsTransfer and Get-BitsTransfer cmdlets were i
mported.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>import-module BitsTransfer -prefix PS -passthru

Name : bitstransfer
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\bits
transfer\bitstransfer.psd1
Description :
Guid : 8fa5064b-8479-4c5c-86ea-0d311fe48875
Version : 1.0.0.0
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\bits
transfer
ModuleType : Manifest
PrivateData :
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {[Add-BitsTransfer, Add-BitsTransfer], [Remove-BitsTran
sfer, Remove-BitsTransfer], [Complete-BitsTransfer, Complete-BitsTransfer]
, [Get-BitsTransfer, Get-BitsTransfer]...}
ExportedFunctions : {}
ExportedVariables : {}
NestedModules : {Microsoft.BackgroundIntelligentTransfer.Management}


C:\PS> get-command -module bitstransfer

CommandType Name Definition
----------- ---- ----------
Cmdlet Add-PSBitsTransfer Add-PSBitsTransfer [-BitsJob] <
BitsJob[]> [-Source] <String[]> ...
Cmdlet Complete-PSBitsTransfer Complete-PSBitsTransfer [-BitsJ
ob] <BitsJob[]> [-Verbose] [-Deb...
Cmdlet Get-PSBitsTransfer Get-PSBitsTransfer [[-Name] <St
ring[]>] [-AllUsers] [-Verbose] ...
Cmdlet Remove-PSBitsTransfer Remove-PSBitsTransfer [-BitsJob
] <BitsJob[]> [-Verbose] [-Debug...
Cmdlet Resume-PSBitsTransfer Resume-PSBitsTransfer [-BitsJob
] <BitsJob[]> [-Asynchronous] [-...
Cmdlet Set-PSBitsTransfer Set-PSBitsTransfer [-BitsJob] <
BitsJob[]> [-DisplayName <String...
Cmdlet Start-PSBitsTransfer Start-PSBitsTransfer [[-Source]
<String[]>] [[-Destination] <St...
Cmdlet Suspend-PSBitsTransfer Suspend-PSBitsTransfer [-BitsJo
b] <BitsJob[]> [-Verbose] [-Debu...

Description
-----------
These commands import the BitsTransfer module into the current session, add
a prefix to the member names, and then display the prefixed member names.

The first command uses the Import-Module cmdlet to import the BitsTransfer
module. It uses the Prefix parameter to add the PS prefix to all members th
at are imported from the module and the PassThru parameter to return a modu
le object that represents the imported module.

The module object that the command returns has an ExportedCmdlets property
that lists the exported members. The prefix does not appear in the cmdlet n
ames, because it is applied after the members are exported (but before they
are imported).

The second command uses the Get-Command cmdlet to get the members that have
been imported from the module. It uses the Module parameter to specify the
module. The output shows that the module members were correctly prefixed.

The prefix that you use applies only to the members in the current session.
It does not change the module.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-module -list | format-table -property name, moduletype -auto

Name ModuleType
---- ----------
Show-Calendar Script
BitsTransfer Manifest
PSDiagnostics Manifest
TestCmdlets Script

C:\PS> $a = import-module -name Show-Calendar -asCustomObject

C:\PS> $a | get-member


TypeName: System.Management.Automation.PSCustomObject

Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Show-Calendar ScriptMethod System.Object Show-Calendar();

C:\PS> $a."show-calendar"()

Description
-----------
These commands demonstrate how to get and use the custom object that Import
-Module returns.

Custom objects include synthetic members that represent each of the importe
d module members. For example, the cmdlets and functions in a module are co
nverted to script methods of the custom object.

Custom objects are very useful in scripting. They are also useful when seve
ral imported objects have the same names. Using the script method of an obj
ect is equivalent to specifying the fully qualified name of an imported mem
ber, including its module name.

The AsCustomObject parameter can be used only with a script module, so the
first task is to determine which of the available modules is a script modul
e.

The first command uses the Get-Module cmdlet to get the available modules.
The command uses a pipeline operator (|) to pass the module objects to the
Format-Table cmdlet, which lists the Name and ModuleType of each module in
a table.

The second command uses the Import-Module cmdlet to import the Show-Calenda
r script module. The command uses the AsCustomObject parameter to request a
custom object. The command saves the resulting custom object in the $a var
iable.

The third command uses a pipeline operator to send the $a variable to the G
et-Member cmdlet, which gets the properties and methods of the PSCustomObje
ct in $a. The output shows a Show-Calendar script method.

The last command uses the Show-Calendar script method. The method name must
be enclosed in quotation marks, because it includes a hyphen.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>import-module BitsTransfer

C:\PS> import-module BitsTransfer -force -prefix PS

Description
-----------
This example shows how to use the Force parameter of Import-Module when you
are re-importing a module into the same session.

The first command imports the BitsTransfer module. The second command impor
ts the module again, this time using the Prefix parameter.

The second command also includes the Force parameter, which removes the mod
ule and then imports it again. Without this parameter, the session would in
clude two copies of each BitsTransfer cmdlet, one with the standard name an
d one with the prefixed name.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>get-date

Saturday, September 12, 2009 6:47:04 PM

C:\PS> import-module TestModule

C:\PS> get-date
09255

C:\PS> get-command get-date | format-table -property commandtype, name, pss
napin, module -auto

CommandType Name pssnapin Module
----------- ---- -------- ------
Function Get-Date TestModule
Cmdlet Get-Date Microsoft.PowerShell.Utility


C:\PS> Microsoft.PowerShell.Utility\get-date

Saturday, September 12, 2009 6:33:23 PM

Description
-----------
This example shows how to run commands that have been hidden by imported co
mmands.

The first command run the Get-Date cmdlet that comes with Windows PowerShel
l. It returns a DateTime object with the current date.

The second command imports the TestModule module. This module includes a fu
nction named Get-Date that returns the Julian date.

The third command runs the Get-Date command again. Because functions take p
recedence over cmdlets, the Get-Date function from the TestModule module ra
n, instead of the Get-Date cmdlet.

The fourth command shows that there are two Get-Date commands in the sessio
n, a function from the TestModule module and a cmdlet from the Microsoft.Po
werShell.Utility snap-in.

The fifth command runs the hidden cmdlet by qualifying the command name wit
h the snap-in name.

For more information about command precedence in Windows PowerShell, see ab
out_command_precedence.




REMARKS
To see the examples, type: "get-help Import-Module -examples".
For more information, type: "get-help Import-Module -detailed".
For technical information, type: "get-help Import-Module -full".

NAME
Import-PSSession

SYNOPSIS
Imports commands from another session into the current session.


SYNTAX
Import-PSSession [-Session] <PSSession> [[-CommandName] <string[]>] [[-Form
atTypeName] <string[]>] [-AllowClobber] [-ArgumentList <Object[]>] [-Comman
dType {Alias | Function | Filter | Cmdlet | ExternalScript | Application |
Script | All}] [-Module <string[]>] [-Prefix <string>] [<CommonParameters>]


DESCRIPTION
The Import-PSSession cmdlet imports commands (such as cmdlets, functions, a
nd aliases) from a PSSession on a local or remote computer into the current
session. You can import any command that Get-Command can find in the PSSes
sion.

Use an Import-PSSession command to import commands from a customized shell,
such as a Microsoft Exchange Server shell, or from a session that includes
Windows PowerShell modules and snap-ins or other elements that are not in
the current session.

To import commands, first use the New-PSSession cmdlet to create a PSSessio
n. Then, use the Import-PSSession cmdlet to import the commands. By default
, Import-PSSession imports all commands except for commands that have the s
ame names as commands in the current session. To import all the commands, u
se the AllowClobber parameter.

You can use imported commands just as you would use any command in the sess
ion. When you use an imported command, the imported part of the command run
s implicitly in the session from which it was imported. However, the remote
operations are handled entirely by Windows PowerShell. You need not even b
e aware of them, except that you must keep the connection to the other sess
ion (PSSession) open. If you close it, the imported commands are no longer
available.

Because imported commands might take longer to run than local commands, Imp
ort-PSSession adds an AsJob parameter to every imported command. This param
eter allows you to run the command as a Windows PowerShell background job.
For more information, see about_Jobs.

When you use Import-PSSession, Windows PowerShell adds the imported command
s to a temporary module that exists only in your session and returns an obj
ect that represents the module. To create a persistent module that you can
use in future sessions, use the Export-PSSession cmdlet.

The Import-PSSession cmdlet uses the implicit remoting feature of Windows P
owerShell. When you import commands into the current session, they run impl
icitly in the original session or in a similar session on the originating
computer.

PARAMETERS
-AllowClobber [<SwitchParameter>]
Imports the specified commands, even if they have the same names as com
mands in the current session.

If you import a command with the same name as a command in the current
session, the imported command hides or replaces the original commands.
For more information, see about_Command_Precedence.

By default, Import-PSSession does not import commands that have the sam
e name as commands in the current session.

-ArgumentList <Object[]>
Imports the variant of the command that results from using the specifie
d arguments (parameter values).

For example, to import the variant of the Get-Item command in the certi
ficate (Cert:) drive in the PSSession in $s, type "import-pssession -se
ssion $s -command get-item -argumentlist cert:".

-CommandName <string[]>
Imports only the commands with the specified names or name patterns. Wi
ldcards are permitted. Use "CommandName" or its alias, "Name".

By default, Import-PSSession imports all commands from the session, exc
ept for commands that have the same names as commands in the current se
ssion. This prevents imported commands from hiding or replacing command
s in the session. To import all commands, even those that hide or repla
ce other commands, use the AllowClobber parameter.

If you use the CommandName parameter, the formatting files for the comm
ands are not imported unless you use the FormatTypeName parameter. Simi
larly, if you use the FormatTypeName parameter, no commands are importe
d unless you use the CommandName parameter.

-CommandType <CommandTypes>
Imports only the specified types of command objects. The default value
is Cmdlet. Use "CommandType" or its alias, "Type".

Valid values are:
-- Alias: The Windows PowerShell aliases in the remote session.
-- All: The cmdlets and functions in the remote session.
-- Application: All the files other than Windows-PowerShell files in th
e paths that are listed in the Path environment variable ($env:path) in
the remote session, including .txt, .exe, and .dll files.
-- Cmdlet: The cmdlets in the remote session. "Cmdlet" is the default.
-- ExternalScript: The .ps1 files in the paths listed in the Path envir
onment variable ($env:path) in the remote session.
-- Filter and Function: The Windows PowerShell functions in the remote
session.
-- Script: The script blocks in the remote session.

-FormatTypeName <string[]>
Imports formatting instructions for the specified Microsoft .NET Framew
ork types. Enter the type names. Wildcards are permitted.

The value of this parameter must be the name of a type that is returned
by a Get-FormatData command in the session from which the commands are
being imported. To get all of the formatting data in the remote sessio
n, type *.

If the command does not include either the CommandName or FormatTypeNam
e parameters, Import-PSSession
imports formatting instructions for all .NET Framework types returned b
y a Get-FormatData command in the remote session.

If you use the FormatTypeName parameter, no commands are imported unles
s you use the CommandName parameter.
Similarly, if you use the CommandName parameter, the formatting files f
or the commands are not imported unless you use the FormatTypeName para
meter.

-Module <string[]>
Imports only the commands in the specified Windows PowerShell snap-ins
and modules. Enter the snap-in and module names. Wildcards are not perm
itted.

For more information, see about_PSSnapins and Import-Module.

-Prefix <string>
Adds the specified prefix to the nouns in the names of imported command
s.

Use this parameter to avoid name conflicts that might occur when differ
ent commands in the session have the same name.
For example, if you specify the prefix "Remote" and then import a Get-D
ate cmdlet, the cmdlet is known in the session as Get-RemoteDate and it
is not confused with the original Get-Date cmdlet.

-Session <PSSession>
Specifies the PSSession from which the cmdlets are imported. Enter a va
riable that contains a session object or a command that gets a session
object, such as a New-PSSession or Get-PSSession command. You can speci
fy only one session. This parameter is required.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$s = new-pssession -computername Server01

C:\PS> import-pssession -session $s

Description
-----------
This command imports all commands from a PSSession on the Server01 computer
into the current session, except for commands that have the same names as
commands in the current session.

Because this command does not use the CommandName parameter, it also import
s all of the formatting data required for the imported commands.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$s = new-pssession https://ps.testlabs.com/powershell

C:\PS> import-pssession -session $s -commandname *-test -formatTypeName *

C:\PS> new-test -name test1

C:\PS> get-test test1 | run-test

Description
-----------
These commands import the commands with names that end in "-test" from a PS
Session into the local session, and then they show how to use an imported c
mdlet.

The first command uses the New-PSSession cmdlet to create a PSSession. It s
aves the PSSession in the $s variable.

The second command uses the Import-PSSession cmdlet to import commands from
the PSSession in $s into the current session. It uses the CommandName para
meter to specify commands with the Test noun and the FormatTypeName paramet
er to import the formatting data for the Test commands.

The third and fourth commands use the imported commands in the current sess
ion. Because imported commands are actually added to the current session, y
ou use the local syntax to run them. You do not need to use the Invoke-Comm
and cmdlet to run an imported command.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$s1 = new-pssession -computername s1

C:\PS> $s2 = new-pssession -computername s2

C:\PS> import-pssession -session s1 -type cmdlet -name New-Test, Get-Test -
FormatTypeName *

C:\PS> import-pssession -session s2 -type cmdlet -name Set-Test -FormatType
Name *

C:\PS> new-test Test1 | set-test -runtype full

Description
-----------
This example shows that you can use imported cmdlets just as you would use
local cmdlets.

These commands import the New-Test and Get-Test cmdlets from a PSSession on
the Server01 computer and the Set-Test cmdlet from a PSSession on the Serv
er02 computer.

Even though the cmdlets were imported from different PSSessions, you can pi
pe an object from one cmdlet to another without error.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$s = new-pssession -computername Server01

C:\PS> import-pssession -session $s -commandname *-test* -formattypename *

C:\PS> $batch = new-test -name Batch -asjob

C:\PS> receive-job $batch

Description
-----------
This example shows how to run an imported command as a background job.

Because imported commands might take longer to run than local commands, Imp
ort-PSSession adds an AsJob parameter to every imported command. The AsJob
parameter lets you run the command as a background job.

The first command creates a PSSession on the Server01 computer and saves th
e PSSession object in the $s variable.

The second command uses Import-PSSession to import the Test cmdlets from th
e PSSession in $s into the current session.

The third command uses the AsJob parameter of the imported New-Test cmdlet
to run a New-Test command as a background job. The command saves the job ob
ject that New-Test returns in the $batch variable.

The fourth command uses the Receive-Job cmdlet to get the results of the jo
b in the $batch variable.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>$s = new-pssession -comp Server01

C:\PS> invoke-command -session $s {import-module TestManagement}

C:\PS> import-pssession -session $s -module TestManagement

Description
-----------
This example shows how to import the cmdlets and functions from a Windows P
owerShell module on a remote computer into the current session.

The first command creates a PSSession on the Server01 computer and saves it
in the $s variable.

The second command uses the Invoke-Command cmdlet to run an Import-Module c
ommand in the PSSession in $s.

Typically, the module would be added to all sessions by an Import-Module co
mmand in a Windows PowerShell profile, but profiles are not run in PSSessio
ns.

The third command uses the Module parameter of Import-PSSession to import t
he cmdlets and functions in the module into the current session.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>import-pssession $s -CommandName Get-Date, SearchHelp -formatTypeNam
e * -AllowClobber


Name : tmp_79468106-4e1d-4d90-af97-1154f9317239_tcw1zunz.ttf
Path : C:\Users\User01\AppData\Local\Temp\tmp_79468106-4e1d-4d
90-af97-1154f9317239_tcw1zunz.ttf\tmp_79468106-4e1d-4d90-af97-1154f9317239_
tcw1zunz.ttf.psm1
Description : Implicit remoting for http://server01.corp.fabrikam.com
/wsman
Guid : 79468106-4e1d-4d90-af97-1154f9317239
Version : 1.0
ModuleBase : C:\Users\User01\AppData\Local\Temp\tmp_79468106-4e1d-4d
90-af97-1154f9317239_tcw1zunz.ttf
ModuleType : Script
PrivateData : {ImplicitRemoting}
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {}
ExportedFunctions : {[Get-Date, Get-Date], [SearchHelp, SearchHelp]}
ExportedVariables : {}
NestedModules : {}

Description
-----------
This example shows that Import-PSSession creates a module in a temporary fi
le on disk. It also shows that all commands are converted into functions be
fore they are imported into the current session.

The command uses the Import-PSSession cmdlet to import a Get-Date cmdlet an
d a SearchHelp function into the current session.

The Import-PSSession cmdlet returns a PSModuleInfo object that represents t
he temporary module. The value of the Path property shows that Import-PSSes
sion created a script module (.psm1) file in a temporary location. The Expo
rtedFunctions property shows that the Get-Date cmdlet and the SearchHelp fu
nction were both imported as functions.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>import-pssession $s -CommandName Get-Date -formatTypeName * -AllowClo
bber

C:\PS> get-command get-date

CommandType Name Definition
----------- ---- ----------
Function Get-Date ...
Cmdlet Get-Date Get-Date [[-Date] <DateTime>] [-Year <Int32>] [-Mo
nth <Int32>]

C:\PS> Get-Date
09074

C:\PS> (get-command -type cmdlet -name get-date).pssnapin.name
Microsoft.PowerShell.Utility

C:\PS> Microsoft.PowerShell.Utility\get-date

Sunday, March 15, 2009 2:08:26 PM

Description
-----------
This example shows how to run a command that is hidden by an imported comma
nd.

The first command imports a Get-Date cmdlet from the PSSession in the $s va
riable. Because the current session includes a Get-Date cmdlet, the AllowCl
obber parameter is required in the command.

The second command uses the Get-Command cmdlet to get the Get-Date commands
in the current session. The output shows that the session includes the ori
ginal Get-Date cmdlet and a Get-Date function. The Get-Date function runs t
he imported Get-Date cmdlet in the PSSession in $s.

The third command runs a Get-Date command. Because functions take precedenc
e over cmdlets, Windows PowerShell runs the imported Get-Date function, whi
ch returns a Julian date.

The fourth and fifth commands show how to use a qualified name to run a com
mand that is hidden by an imported command.

The fourth command gets the name of the Windows PowerShell snap-in that add
ed the original Get-Date cmdlet to the current session.

The fifth command uses the snap-in-qualified name of the Get-Date cmdlet to
run a Get-Date command.

For more information about command precedence and hidden commands, see abou
t_Command_Precedence.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>import-pssession -session $s -commandName *Item* -AllowClobber

Description
-----------
This command imports commands whose names include "Item" from the PSSession
in $s. Because the command includes the CommandName parameter but not the
FormatTypeData parameter, only the command is imported.

Use this command when you are using Import-PSSession to run a command on a
remote computer and you already have the formatting data for the command in
the current session.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>$m = import-pssession -session $s -CommandName *bits* -formattypename
*bits*

C:\PS> get-command -module $m

CommandType Name
----------- ----
Function Add-BitsFile
Function Complete-BitsTransfer
Function Get-BitsTransfer
Function Remove-BitsTransfer
Function Resume-BitsTransfer
Function Set-BitsTransfer
Function Start-BitsTransfer
Function Suspend-BitsTransfer

Description
-----------
This command shows how to use the Module parameter of Get-Command to find o
ut which commands were imported into the session by an Import-PSSession com
mand.

The first command uses the Import-PSSession cmdlet to import commands whose
names include "bits" from the PSSession in the $s variable. The Import-PSS
ession command returns a temporary module, and the command saves the module
in the $m variable.

The second command uses the Get-Command cmdlet to get the commands that are
exported by the module in the $m variable.

The Module parameter takes a string value, which is designed for the module
name. However, when you submit a module object, Windows PowerShell uses th
e ToString method on the module object, which returns the module name.

The Get-Command command is the equivalent of "get-command $m.name".




REMARKS
To see the examples, type: "get-help Import-PSSession -examples".
For more information, type: "get-help Import-PSSession -detailed".
For technical information, type: "get-help Import-PSSession -full".

Name : ise
Category : Alias
Synopsis : powershell_ise.exe
Component :
Role :
Functionality :

Name : about_Windows_PowerShell_ISE
Category : HelpFile
Synopsis : Describes the features and system requirements of Windows Power
Shell
Component :
Role :
Functionality :
Length : 6789

NAME
Invoke-WmiMethod

SYNOPSIS
Calls Windows Management Instrumentation (WMI) methods.


SYNTAX
Invoke-WmiMethod [-Class] <string> [[-ArgumentList] <Object[]>] [-Authentic
ation {Default | None | Connect | Call | Packet | PacketIntegrity | PacketP
rivacy | Unchanged}] [-Authority <string>] [-ComputerName <string[]>] [-Cre
dential <PSCredential>] [-EnableAllPrivileges] [-Impersonation {Default | A
nonymous | Identify | Impersonate | Delegate}] [-Locale <string>] [-Namespa
ce <string>] [-Name] <string> [-AsJob] [-ThrottleLimit <int>] [-Confirm] [-
WhatIf] [<CommonParameters>]

Invoke-WmiMethod [-Authentication {Default | None | Connect | Call | Packet
| PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority <string>] [-Co
mputerName <string[]>] [-Credential <PSCredential>] [-EnableAllPrivileges]
[-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}]
[-Locale <string>] [-Namespace <string>] [-Name] <string> [-AsJob] [-Thrott
leLimit <int>] [-Confirm] [-WhatIf] [<CommonParameters>]

Invoke-WmiMethod -InputObject <ManagementObject> [-ArgumentList <Object[]>]
[-Name] <string> [-AsJob] [-ThrottleLimit <int>] [-Confirm] [-WhatIf] [<Co
mmonParameters>]

Invoke-WmiMethod -Path <string> [-ArgumentList <Object[]>] [-Authentication
{Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivac
y | Unchanged}] [-Authority <string>] [-ComputerName <string[]>] [-Credenti
al <PSCredential>] [-EnableAllPrivileges] [-Impersonation {Default | Anonym
ous | Identify | Impersonate | Delegate}] [-Locale <string>] [-Namespace <s
tring>] [-Name] <string> [-AsJob] [-ThrottleLimit <int>] [-Confirm] [-WhatI
f] [<CommonParameters>]

Invoke-WmiMethod [-Authentication {Default | None | Connect | Call | Packet
| PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority <string>] [-Co
mputerName <string[]>] [-Credential <PSCredential>] [-EnableAllPrivileges]
[-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}]
[-Locale <string>] [-Namespace <string>] [-Name] <string> [-AsJob] [-Thrott
leLimit <int>] [-Confirm] [-WhatIf] [<CommonParameters>]

Invoke-WmiMethod [-Authentication {Default | None | Connect | Call | Packet
| PacketIntegrity | PacketPrivacy | Unchanged}] [-Authority <string>] [-Co
mputerName <string[]>] [-Credential <PSCredential>] [-EnableAllPrivileges]
[-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}]
[-Locale <string>] [-Namespace <string>] [-Name] <string> [-AsJob] [-Thrott
leLimit <int>] [-Confirm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Invoke-WmiMethod cmdlet calls WMI methods.

PARAMETERS
-ArgumentList <Object[]>
Specifies the parameters to pass to the called method. The value of thi
s parameter must be an array of objects and they must appear in the ord
er required by the called method.

Important: A second value of $null is required, otherwise the command w
ill generate an error, such as "Unable to cast object of type 'System.B
yte' to type 'System.Array'.".

An example using an array of objects ($binSD) followed by a null value
($null) follows:

PS C:\> $acl = get-acl test.txt
PS C:\> $binSD = $acl.GetSecurityDescriptorBinaryForm()
PS C:\> invoke-wmimethod -class Win32_SecurityDescriptorHelper -Name Bi
narySDToSDDL -argumentlist $binSD, $null

-AsJob [<SwitchParameter>]
Runs the command as a background job. Use this parameter to run command
s that take a long time to finish.

When you use the AsJob parameter, the command returns an object that re
presents the background job and then displays the command prompt. You c
an continue to work in the session while the job finishes. If Invoke-Wm
iMethod is used against a remote computer, the job is created on the lo
cal computer, and the results from remote computers are automatically r
eturned to the local computer. To manage the job, use the cmdlets that
contain the Job noun (the Job cmdlets). To get the job results, use the
Receive-Job cmdlet.

Note: To use this parameter with remote computers, the local and remote
computers must be configured for remoting. Additionally, you must star
t Windows PowerShell by using the "Run as administrator" option in Wind
ows Vista and later versions of Windows. For more information, see abou
t_Remote_Requirements.

For more information about Windows PowerShell background jobs, see abou
t_Jobs and about_Remote_Jobs.

-Authentication <AuthenticationLevel>
Specifies the authentication level to be used with the WMI connection.
Valid values are:

-1: Unchanged
0: Default
1: None (No authentication in performed.)
2: Connect (Authentication is performed only when the client establishe
s a relationship with the application.)
3: Call (Authentication is performed only at the beginning of each call
when the application receives the request.)
4: Packet (Authentication is performed on all the data that is received
from the client.)
5: PacketIntegrity (All the data that is transferred between the client
and the application is authenticated and verified.)
6: PacketPrivacy (The properties of the other authentication levels are
used, and all the data is encrypted.)

-Authority <string>
Specifies the authority to use to authenticate the WMI connection. You
can specify standard NTLM or Kerberos authentication. To use NTLM, set
the authority setting to ntlmdomain:<DomainName>, where <DomainName> id
entifies a valid NTLM domain name. To use Kerberos, specify kerberos:<D
omainName\ServerName>. You cannot include the authority setting when yo
u connect to the local computer.

-Class <string>
Specifies the WMI class that contains a static method to call.

-ComputerName <string[]>
Specifies the computer against which you want to run the management ope
ration. The value can be a fully qualified domain name, a NetBIOS name,
or an Internet Protocol (IP) address. Use the local computer name, use
localhost, or use a dot (.) to specify the local computer. The local c
omputer is the default. When the remote computer is in a different dom
ain from the user, a fully qualified domain name is required. You can a
lso set the value of this parameter by piping the value to the paramete
r.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user. Type a user name, such as "User01", "Dom
ain01\User01", or User@Contoso.com. Or, enter a PSCredential object, su
ch as an object that is returned by the Get-Credential cmdlet. When you
type a user name, you will be prompted for a password.

-EnableAllPrivileges [<SwitchParameter>]
Enables all the privileges of the current user before the command makes
the WMI call.

-Impersonation <ImpersonationLevel>
Specifies the impersonation level to use. Valid values are:

0: Default (Reads the local registry for the default impersonation leve
l, which is usually set to "3: Impersonate".)
1: Anonymous (Hides the credentials of the caller.)
2: Identify (Allows objects to query the credentials of the caller.)
3: Impersonate (Allows objects to use the credentials of the caller.)
4: Delegate (Allows objects to permit other objects to use the credenti
als of the caller.)

-InputObject <ManagementObject>
Specifies a ManagementObject object to use as input. When this paramete
r is used, all other parameters except the Flag and Argument parameters
are ignored.

-Locale <string>
Specifies the preferred locale for WMI objects. Specify the value of th
e Locale parameter as an array in the MS_<LCID> format in the preferred
order.

-Name <string>
Specifies the name of the method to be invoked. This parameter is manda
tory and cannot be null or empty.

-Namespace <string>
When used with the Class parameter, this parameter specifies the WMI re
pository namespace where the referenced WMI class or object is located.

-Path <string>
Specifies the WMI object path of a WMI class, or specifies the WMI obje
ct path of an instance of a WMI class. The class or the instance that y
ou specify must contain the method that is specified in the Name parame
ter.

-ThrottleLimit <int>
Allows the user to specify a throttling value for the number of WMI ope
rations that can be executed simultaneously. This parameter is used tog
ether with the AsJob parameter. The throttle limit applies only to the
current command, not to the session or to the computer.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>invoke-wmimethod -path win32_process -name create -argumentlist notep
ad.exe

__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ProcessId : 4844
ReturnValue : 0

Description
-----------
This command starts an instance of Notepad by calling the Create method of
the Win32_Process class.

Note: The ReturnValue property is populated with a 0, and the ProcessId pro
perty is populated with an integer (the next process ID number) if the comm
and is completed.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>invoke-wmimethod -path "CIM_DataFile.Name='C:\scripts\test.txt'" -Nam
e Rename -ArgumentList "C:\scripts\test_bu.txt"

__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0

Description
-----------
This command renames a file. It uses the Path parameter to reference an ins
tance of the CIM_DataFile class. Then, it applies the Rename method to that
particular instance.

Note: The ReturnValue property is populated with a 0 if the command is comp
leted.




REMARKS
To see the examples, type: "get-help Invoke-WmiMethod -examples".
For more information, type: "get-help Invoke-WmiMethod -detailed".
For technical information, type: "get-help Invoke-WmiMethod -full".

J:

NAME
Join-Path

SYNOPSIS
Combines a path and a child path into a single path. The provider supplies
the path delimiters.


SYNTAX
Join-Path [-Path] <string[]> [-ChildPath] <string> [-Credential <PSCredenti
al>] [-Resolve] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The Join-Path cmdlet combines a path and child-path into a single path. The
provider supplies the path delimiters.

PARAMETERS
-ChildPath <string>
Specifies the elements to append to the value of Path. Wildcards are pe
rmitted. The ChildPath parameter is required, although the parameter na
me ("ChildPath") is optional.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01". Or, enter a PS
Credential object, such as one generated by the Get-Credential cmdlet.
If you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Path <string[]>
Specifies the main path (or paths) to which the child-path is appended.
Wildcards are permitted.

The value of Path determines which provider joins the paths and adds th
e path delimiters. The Path parameter is required, although the paramet
er name ("Path") is optional.

-Resolve [<SwitchParameter>]
Displays the items that are referenced by the joined path.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>join-path -path c:\win* -childpath System*

Description
-----------
This command uses Join-Path to combine the "c:\Win*" path with the "System*
" child path. The Windows PowerShell file system provider, FileSystem joins
the path and adds the "\" delimiter.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>join-path c:\win* System* -resolve

Description
-----------
This command displays the files and folders that are referenced by joining
the "c:\Win*" path and the "System*" child path. It displays the same files
and folders as Get-ChildItem, but it displays the fully qualified path to
each item. In this command, the Path and ChildPath optional parameter names
are omitted.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>PS HKLM:\> join-path System *ControlSet* -resolve

Description
-----------
This command displays the registry keys in the HKLM\System registry subkey
that include "ControlSet". This example shows how to use Join-Path with the
Windows PowerShell registry provider.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>join-path -path C:, D:, E:, F: -childpath New

Description
-----------
This command uses Join-Path to combine multiple path roots with a child pat
h.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-psdrive -psprovider filesystem | foreach {$_.root} | join-path -c
hildpath Subdir

Description
-----------
This command combines the roots of each Windows PowerShell file system driv
e in the console with the Subdir child path.

The command uses the Get-PSDrive cmdlet to get the Windows PowerShell drive
s supported by the FileSystem provider. The ForEach statement selects only
the Root property of the PSDriveInfo objects and combines it with the speci
fied child path.

The output shows that the Windows PowerShell drives on the computer include
d a drive mapped to the C:\Program Files directory.




REMARKS
To see the examples, type: "get-help Join-Path -examples".
For more information, type: "get-help Join-Path -detailed".
For technical information, type: "get-help Join-Path -full".

K:

NAME
Stop-Process

SYNOPSIS
Stops one or more running processes.


SYNTAX
Stop-Process [-Id] <Int32[]> [-Force] [-PassThru] [-Confirm] [-WhatIf] [<Co
mmonParameters>]

Stop-Process -InputObject <Process[]> [-Force] [-PassThru] [-Confirm] [-Wha
tIf] [<CommonParameters>]

Stop-Process -Name <string[]> [-Force] [-PassThru] [-Confirm] [-WhatIf] [<C
ommonParameters>]


DESCRIPTION
The Stop-Process cmdlet stops one or more running processes. You can specif
y a process by process name or process ID (PID), or pass a process object t
o Stop-Process. Stop-Process works only on processes running on the local
computer.

On Windows Vista and later versions of Windows, to stop a process that is n
ot owned by the current user, you must start Windows PowerShell with the "R
un as administrator" option. Also, you are prompted for confirmation unles
s you use the Force parameter.

PARAMETERS
-Force [<SwitchParameter>]
Stops the specified processes without prompting for confirmation. By de
fault, Stop-Process prompts for confirmation before stopping any proces
s that is not owned by the current user.

To find the owner of a process, use the Get-WmiMethod cmdlet to get a W
in32_Process object that represents the process, and then use the GetOw
ner method of the object.

-Id <Int32[]>
Specifies the process IDs of the processes to be stopped. To specify mu
ltiple IDs, use commas to separate the IDs. To find the PID of a proces
s, type "get-process". The parameter name ("Id") is optional.

-InputObject <Process[]>
Stops the processes represented by the specified process objects. Enter
a variable that contains the objects, or type a command or expression
that gets the objects.

-Name <string[]>
Specifies the process names of the processes to be stopped. You can typ
e multiple process names (separated by commas) or use wildcard characte
rs.

-PassThru [<SwitchParameter>]
Returns an object representing the process. By default, this cmdlet doe
s not generate any output.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>stop-process -name notepad

Description
-----------
This command stops all instances of the Notepad process on the computer. (E
ach instance of Notepad runs in its own process.) It uses the Name paramete
r to specify the processes, all of which have the same name. If you were to
use the ID parameter to stop the same processes, you would have to list th
e process IDs of each instance of Notepad.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>stop-process -id 3952 -confirm -passthru

Confirm
Are you sure you want to perform this action?
Performing operation "Stop-Process" on Target "notepad (3952)".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):y
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
41 2 996 3212 31 3952 notepad

Description
-----------
This command stops a particular instance of the Notepad process. It uses th
e process ID, 3952, to identify the process. The Confirm parameter directs
Windows PowerShell to prompt the user before stopping the process. Because
the prompt includes the process name, as well as its ID, this is best pract
ice. The PassThru parameter passes the process object to the formatter for
display. Without this parameter, there would be no display after a Stop-Pro
cess command.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>calc

c:\PS>$p = get-process calc

c:\PS>stop-process -inputobject $p

c:\PS>get-process | where-object {$_.HasExited}

Description
-----------
This series of commands starts and stops the Calc process and then detects
processes that have stopped.

The first command ("calc") starts an instance of the calculator. The second
command ("$p = get-process calc"), uses the Get-Process cmdlet to get an o
bject representing the Calc process and store it in the $p variable. The th
ird command ("stop-process -inputobject $p") uses the Stop-Process cmdlet t
o stop the Calc process. It uses the InputObject parameter to pass the obje
ct to Stop-Process.

The last command gets all of the processes on the computer that were runnin
g but that are now stopped. It uses the Get-Process cmdlet to get all of th
e processes on the computer. The pipeline operator (|) passes the results t
o the Where-Object cmdlet, which selects the ones where the value of the Ha
sExited property is TRUE. HasExited is just one property of process objects
. To find all the properties, type "get-process | get-member".




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-process lsass | stop-process

Stop-Process : Cannot stop process 'lsass (596)' because of the following e
rror: Access is denied
At line:1 char:34
+ get-process lsass | stop-process <<<<

[ADMIN]: C:\PS> get-process lsass | stop-process
Warning!
Are you sure you want to perform this action?
Performing operation 'Stop-Process' on Target 'lsass(596)'
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (defa
ult is "Y"):

[ADMIN]: C:\PS> get-process lsass | stop-process -force
[ADMIN]: C:\PS>

Description
-----------
These commands show the effect of using the Force parameter to stop a proce
ss that is not owned by the user.

The first command uses the Get-Process cmdlet to get the Lsass process. A p
ipeline operator sends the process to the Stop-Process cmdlet to stop it. A
s shown in the sample output, the first command fails with an "Access denie
d" message, because this process can be stopped only by a member of the Adm
inistrator's group on the computer.

When Windows PowerShell is opened with the "Run as administrator" option, a
nd the command is repeated, Windows PowerShell prompts you for confirmation
.

The second command uses the Force parameter to suppress the prompt. As a re
sult, the process is stopped without confirmation.




REMARKS
To see the examples, type: "get-help Stop-Process -examples".
For more information, type: "get-help Stop-Process -detailed".
For technical information, type: "get-help Stop-Process -full".

L:

NAME
Limit-EventLog

SYNOPSIS
Sets the event log properties that limit the size of the event log and the
age of its entries.


SYNTAX
Limit-EventLog [-LogName] <string[]> [-ComputerName <string[]>] [-MaximumSi
ze <Int64>] [-OverFlowAction {OverwriteAsNeeded | OverwriteOlder | DoNotOve
rwrite}] [-RetentionDays <int>] [-Confirm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The Limit-EventLog cmdlet sets the maximum size of a classic event log, how
long each event must be retained, and what happens when the log reaches it
s maximum size. You can use it to limit the event logs on local or remote c
omputers.

The cmdlets that contain the EventLog noun (the EventLog cmdlets) work only
on classic event logs. To get events from logs that use the Windows Event
Log technology in Windows Vista and later versions of Windows, use Get-WinE
vent.

PARAMETERS
-ComputerName <string[]>
Specifies a remote computer. The default is the local computer.

Type the NetBIOS name, an Internet Protocol (IP) address, or a fully qu
alified domain name of a remote computer. To specify the local computer
, type the computer name, a dot (.), or "localhost".

This parameter does not rely on Windows PowerShell remoting. You can us
e the ComputerName parameter of Limit-EventLog even if your computer is
not configured to run remote commands.

-LogName <string[]>
Specifies the event logs. Enter the log name (the value of the Log prop
erty; not the LogDisplayName) of one or more event logs , separated by
commas. Wildcard characters are not permitted. This parameter is requi
red.

-MaximumSize <Int64>
Specifies the maximum size of the event logs in bytes. Enter a value be
tween 64 kilobytes (KB) and 4 gigabytes (GB). The value must be divisib
le by 64 KB (65536).

This parameter specifies the value of the MaximumKilobytes property of
the System.Diagnostics.EventLog object that represents a classic event
log.

-OverFlowAction <OverflowAction>
Specifies what happens when the event log reaches its maximum size.

Valid values are:
-- DoNotOverwrite: Existing entries are retained and new entries are d
iscarded.
-- OverwriteAsNeeded: Each new entry overwrites the oldest entry.
-- OverwriteOlder: New events overwrite events older than the value sp
ecified by the MinimumRetentionDays property. If there are no events ol
der than specified by the MinimumRetentionDays property value, new even
ts are discarded.

This parameter specifies the value of the OverflowAction property of th
e System.Diagnostics.EventLog object that represents a classic event lo
g.

-RetentionDays <int>
Specifies the minimum number of days that an event must remain in the e
vent log.

This parameter specifies the value of the MinimumRetentionDays property
of the System.Diagnostics.EventLog object that represents a classic ev
ent log.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>limit-eventLog -logname "Windows PowerShell" -MaximumSize 20KB

Description
-----------
This command increases the maximum size of the Windows PowerShell event log
on the local computer to 20480 kilobytes (KB) (20 KB).




-------------------------- EXAMPLE 2 --------------------------

C:\PS>limit-eventlog -logname Security -comp Server01, Server02 -retentionD
ays 7

Description
-----------
This command ensures that events in the Security log on the Server01 and Se
rver02 computers are retained for at least 7 days.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$logs = get-eventlog -list | foreach {$_.log}

C:\PS> limit-eventlog -overflowaction OverwriteOlder -logname $logs

C:\PS> get-eventlog -list

Max(K) Retain OverflowAction Entries Log
------ ------ -------------- ------- ---
15,168 0 OverwriteOlder 3,412 Application
512 0 OverwriteOlder 0 DFS Replication
512 0 OverwriteOlder 17 DxStudio
10,240 7 OverwriteOlder 0 HardwareEvents
512 0 OverwriteOlder 0 Internet Explorer
512 0 OverwriteOlder 0 Key Management Service
16,384 0 OverwriteOlder 4 ODiag
16,384 0 OverwriteOlder 389 OSession
Security
15,168 0 OverwriteOlder 19,360 System
15,360 0 OverwriteOlder 15,828 Windows PowerShell

Description
-----------
These commands change the overflow action of all event logs on the local co
mputer to "OverwriteOlder".

The first command gets the log names of all of the logs on the local comput
er. The second command sets the overflow action. The third command displays
the results.




REMARKS
To see the examples, type: "get-help Limit-EventLog -examples".
For more information, type: "get-help Limit-EventLog -detailed".
For technical information, type: "get-help Limit-EventLog -full".

NAME
Out-Printer

SYNOPSIS
Sends output to a printer.


SYNTAX
Out-Printer [[-Name] <string>] [-InputObject <psobject>] [<CommonParameters
>]


DESCRIPTION
The Out-Printer cmdlet sends output to the default printer or to an alterna
te printer, if one is specified.

PARAMETERS
-InputObject <psobject>
Specifies the objects to be sent to the printer. Enter a variable that
contains the objects, or type a command or expression that gets the obj
ects.

-Name <string>
Specifies the alternate printer. The parameter name ("Name") is option
al.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-content $pshome\about_signing.help.txt | Out-Printer

Description
-----------
This command prints the content of the about_Signing Help topic to the defa
ult printer. This example shows you how to print a file, even though Out-Pr
inter does not have a Path parameter.

The command uses the Get-Content cmdlet to get the contents of the Help top
ic. The path includes $pshome, a built-in variable that stores the installa
tion directory for Windows PowerShell. A pipeline operator (|) passes the r
esults to Out-Printer, which sends it to the default printer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>"Hello, World" | out-printer -name "\\Server01\Prt-6B Color"

Description
-----------
This command prints "Hello, World" to the "Prt-6B Color" printer on Server0
1. This command uses the Name parameter to specify the alternate printer. B
ecause the parameter name is optional, you can omit it.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$h = get-help -full get-wmiobject

C:\PS> out-printer -inputobject $h

Description
-----------
These commands print the full version of the Help topic for Get-WmiObject.
The first command uses the Get-Help cmdlet to get the full version of the H
elp topic for Get-WmiObject and stores it in the $h variable. The second co
mmand sends the content to the default printer. It uses the InputObject par
ameter to pass the value of the $h variable to Out-Printer.




REMARKS
To see the examples, type: "get-help Out-Printer -examples".
For more information, type: "get-help Out-Printer -detailed".
For technical information, type: "get-help Out-Printer -full".

NAME
Get-ChildItem

SYNOPSIS
Gets the items and child items in one or more specified locations.


SYNTAX
Get-ChildItem [[-Path] <string[]>] [[-Filter] <string>] [-Exclude <string[]
>] [-Force] [-Include <string[]>] [-Name] [-Recurse] [-UseTransaction] [<Co
mmonParameters>]

Get-ChildItem [-LiteralPath] <string[]> [[-Filter] <string>] [-Exclude <str
ing[]>] [-Force] [-Include <string[]>] [-Name] [-Recurse] [-UseTransaction]
[<CommonParameters>]


DESCRIPTION
The Get-ChildItem cmdlet gets the items in one or more specified locations.
If the item is a container, it gets the items inside the container, known
as child items. You can use the Recurse parameter to get items in all child
containers.

A location can be a file system location, such as a directory, or a locatio
n exposed by another provider, such as a registry hive or a certificate sto
re.

PARAMETERS
-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to get items that cannot otherwise not be accessed by
the user, such as hidden or system files. Implementation varies from p
rovider to provider. For more information, see about_Providers. Even us
ing the Force parameter, the cmdlet cannot override security restrictio
ns.

-Include <string[]>
Retrieves only the specified items. The value of this parameter qualifi
es the Path parameter. Enter a path element or pattern, such as "*.txt"
. Wildcards are permitted.

The Include parameter is effective only when the command includes the R
ecurse parameter or the path leads to the contents of a directory, such
as C:\Windows\*, where the wildcard character specifies the contents o
f the C:\Windows directory.

-LiteralPath <string[]>
Specifies a path to one or more locations. Unlike Path, the value of Li
teralPath is used exactly as it is typed. No characters are interpreted
as wildcards. If the path includes escape characters, enclose it in si
ngle quotation marks. Single quotation marks tell Windows PowerShell no
t to interpret any characters as escape sequences.

-Name [<SwitchParameter>]
Retrieves only the names of the items in the locations. If you pipe the
output of this command to another command, only the item names are sen
t.

-Path <string[]>
Specifies a path to one or more locations. Wildcards are permitted. The
default location is the current directory (.).

-Recurse [<SwitchParameter>]
Gets the items in the specified locations and in all child items of the
locations.

Recurse works only when the path points to a container that has child i
tems, such as C:\Windows or C:\Windows\*, and not when it points to ite
ms that do not have child items, such as C:\Windows\*.exe.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-childitem

Description
-----------
This command gets the child items in the current location. If the location
is a file system directory, it gets the files and sub-directories in the cu
rrent directory. If the item does not have child items, this command return
s to the command prompt without displaying anything.

The default display lists the mode (attributes), last write time, file size
(length), and the name of the file. The valid values for mode are d (direc
tory), a (archive), r (read-only), h (hidden), and s (system).




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-childitem . -include *.txt -recurse -force

Description
-----------
This command retrieves all of the .txt files in the current directory and i
ts subdirectories. The dot (.) represents the current directory and the Inc
lude parameter specifies the file name extension. The Recurse parameter dir
ects Windows PowerShell to retrieve objects recursively, and it indicates t
hat the subject of the command is the specified directory and its contents.
The force parameter adds hidden files to the display.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-childitem c:\windows\logs\* -include *.txt -exclude A*

Description
-----------
This command lists the .txt files in the Logs subdirectory, except for thos
e whose names start with the letter A. It uses the wildcard character (*) t
o indicate the contents of the Logs subdirectory, not the directory contain
er. Because the command does not include the Recurse parameter, Get-ChildIt
em does not include the content of directory automatically; you need to spe
cify it.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-childitem registry::hklm\software

Description
-----------
This command retrieves all of the registry keys in the HKEY_LOCAL_MACHINE\S
OFTWARE key in the registry of the local computer.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-childitem -name

Description
-----------
This command retrieves only the names of items in the current directory.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-childitem cert:\. -recurse -codesigningcert

Description
-----------
This command gets all of the certificates in the certificate store that hav
e code-signing authority.

The command uses the Get-ChildItem cmdlet. The path specifies the Cert: dri
ve exposed by the Windows PowerShell certificate provider. The backslash (\
) symbol specifies a subdirectory of the certificate store and the dot (.)
represents the current directory, which would be the root directory of the
certificate store. The Recurse parameter specifies a recursive search.

The CodeSigningCertificate parameter is a dynamic parameter that gets only
certificates with code-signing authority. For more information, type "get-h
elp certificate".




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-childitem * -include *.exe

Description
-----------
This command retrieves all of the items in the current directory with a ".e
xe" file name extension. The wildcard character (*) represents the contents
of the current directory (not the container). When using the Include param
eter without the Recurse parameter, the path must point to contents, not a
container.




REMARKS
To see the examples, type: "get-help Get-ChildItem -examples".
For more information, type: "get-help Get-ChildItem -detailed".
For technical information, type: "get-help Get-ChildItem -full".

M:

NAME
Get-Help

SYNOPSIS
Displays information about Windows PowerShell commands and concepts.


SYNTAX
Get-Help [-Full] [[-Name] <string>] [-Category <string[]>] [-Component <str
ing[]>] [-Functionality <string[]>] [-Online] [-Path <string>] [-Role <stri
ng[]>] [<CommonParameters>]

Get-Help [-Detailed] [[-Name] <string>] [-Category <string[]>] [-Component
<string[]>] [-Functionality <string[]>] [-Online] [-Path <string>] [-Role <
string[]>] [<CommonParameters>]

Get-Help [-Examples] [[-Name] <string>] [-Category <string[]>] [-Component
<string[]>] [-Functionality <string[]>] [-Online] [-Path <string>] [-Role <
string[]>] [<CommonParameters>]

Get-Help [-Parameter <string>] [[-Name] <string>] [-Category <string[]>] [-
Component <string[]>] [-Functionality <string[]>] [-Online] [-Path <string>
] [-Role <string[]>] [<CommonParameters>]


DESCRIPTION
The Get-Help cmdlet displays information about Windows PowerShell concepts
and commands, including cmdlets, providers, functions and scripts. To get a
list of all cmdlet help topic titles, type "get-help *".

If you type "Get-Help" followed by the exact name of a help topic, or by a
word unique to a help topic, Get-Help displays the topic contents. If you e
nter a word or word pattern that appears in several help topic titles, Get-
Help displays a list of the matching titles. If you enter a word that does
not appear in any help topic titles, Get-Help displays a list of topics tha
t include that word in their contents.

In addition to "get-help", you can also type "help" or "man", which display
s one screen of text at a time, or "<cmdlet-name> -?", which is identical t
o Get-Help but works only for cmdlets.

You can display the entire help file or selected parts of the file, such as
the syntax, parameters, or examples. You can also use the Online parameter
to display an online version of a help file in your Internet browser. Thes
e parameters have no effect on conceptual help topics.

Conceptual help topics in Windows PowerShell begin with "about_", such as "
about_Comparison_Operators". To see all "about_" topics, type "get-help abo
ut_*". To see a particular topic, type "get-help about_<topic-name>", such
as "get-help about_Comparison_Operators".

PARAMETERS
-Category <string[]>
Displays help for items in the specified category. Valid values are Ali
as, Cmdlet, Provider, and HelpFile. Conceptual topics are in the HelpFi
le category.

Category is a property of the MamlCommandHelpInfo object that Get-Help
returns. This parameter has no effect on displays of conceptual ("about
_") help.

-Component <string[]>
Displays a list of tools with the specified component value, such as "E
xchange." Enter a component name. Wildcards are permitted.

Component is a property of the MamlCommandHelpInfo object that Get-Help
returns. This parameter has no effect on displays of conceptual ("Abou
t_") help.

-Detailed [<SwitchParameter>]
Adds parameter descriptions and examples to the basic help display.

This parameter has no effect on displays of conceptual ("About_") help.

-Examples [<SwitchParameter>]
Displays only the name, synopsis, and examples. To display only the exa
mples, type "(get-help <cmdlet-name>).examples".

This parameter has no effect on displays of conceptual ("About_") help.

-Full [<SwitchParameter>]
Displays the entire help file for a cmdlet, including parameter descrip
tions and attributes, examples, input and output object types, and addi
tional notes.

This parameter has no effect on displays of conceptual ("About_") help.

-Functionality <string[]>
Displays help for items with the specified functionality. Enter the fun
ctionality. Wildcards are permitted.

Functionality is a property of the MamlCommandHelpInfo object that Get-
Help returns. This parameter has no effect on displays of conceptual ("
About_") help.

-Name <string>
Requests help about the specified tool or conceptual topic. Enter a cmd
let, provider, script, or function name, such as Get-Member, a conceptu
al topic name, such as "about_Objects", or an alias, such as "ls". Wild
cards are permitted in cmdlet and provider names, but you cannot use wi
ldcards to find the names of function help and script help topics.

To get help for a script that is not located in a path that is listed i
n the Path environment variable, type the path and file name of the scr
ipt .

If you enter the exact name of a help topic, Get-Help displays the topi
c contents. If you enter a word or word pattern that appears in several
help topic titles, Get-Help displays a list of the matching titles. If
you enter a word that does not match any help topic titles, Get-Help d
isplays a list of topics that include that word in their contents.

The names of conceptual topics, such as about_Objects, must be entered
in English, even in non-English versions of Windows PowerShell.

-Online [<SwitchParameter>]
Displays the online version of a help topic in the default Internet bro
wser. This parameter is valid only for cmdlet, function, and script hel
p topics.

Get-Help uses the Internet address (Uniform Resource Identifier [URI])
that appears in the first item of the Related Links section of a cmdlet
, function, or script help topic. This parameter works only when the he
lp topic includes a URI that begins with "Http" or "Https" and an Inter
net browser is installed on the system.

For information about supporting this feature in help topics that you w
rite, see about_Comment_Based_Help, and see "How to Write Cmdlet Help"
in the MSDN (Microsoft Developer Network) library at http://go.microsof
t.com/fwlink/?LinkID=123415.

-Parameter <string>
Displays only the detailed descriptions of the specified parameters. Wi
ldcards are permitted.

This parameter has no effect on displays of conceptual ("About_") help.

-Path <string>
Gets help that explains how the cmdlet works in the specified provider
path. Enter a Windows PowerShell provider path.

This parameter gets a customized version of a cmdlet help topic that ex
plains how the cmdlet works in the specified Windows PowerShell provide
r path. This parameter is effective only for help about a provider cmdl
et and only when the provider includes a custom version of the provider
cmdlet help topic.

To see the custom cmdlet help for a provider path, go to the provider p
ath location and enter a Get-Help command or, from any path location, u
se the Path parameter of Get-Help to specify the provider path. For mor
e information, see about_Providers.

-Role <string[]>
Displays help customized for the specified user role. Enter a role. Wil
dcards are permitted.

Enter the role that the user plays in an organization. Some cmdlets dis
play different text in their help files based on the value of this para
meter. This parameter has no effect on help for the core cmdlets.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-help

Description
-----------
This command displays help about the Windows PowerShell help system.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-help *

Description
-----------
This command displays a list of all help files in the Windows PowerShell he
lp system.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-help get-alias

C:\PS>help get-alias

C:\PS>get-alias -?

Description
-----------
These commands display basic information about the get-alias cmdlet. The "G
et-Help" and "-?" commands display the information on a single page. The "H
elp" command displays the information one page at a time.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-help about_*

Description
-----------
This command displays a list of the conceptual topics included in Windows P
owerShell help. All of these topics begin with the characters "about_". To
display a particular help file, type "get-help <topic-name>, for example, "
get-help about_signing".




-------------------------- EXAMPLE 5 --------------------------

C:\PS>get-help ls -detailed

Description
-----------
This command displays detailed help for the Get-ChildItem cmdlet by specify
ing one of its aliases, "ls." The Detailed parameter requests the detailed
view of the help file, which includes parameter descriptions and examples.
To see the complete help file for a cmdlet, use the Full parameter.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-help format-string -full

Description
-----------
This command displays the full view help for the Format-String cmdlet. The
full view of help includes parameter descriptions, examples, and a table of
technical details about the parameters.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>get-help start-service -examples

Description
-----------
This command displays examples of using start-service in Windows PowerShell
commands.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>get-help get-childitem -parameter f*

Description
-----------
This command displays descriptions of the parameters of the Get-ChildItem c
mdlet that begin with "f" (filter and force). For descriptions of all param
eters, type "get-help get-childitem parameter*".




-------------------------- EXAMPLE 9 --------------------------

C:\PS>(get-help write-output).syntax

Description
-----------
This command displays only the syntax of the Write-Output cmdlet.

Syntax is one of many properties of help objects; others are description, d
etails, examples, and parameters. To find all properties and methods of hel
p objects, type "get-help <cmdlet-name> | get-member"; for example, "get-he
lp start-service | get member".




-------------------------- EXAMPLE 10 --------------------------

C:\PS>(get-help trace-command).alertset

Description
-----------
This command displays the notes about the cmdlet. The notes are stored in t
he alertSet property of the help object.

The notes include conceptual information and tips for using the cmdlet. By
default, the notes are displayed only when you use the Full parameter of Ge
t-Help, but you can also display them by using the alertSet property.




-------------------------- EXAMPLE 11 --------------------------

C:\PS>get-help add-member -full | out-string -stream | select-string -patte
rn clixml

Description
-----------
This example shows how to search for a word in particular cmdlet help topic
. This command searches for the word "clixml" in the full version of the he
lp topic for the Add-Member cmdlet.

Because the Get-Help cmdlet generates a MamlCommandHelpInfo object, not a s
tring, you need to use a command that transforms the help topic content int
o a string, such as Out-String or Out-File.




-------------------------- EXAMPLE 12 --------------------------

C:\PS>get-help get-member -online

Description
-----------
This command displays the online version of the help topic for the Get-Memb
er cmdlet.




-------------------------- EXAMPLE 13 --------------------------

C:\PS>get-help remoting

Description
-----------
This command displays a list of topics that include the word "remoting" in
their contents.

When you enter a word that does not appear in any topic title, Get-Help dis
plays a list of topics that include that word.




-------------------------- EXAMPLE 14 --------------------------

C:\PS>get-help get-item -path SQLSERVER:\DataCollection

NAME
Get-Item

SYNOPSIS
Gets a collection of Server objects for the local computer and any comp
uters to which you have made a SQL Server PowerShell connection.
...

C:\PS> cd SQLSERVER:\DataCollection
C:\PS> SQLSERVER:\DataCollection> get-help get-item


NAME
Get-Item

SYNOPSIS
Gets a collection of Server objects for the local computer and any comp
uters to which you have made a SQL Server PowerShell connection.
...


C:\PS> Get-Item

NAME
Get-Item

SYNOPSIS
Gets the item at the specified location.

...

Description
-----------
This example shows how to get help for the Get-Item cmdlet that explains ho
w to use the cmdlet in the DataCollection node of the Windows PowerShell SQ
L Server provider.

The example shows two ways of getting the custom help for Get-Item.

The first command uses the Path parameter of Get-Help to specify the provid
er path. This command can be entered at any path location.

The second command uses the Set-Location cmdlet (alias = "cd") to go to the
provider path. From that location, even without the Path parameter, the Ge
t-Help command gets the custom help for the provider path.

The third command shows that a Get-Help command in a file system path, and
without the Path parameter, gets the standard help for the Get-Item cmdlet.




-------------------------- EXAMPLE 15 --------------------------

C:\PS>get-help c:\ps-test\MyScript.ps1

Description
-----------
This command gets help for the MyScript.ps1 script. For information about w
riting help for your functions and scripts, see about_Comment_Based_Help.




REMARKS
To see the examples, type: "get-help Get-Help -examples".
For more information, type: "get-help Get-Help -detailed".
For technical information, type: "get-help Get-Help -full".

NAME
New-Item

SYNOPSIS
Creates a new item.


SYNTAX
New-Item [-Path] <string[]> [-Credential <PSCredential>] [-Force] [-ItemTyp
e <string>] [-Value <Object>] [-Confirm] [-WhatIf] [-UseTransaction] [<Comm
onParameters>]

New-Item -Name <string> [[-Path] <string[]>] [-Credential <PSCredential>] [
-Force] [-ItemType <string>] [-Value <Object>] [-Confirm] [-WhatIf] [-UseTr
ansaction] [<CommonParameters>]


DESCRIPTION
The New-Item cmdlet creates a new item and sets its value. The types of ite
ms that can be created depend upon the location of the item. For example, i
n the file system, New-Item is used to create files and folders. In the reg
istry, New-Item creates registry keys and entries.

New-Item can also set the value of the items that it creates. For example,
when creating a new file, New-Item can add initial content to the file.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell

-Force [<SwitchParameter>]
Allows the cmdlet to create an item that writes over an existing read-o
nly item. Implementation varies from provider to provider. For more inf
ormation, see about_Providers. Even using the Force parameter, the cmdl
et cannot override security restrictions.

-ItemType <string>
Specifies the provider-specified type of the new item.

-Name <string>
Specifies the name of the new item. You can use this parameter to speci
fy the name of the new item, or include the name in the value of the Pa
th parameter.

-Path <string[]>
Specifies the path to the location of the new item. Wildcards are permi
tted.

You can specify the name of the new item in the Name parameter, or incl
ude it in the Path parameter.

-Value <Object>
Specifies the value of the new item. You can also pipe a value to New-I
tem.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-item -path . -name testfile1.txt -type "file" -value "This is a t
ext string."

Description
-----------
This command creates a text file named testfile1.txt in the current directo
ry. The dot (.) in the value of the Path parameter indicates the current di
rectory. The quoted text that follows the Value parameter is added to the f
ile as content.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>new-item -path c:\ -name logfiles -type directory

Description
-----------
This command creates a directory named Logfiles in the C: drive. The Type p
arameter specifies that the new item is a directory, not a file or other fi
le system object.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>new-item -path $profile -type file -force

Description
-----------
This command creates a Windows PowerShell profile in the path that is speci
fied by the $profile variable.

You can use profiles to customize Windows PowerShell. $Profile is an automa
tic (built-in) variable that stores the path and file name of the CurrentUs
er/CurrentHost profile. By default, the profile does not exist, even though
Windows PowerShell stores a path and file name for it.

In this command, the $profile variable represents the path to the file. The
Type parameter (or InfoType) specifies that the command creates a file. Th
e Force parameter lets you create a file in the profile path, even when the
directories in the path do not exist (Windows PowerShell creates them).

After you use this command to create a profile, you can enter aliases, func
tions, and scripts in the profile to customize your shell.

For more information, see about_Automatic_Variables and about_Profiles.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>new-item -type directory -path c:\ps-test\scripts

Description
-----------
This command creates a new Scripts directory in the C:\PS-Test directory.

The name of the new directory item, Scripts, is included in the value of th
e Path parameter, instead of being specified in the value of the Name param
eter. As indicated by the syntax, either command form is valid.




REMARKS
To see the examples, type: "get-help New-Item -examples".
For more information, type: "get-help New-Item -detailed".
For technical information, type: "get-help New-Item -full".

NAME
Measure-Object

SYNOPSIS
Calculates the numeric properties of objects, and the characters, words, an
d lines in string objects, such as files of text.


SYNTAX
Measure-Object [-Average] [-Maximum] [-Minimum] [-Sum] [[-Property] <string
[]>] [-InputObject <psobject>] [<CommonParameters>]

Measure-Object [-Character] [-IgnoreWhiteSpace] [-Line] [-Word] [[-Property
] <string[]>] [-InputObject <psobject>] [<CommonParameters>]


DESCRIPTION
The Measure-Object cmdlet calculates the property values of certain types o
f object. Measure-Object performs three types of measurements, depending on
the parameters in the command.
The Measure-Object cmdlet performs calculations on the property values of o
bjects. It can count objects and calculate the minimum, maximum, sum, and
average of the numeric values. For text objects, it can count and calculate
the number of lines, words, and characters.

PARAMETERS
-Average [<SwitchParameter>]
Displays the average value of the specified properties.

-Character [<SwitchParameter>]
Counts the number of characters in the input object.

-IgnoreWhiteSpace [<SwitchParameter>]
Ignores white space in word counts and character counts. By default, wh
ite space is not ignored.

-InputObject <psobject>
Specifies the objects to be measured. Enter a variable that contains th
e objects, or type a command or expression that gets the objects.

-Line [<SwitchParameter>]
Counts the number of lines in the input object.

-Maximum [<SwitchParameter>]
Displays the maximum value of the specified properties.

-Minimum [<SwitchParameter>]
Displays the minimum value of the specified properties.

-Property <string[]>
Specifies one or more numeric properties to measure. The default is the
Count (Length) property of the object.

-Sum [<SwitchParameter>]
Displays the sum of the values of the specified properties.

-Word [<SwitchParameter>]
Counts the number of words in the input object.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-childitem | measure-object

Description
-----------
This command counts the files and folders in the current directory.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-childitem | measure-object -property length -minimum -maximum -av
erage

Description
-----------
This command displays the minimum, maximum, and sum of the sizes of all fil
es in the current directory, and the average size of a file in the director
y.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-content C:\test.txt | measure-object -character -line -word

Description
-----------
This command displays the number of characters, words, and lines in the Tex
t.txt file.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-process | measure-object -property workingset -minimum -maximum -
average

Description
-----------
This command displays the minimum, maximum, and average sizes of the workin
g sets of the processes on the computer.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>import-csv d:\test\serviceyrs.csv | measure-object -property years -m
inimum -maximum -average

Description
-----------
This command calculates the average years of service of the employees of a
company.

The ServiceYrs.csv file is a CSV file that contains the employee number and
years of service of each employee. The first row in the table is a header
row of "EmpNo, Years".

When you use Import-Csv to import the file, the result is a PSCustomObject
with note properties of EmpNo and Years. You can use Measure-Object to calc
ulate the values of these properties, just like any other property of an ob
ject.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-childitem | measure-object -property psiscontainer -max -sum -min
-average

Count : 126
Average : 0.0634920634920635
Sum : 8
Maximum : 1
Minimum : 0
Property : PSIsContainer

Description
-----------
This example demonstrates the Measure-Object can measure Boolean values. In
this case, it uses the PSIsContainer Boolean property to measure the incid
ence of folders (vs. files) in the current directory.




REMARKS
To see the examples, type: "get-help Measure-Object -examples".
For more information, type: "get-help Measure-Object -detailed".
For technical information, type: "get-help Measure-Object -full".

NAME
Measure-Command

SYNOPSIS
Measures the time it takes to run script blocks and cmdlets.


SYNTAX
Measure-Command [-Expression] <scriptblock> [-InputObject <psobject>] [<Com
monParameters>]


DESCRIPTION
The Measure-Command cmdlet runs a script block or cmdlet internally, times
the execution of the operation, and returns the execution time.

PARAMETERS
-Expression <scriptblock>
Specifies the expression that is being timed. Enclose the expression in
curly braces ({}). The parameter name ("Expression") is optional.

-InputObject <psobject>
Specifies objects representing the expressions to be measured. Enter a
variable that contains the objects or type a command or expression that
gets the objects.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>Measure-Command { get-eventlog "windows powershell" }

Description
-----------
This command measures the time it takes to run a "get-eventlog" command tha
t gets the events in the Windows PowerShell event log.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>measure-command {get-childitem c:\windows -include *.txt -recurse}

Days : 0
Hours : 0
Minutes : 0
Seconds : 8
Milliseconds : 618
Ticks : 86182763
TotalDays : 9.9748568287037E-05
TotalHours : 0.00239396563888889
TotalMinutes : 0.143637938333333
TotalSeconds : 8.6182763
TotalMilliseconds : 8618.2763

C:\PS>measure-command {get-childitem c:\windows -filter "*.txt" -recurse}

Days : 0
Hours : 0
Minutes : 0
Seconds : 1
Milliseconds : 140
Ticks : 11409189
TotalDays : 1.32050798611111E-05
TotalHours : 0.000316921916666667
TotalMinutes : 0.019015315
TotalSeconds : 1.1409189
TotalMilliseconds : 1140.9189

Description
-----------
These commands show the value of using a provider-specific filter in Window
s PowerShell commands. The first command measures the time it takes to proc
ess a recursive Get-ChildItem command that uses the Include parameter. The
second command measures the time it takes to process a recursive Get-ChildI
tem command that uses the provider-specific Filter parameter.




REMARKS
To see the examples, type: "get-help Measure-Command -examples".
For more information, type: "get-help Measure-Command -detailed".
For technical information, type: "get-help Measure-Command -full".

NAME
Measure-Object

SYNOPSIS
Calculates the numeric properties of objects, and the characters, words, an
d lines in string objects, such as files of text.


SYNTAX
Measure-Object [-Average] [-Maximum] [-Minimum] [-Sum] [[-Property] <string
[]>] [-InputObject <psobject>] [<CommonParameters>]

Measure-Object [-Character] [-IgnoreWhiteSpace] [-Line] [-Word] [[-Property
] <string[]>] [-InputObject <psobject>] [<CommonParameters>]


DESCRIPTION
The Measure-Object cmdlet calculates the property values of certain types o
f object. Measure-Object performs three types of measurements, depending on
the parameters in the command.
The Measure-Object cmdlet performs calculations on the property values of o
bjects. It can count objects and calculate the minimum, maximum, sum, and
average of the numeric values. For text objects, it can count and calculate
the number of lines, words, and characters.

PARAMETERS
-Average [<SwitchParameter>]
Displays the average value of the specified properties.

-Character [<SwitchParameter>]
Counts the number of characters in the input object.

-IgnoreWhiteSpace [<SwitchParameter>]
Ignores white space in word counts and character counts. By default, wh
ite space is not ignored.

-InputObject <psobject>
Specifies the objects to be measured. Enter a variable that contains th
e objects, or type a command or expression that gets the objects.

-Line [<SwitchParameter>]
Counts the number of lines in the input object.

-Maximum [<SwitchParameter>]
Displays the maximum value of the specified properties.

-Minimum [<SwitchParameter>]
Displays the minimum value of the specified properties.

-Property <string[]>
Specifies one or more numeric properties to measure. The default is the
Count (Length) property of the object.

-Sum [<SwitchParameter>]
Displays the sum of the values of the specified properties.

-Word [<SwitchParameter>]
Counts the number of words in the input object.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>get-childitem | measure-object

Description
-----------
This command counts the files and folders in the current directory.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-childitem | measure-object -property length -minimum -maximum -av
erage

Description
-----------
This command displays the minimum, maximum, and sum of the sizes of all fil
es in the current directory, and the average size of a file in the director
y.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-content C:\test.txt | measure-object -character -line -word

Description
-----------
This command displays the number of characters, words, and lines in the Tex
t.txt file.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-process | measure-object -property workingset -minimum -maximum -
average

Description
-----------
This command displays the minimum, maximum, and average sizes of the workin
g sets of the processes on the computer.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>import-csv d:\test\serviceyrs.csv | measure-object -property years -m
inimum -maximum -average

Description
-----------
This command calculates the average years of service of the employees of a
company.

The ServiceYrs.csv file is a CSV file that contains the employee number and
years of service of each employee. The first row in the table is a header
row of "EmpNo, Years".

When you use Import-Csv to import the file, the result is a PSCustomObject
with note properties of EmpNo and Years. You can use Measure-Object to calc
ulate the values of these properties, just like any other property of an ob
ject.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>get-childitem | measure-object -property psiscontainer -max -sum -min
-average

Count : 126
Average : 0.0634920634920635
Sum : 8
Maximum : 1
Minimum : 0
Property : PSIsContainer

Description
-----------
This example demonstrates the Measure-Object can measure Boolean values. In
this case, it uses the PSIsContainer Boolean property to measure the incid
ence of folders (vs. files) in the current directory.




REMARKS
To see the examples, type: "get-help Measure-Object -examples".
For more information, type: "get-help Measure-Object -detailed".
For technical information, type: "get-help Measure-Object -full".

NAME
Move-Item

SYNOPSIS
Moves an item from one location to another.


SYNTAX
Move-Item [-LiteralPath] <string[]> [[-Destination] <string>] [-Credential
<PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include
<string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonPar
ameters>]

Move-Item [-Path] <string[]> [[-Destination] <string>] [-Credential <PSCred
ential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <strin
g[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters
>]


DESCRIPTION
The Move-Item cmdlet moves an item, including its properties, contents, and
child items, from one location to another location. The locations must be
supported by the same provider. For example, it can move a file or subdirec
tory from one directory to another or move a registry subkey from one key t
o another. When you move an item, it is added to the new location and delet
ed from its original location.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Destination <string>
Specifies the path to the location where the items are being moved. The
default is the current directory. Wildcards are permitted, but the res
ult must specify a single location.

To rename the item being moved, specify a new name in the value of the
Destination parameter.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to move an item that writes over an existing read-onl
y item. Implementation varies from provider to provider. For more infor
mation, see about_Providers. Even using the Force parameter, the cmdlet
cannot override security restrictions.

-Include <string[]>
Moves only the specified items. The value of this parameter qualifies t
he Path parameter. Enter a path element or pattern, such as "*.txt". Wi
ldcards are permitted.

-LiteralPath <string[]>
Specifies the path to the current location of the items. Unlike Path, t
he value of LiteralPath is used exactly as it is typed. No characters a
re interpreted as wildcards. If the path includes escape characters, en
close it in single quotation marks. Single quotation marks tell Windows
PowerShell not to interpret any characters as escape sequences.

-PassThru [<SwitchParameter>]
Passes an object representing the item to the pipeline. By default, thi
s cmdlet does not generate any output.

-Path <string[]>
Specifies the path to the current location of the items. The default is
the current directory. Wildcards are permitted.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>move-item -path C:\test.txt -destination E:\Temp\tst.txt

Description
-----------
This command moves the Test.txt file from the C: drive to the E:\Temp direc
tory and renames it from "test.txt" to "tst.txt".




-------------------------- EXAMPLE 2 --------------------------

C:\PS>move-item -path C:\Temp -destination C:\Logs

Description
-----------
This command moves the C:\Temp directory and its contents to the C:\Logs di
rectory. The Temp directory, and all of its subdirectories and files, then
appear in the Logs directory.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>move-item -path .\*.txt -destination C:\Logs

Description
-----------
This command moves all of the text files (*.txt) in the current directory (
represented by a dot (.)) to the C:\Logs directory.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-childitem -path . -recurse -include *.txt | move-item -destinatio
n C:\TextFiles

Description
-----------
This command moves all of the text files from the current directory and all
subdirectories, recursively, to the C:\TextFiles directory.

The command uses the Get-ChildItem cmdlet to get all of the child items in
the current directory (represented by the dot [.]) and its subdirectories t
hat have a *.txt file name extension. It uses the Recurse parameter to make
the retrieval recursive and the Include parameter to limit the retrieval t
o *.txt files.

The pipeline operator (|) sends the results of this command to Move-Item, w
hich moves the text files to the TextFiles directory.

If files being moved to C:\Textfiles have the same name, Move-Item displays
an error and continues, but it moves only one file with each name to C:\Te
xtfiles. The other files remain in their original directories.

If the Textfiles directory (or any other element of the destination path) d
oes not exist, the command fails. The missing directory is not created for
you, even if you use the Force parameter. Move-Item moves the first item to
a file called "Textfiles" and then displays an error explaining that the f
ile already exists.

Also, by default, Get-ChildItem does not move hidden files. To move hidden
files, use the Force parameter with Get-ChildItem.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>move-item hklm:\software\mycompany\* hklm:\software\mynewcompany

Description
-----------
This command moves the registry keys and values within the MyCompany regist
ry key in HKLM\Software to the MyNewCompany key. The wildcard character (*)
indicates that the contents of the MyCompany key should be moved, not the
key itself. In this command, the optional Path and Destination parameter na
mes are omitted.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>move-item -literalpath 'Logs[Sept`06]' -destination 'Logs[2006]'

Description
-----------
This command moves the Logs[Sept`06] directory (and its contents) into the
Logs[2006] directory.

The LiteralPath parameter is used instead of Path, because the original dir
ectory name includes left bracket and right bracket characters ("[" and "]"
). The path is also enclosed in single quotation marks (' '), so that the b
acktick symbol (`) is not misinterpreted.

The Destination parameter does not require a literal path, because the Dest
ination variable also must be enclosed in single quotation marks, because i
t includes brackets that can be misinterpreted.




REMARKS
To see the examples, type: "get-help Move-Item -examples".
For more information, type: "get-help Move-Item -detailed".
For technical information, type: "get-help Move-Item -full".

NAME
New-Item

SYNOPSIS
Creates a new item.


SYNTAX
New-Item [-Path] <string[]> [-Credential <PSCredential>] [-Force] [-ItemTyp
e <string>] [-Value <Object>] [-Confirm] [-WhatIf] [-UseTransaction] [<Comm
onParameters>]

New-Item -Name <string> [[-Path] <string[]>] [-Credential <PSCredential>] [
-Force] [-ItemType <string>] [-Value <Object>] [-Confirm] [-WhatIf] [-UseTr
ansaction] [<CommonParameters>]


DESCRIPTION
The New-Item cmdlet creates a new item and sets its value. The types of ite
ms that can be created depend upon the location of the item. For example, i
n the file system, New-Item is used to create files and folders. In the reg
istry, New-Item creates registry keys and entries.

New-Item can also set the value of the items that it creates. For example,
when creating a new file, New-Item can add initial content to the file.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell

-Force [<SwitchParameter>]
Allows the cmdlet to create an item that writes over an existing read-o
nly item. Implementation varies from provider to provider. For more inf
ormation, see about_Providers. Even using the Force parameter, the cmdl
et cannot override security restrictions.

-ItemType <string>
Specifies the provider-specified type of the new item.

-Name <string>
Specifies the name of the new item. You can use this parameter to speci
fy the name of the new item, or include the name in the value of the Pa
th parameter.

-Path <string[]>
Specifies the path to the location of the new item. Wildcards are permi
tted.

You can specify the name of the new item in the Name parameter, or incl
ude it in the Path parameter.

-Value <Object>
Specifies the value of the new item. You can also pipe a value to New-I
tem.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-item -path . -name testfile1.txt -type "file" -value "This is a t
ext string."

Description
-----------
This command creates a text file named testfile1.txt in the current directo
ry. The dot (.) in the value of the Path parameter indicates the current di
rectory. The quoted text that follows the Value parameter is added to the f
ile as content.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>new-item -path c:\ -name logfiles -type directory

Description
-----------
This command creates a directory named Logfiles in the C: drive. The Type p
arameter specifies that the new item is a directory, not a file or other fi
le system object.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>new-item -path $profile -type file -force

Description
-----------
This command creates a Windows PowerShell profile in the path that is speci
fied by the $profile variable.

You can use profiles to customize Windows PowerShell. $Profile is an automa
tic (built-in) variable that stores the path and file name of the CurrentUs
er/CurrentHost profile. By default, the profile does not exist, even though
Windows PowerShell stores a path and file name for it.

In this command, the $profile variable represents the path to the file. The
Type parameter (or InfoType) specifies that the command creates a file. Th
e Force parameter lets you create a file in the profile path, even when the
directories in the path do not exist (Windows PowerShell creates them).

After you use this command to create a profile, you can enter aliases, func
tions, and scripts in the profile to customize your shell.

For more information, see about_Automatic_Variables and about_Profiles.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>new-item -type directory -path c:\ps-test\scripts

Description
-----------
This command creates a new Scripts directory in the C:\PS-Test directory.

The name of the new directory item, Scripts, is included in the value of th
e Path parameter, instead of being specified in the value of the Name param
eter. As indicated by the syntax, either command form is valid.




REMARKS
To see the examples, type: "get-help New-Item -examples".
For more information, type: "get-help New-Item -detailed".
For technical information, type: "get-help New-Item -full".

more [[-paths] <String[]>]

NAME
New-PSDrive

SYNOPSIS
Creates a Windows PowerShell drive in the current session.


SYNTAX
New-PSDrive [-Name] <string> [-PSProvider] <string> [-Root] <string> [-Cred
ential <PSCredential>] [-Description <string>] [-Scope <string>] [-Confirm]
[-WhatIf] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The New-PSDrive cmdlet creates a Windows PowerShell drive that is "mapped"
to or associated with a location in a data store, such as a network drive,
a directory on the local computer, or a registry key.

You can use the Windows PowerShell drives that you create to access data in
the associated data store, just like you would do with any mapped drive. Y
ou can change locations into the drive (using "set-location", "cd", or "chd
ir") and access the contents of the drive (using "get-item", "get-childitem
", or "dir").

However, the Windows PowerShell drives are known only to Windows PowerShell
. You cannot access them by using Windows Explorer, Windows Management Inst
rumentation (WMI), Component Object Model (COM), or the Microsoft .NET Fram
ework, or by using tools such as Net Use.

Windows PowerShell drives exist only in the current Windows PowerShell ses
sion. To make the drive persistent, you can export the session to which you
have added the drive, or you can save a New-PSDrive command in your Window
s PowerShell profile.

To delete a drive that was created by New-PSDrive, use the Remove-PSDrive c
mdlet.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01". Or, enter a PS
Credential object, such as one generated by the Get-Credential cmdlet.
If you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Description <string>
Specifies a brief text description of the drive. Type any string.

To see the descriptions of all of the Windows PowerShell drives on your
system, type "get-psdrive | format name, description". To see the desc
ription of a particular Windows PowerShell drives, type "(get-psdrive <
DriveName>).description".

-Name <string>
Specifies a name for the new drive. You can use any valid string for th
e name. You are not limited to drive letters. Windows PowerShell drives
names are case-sensitive.

-PSProvider <string>
Specifies the Windows PowerShell provider that supports drives of this
type.

For example, if the Windows PowerShell drives is associated with a net
work share or file system directory, the Windows PowerShell provider is
"FileSystem". If the Windows PowerShell drive is associated with a reg
istry key, the provider is "Registry".

To see a list of the providers in your Windows PowerShell session, type
"get-psprovider".

-Root <string>
Specifies the data store location that the Windows PowerShell drive is
mapped to.

For example, specify a network share (such as \\Server01\Public), a loc
al directory (such as C:\Program Files), or a registry key (such as HKL
M:\Software\Microsoft).

-Scope <string>
Specifies a scope for the drive. Valid values are "Global", "Local", or
"Script", or a number relative to the current scope (0 through the num
ber of scopes, where 0 is the current scope and 1 is its parent). "Loca
l" is the default. For more information, see about_Scopes.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-psdrive -name P -psprovider FileSystem -root \\Server01\Public

Name Provider Root
---- -------- ----
P FileSystem \\Server01\Public

Description
-----------
This command creates a Windows PowerShell drive that functions like a mappe
d network drive in Windows. The command creates a Windows PowerShell drive
named P: that is mapped to the \\Server01\Public network share.

It uses the Name parameter to specify a name for the drive, the PSProvider
parameter to specify the Windows PowerShell FileSystem provider, and the Ro
ot parameter to specify the network share.

When the command completes, the contents of the \\Server01\Public share app
ear in the P: drive. To see them, type: "dir p:".




-------------------------- EXAMPLE 2 --------------------------

C:\PS>new-psdrive -name MyDocs -psprovider FileSystem -root "C:\Documents a
nd Settings\User01\My Documents" -Description "Maps to my My Documents fold
er."

Name Provider Root
---- -------- ----
MyDocs FileSystem C:\Documents and Settings\User01\My Documents

Description
-----------
This command creates a Windows PowerShell drive that provides quick access
to a local directory. It creates a drive named MyDocs: that is mapped to th
e
"C:\Documents and Settings\User01\My Documents" directory on the local comp
uter.

It uses the Name parameter to specify a name for the drive, the PSProvider
parameter to specify the Windows PowerShell FileSystem provider, the Root p
arameter to specify the path to the My Documents folder, and the Descriptio
n parameter to create a description of the drive.


When the command completes, the contents of the My Documents folder appear
in the MyDocs: drive. To see them, type: "dir mydocs:".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>new-psdrive -name MyCompany -psprovider Registry -root HKLM:\Software
\MyCompany

Name Provider Root
---- -------- ----
MyCompany Registry HKEY_LOCAL_MACHINE\Software\MyCo...

Description
-----------
This command creates a Windows PowerShell drive that provides quick access
to a frequently checked registry key. It creates a drive named MyCompany th
at is mapped to the HKLM\Software\MyCompany registry key.

It uses the Name parameter to specify a name for the drive, the PSProvider
parameter to specify the Windows PowerShell Registry provider, and the Root
parameter to specify the registry key.


When the command completes, the contents of the MyCompany key appear in the
MyCompany: drive. To see them, type: "dir MyCompany:".




-------------------------- EXAMPLE 4 --------------------------

C:\PS>new-psdrive -name PsDrive -psprovider FileSystem -root \\Server01\Pub
lic

C:\PS> $drive = new-object -com wscript.network
C:\PS> $drive.MapNetworkDrive("X:", "\\Server01\Public")


C PS:\> get-psdrive public, x

Name Provider Root
---- -------- ----
PsDrive FileSystem \\Server01\public
X FileSystem X:\


C:\PS>get-psdrive psdrive, x | get-member

TypeName: System.Management.Automation.PSDriveInfo
Name MemberType Definition
---- ---------- ----------
CompareTo Method System.Int32 CompareTo(PSDriveInfo drive),
Equals Method System.Boolean Equals(Object obj),
GetHashCode Method System.Int32 GetHashCode()
...



C:\PS> net use
Status Local Remote Network
---------------------------------------------------------------------------
X: \\server01\public Microsoft Windows Network


C:\PS> get-wmiobject win32_logicaldisk | ft deviceid
deviceid
--------
C:
D:
X:

C:\PS> get-wmiobject win32_networkconnection
LocalName RemoteName ConnectionState
Status
--------- ---------- ---------------
------
X: \\products\public Disconnected
Unavailable

Description
-----------
This example shows the difference between a Windows drive that is mapped to
a network share and a Windows PowerShell drive that is mapped to the same
network share.

The first command uses the New-PSDrive cmdlet to create a Windows PowerShel
l drive called PSDrive: that is mapped to the \\Server01\Public network sha
re.

The second set of commands uses the New-Object cmdlet to create a Wscript.N
etwork COM object and then use its MapNetworkDrive method to map the \\Serv
er01\Public network share to the X: drive on the local computer.

Now, you can examine the two drives. Using a Get-PSDrive drive command, the
drives appear to be the same, although the network share name appears only
in the root of the PSDrive: drive.

Sending the drive objects to Get-Member shows that they have the same objec
t type, System.Management.Automation.PSDriveInfo.

However, a "net use" command, a Get-WmiObject command to the Win32_LogicalD
isk class, and a Get-WmiObject command to the Win32_NetworkConnection class
find only the X: drive that was created by using the Wscript.Network objec
t. That is because Windows PowerShell drives are known only to Windows Powe
rShell.

If you close the Windows PowerShell session and then open a new one, the PS
Drive: drive is gone, and the X: drive persists.

Therefore, when deciding which method to use to map network drives, conside
r how you will use the drive, whether it needs to be persistant, and whethe
r the drive needs to be visible to other Windows features.




REMARKS
To see the examples, type: "get-help New-PSDrive -examples".
For more information, type: "get-help New-PSDrive -detailed".
For technical information, type: "get-help New-PSDrive -full".

NAME
Move-Item

SYNOPSIS
Moves an item from one location to another.


SYNTAX
Move-Item [-LiteralPath] <string[]> [[-Destination] <string>] [-Credential
<PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include
<string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonPar
ameters>]

Move-Item [-Path] <string[]> [[-Destination] <string>] [-Credential <PSCred
ential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <strin
g[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters
>]


DESCRIPTION
The Move-Item cmdlet moves an item, including its properties, contents, and
child items, from one location to another location. The locations must be
supported by the same provider. For example, it can move a file or subdirec
tory from one directory to another or move a registry subkey from one key t
o another. When you move an item, it is added to the new location and delet
ed from its original location.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Destination <string>
Specifies the path to the location where the items are being moved. The
default is the current directory. Wildcards are permitted, but the res
ult must specify a single location.

To rename the item being moved, specify a new name in the value of the
Destination parameter.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to move an item that writes over an existing read-onl
y item. Implementation varies from provider to provider. For more infor
mation, see about_Providers. Even using the Force parameter, the cmdlet
cannot override security restrictions.

-Include <string[]>
Moves only the specified items. The value of this parameter qualifies t
he Path parameter. Enter a path element or pattern, such as "*.txt". Wi
ldcards are permitted.

-LiteralPath <string[]>
Specifies the path to the current location of the items. Unlike Path, t
he value of LiteralPath is used exactly as it is typed. No characters a
re interpreted as wildcards. If the path includes escape characters, en
close it in single quotation marks. Single quotation marks tell Windows
PowerShell not to interpret any characters as escape sequences.

-PassThru [<SwitchParameter>]
Passes an object representing the item to the pipeline. By default, thi
s cmdlet does not generate any output.

-Path <string[]>
Specifies the path to the current location of the items. The default is
the current directory. Wildcards are permitted.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>move-item -path C:\test.txt -destination E:\Temp\tst.txt

Description
-----------
This command moves the Test.txt file from the C: drive to the E:\Temp direc
tory and renames it from "test.txt" to "tst.txt".




-------------------------- EXAMPLE 2 --------------------------

C:\PS>move-item -path C:\Temp -destination C:\Logs

Description
-----------
This command moves the C:\Temp directory and its contents to the C:\Logs di
rectory. The Temp directory, and all of its subdirectories and files, then
appear in the Logs directory.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>move-item -path .\*.txt -destination C:\Logs

Description
-----------
This command moves all of the text files (*.txt) in the current directory (
represented by a dot (.)) to the C:\Logs directory.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-childitem -path . -recurse -include *.txt | move-item -destinatio
n C:\TextFiles

Description
-----------
This command moves all of the text files from the current directory and all
subdirectories, recursively, to the C:\TextFiles directory.

The command uses the Get-ChildItem cmdlet to get all of the child items in
the current directory (represented by the dot [.]) and its subdirectories t
hat have a *.txt file name extension. It uses the Recurse parameter to make
the retrieval recursive and the Include parameter to limit the retrieval t
o *.txt files.

The pipeline operator (|) sends the results of this command to Move-Item, w
hich moves the text files to the TextFiles directory.

If files being moved to C:\Textfiles have the same name, Move-Item displays
an error and continues, but it moves only one file with each name to C:\Te
xtfiles. The other files remain in their original directories.

If the Textfiles directory (or any other element of the destination path) d
oes not exist, the command fails. The missing directory is not created for
you, even if you use the Force parameter. Move-Item moves the first item to
a file called "Textfiles" and then displays an error explaining that the f
ile already exists.

Also, by default, Get-ChildItem does not move hidden files. To move hidden
files, use the Force parameter with Get-ChildItem.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>move-item hklm:\software\mycompany\* hklm:\software\mynewcompany

Description
-----------
This command moves the registry keys and values within the MyCompany regist
ry key in HKLM\Software to the MyNewCompany key. The wildcard character (*)
indicates that the contents of the MyCompany key should be moved, not the
key itself. In this command, the optional Path and Destination parameter na
mes are omitted.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>move-item -literalpath 'Logs[Sept`06]' -destination 'Logs[2006]'

Description
-----------
This command moves the Logs[Sept`06] directory (and its contents) into the
Logs[2006] directory.

The LiteralPath parameter is used instead of Path, because the original dir
ectory name includes left bracket and right bracket characters ("[" and "]"
). The path is also enclosed in single quotation marks (' '), so that the b
acktick symbol (`) is not misinterpreted.

The Destination parameter does not require a literal path, because the Dest
ination variable also must be enclosed in single quotation marks, because i
t includes brackets that can be misinterpreted.




REMARKS
To see the examples, type: "get-help Move-Item -examples".
For more information, type: "get-help Move-Item -detailed".
For technical information, type: "get-help Move-Item -full".

NAME
Move-Item

SYNOPSIS
Moves an item from one location to another.


SYNTAX
Move-Item [-LiteralPath] <string[]> [[-Destination] <string>] [-Credential
<PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include
<string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonPar
ameters>]

Move-Item [-Path] <string[]> [[-Destination] <string>] [-Credential <PSCred
ential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <strin
g[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters
>]


DESCRIPTION
The Move-Item cmdlet moves an item, including its properties, contents, and
child items, from one location to another location. The locations must be
supported by the same provider. For example, it can move a file or subdirec
tory from one directory to another or move a registry subkey from one key t
o another. When you move an item, it is added to the new location and delet
ed from its original location.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Destination <string>
Specifies the path to the location where the items are being moved. The
default is the current directory. Wildcards are permitted, but the res
ult must specify a single location.

To rename the item being moved, specify a new name in the value of the
Destination parameter.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to move an item that writes over an existing read-onl
y item. Implementation varies from provider to provider. For more infor
mation, see about_Providers. Even using the Force parameter, the cmdlet
cannot override security restrictions.

-Include <string[]>
Moves only the specified items. The value of this parameter qualifies t
he Path parameter. Enter a path element or pattern, such as "*.txt". Wi
ldcards are permitted.

-LiteralPath <string[]>
Specifies the path to the current location of the items. Unlike Path, t
he value of LiteralPath is used exactly as it is typed. No characters a
re interpreted as wildcards. If the path includes escape characters, en
close it in single quotation marks. Single quotation marks tell Windows
PowerShell not to interpret any characters as escape sequences.

-PassThru [<SwitchParameter>]
Passes an object representing the item to the pipeline. By default, thi
s cmdlet does not generate any output.

-Path <string[]>
Specifies the path to the current location of the items. The default is
the current directory. Wildcards are permitted.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>move-item -path C:\test.txt -destination E:\Temp\tst.txt

Description
-----------
This command moves the Test.txt file from the C: drive to the E:\Temp direc
tory and renames it from "test.txt" to "tst.txt".




-------------------------- EXAMPLE 2 --------------------------

C:\PS>move-item -path C:\Temp -destination C:\Logs

Description
-----------
This command moves the C:\Temp directory and its contents to the C:\Logs di
rectory. The Temp directory, and all of its subdirectories and files, then
appear in the Logs directory.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>move-item -path .\*.txt -destination C:\Logs

Description
-----------
This command moves all of the text files (*.txt) in the current directory (
represented by a dot (.)) to the C:\Logs directory.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-childitem -path . -recurse -include *.txt | move-item -destinatio
n C:\TextFiles

Description
-----------
This command moves all of the text files from the current directory and all
subdirectories, recursively, to the C:\TextFiles directory.

The command uses the Get-ChildItem cmdlet to get all of the child items in
the current directory (represented by the dot [.]) and its subdirectories t
hat have a *.txt file name extension. It uses the Recurse parameter to make
the retrieval recursive and the Include parameter to limit the retrieval t
o *.txt files.

The pipeline operator (|) sends the results of this command to Move-Item, w
hich moves the text files to the TextFiles directory.

If files being moved to C:\Textfiles have the same name, Move-Item displays
an error and continues, but it moves only one file with each name to C:\Te
xtfiles. The other files remain in their original directories.

If the Textfiles directory (or any other element of the destination path) d
oes not exist, the command fails. The missing directory is not created for
you, even if you use the Force parameter. Move-Item moves the first item to
a file called "Textfiles" and then displays an error explaining that the f
ile already exists.

Also, by default, Get-ChildItem does not move hidden files. To move hidden
files, use the Force parameter with Get-ChildItem.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>move-item hklm:\software\mycompany\* hklm:\software\mynewcompany

Description
-----------
This command moves the registry keys and values within the MyCompany regist
ry key in HKLM\Software to the MyNewCompany key. The wildcard character (*)
indicates that the contents of the MyCompany key should be moved, not the
key itself. In this command, the optional Path and Destination parameter na
mes are omitted.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>move-item -literalpath 'Logs[Sept`06]' -destination 'Logs[2006]'

Description
-----------
This command moves the Logs[Sept`06] directory (and its contents) into the
Logs[2006] directory.

The LiteralPath parameter is used instead of Path, because the original dir
ectory name includes left bracket and right bracket characters ("[" and "]"
). The path is also enclosed in single quotation marks (' '), so that the b
acktick symbol (`) is not misinterpreted.

The Destination parameter does not require a literal path, because the Dest
ination variable also must be enclosed in single quotation marks, because i
t includes brackets that can be misinterpreted.




REMARKS
To see the examples, type: "get-help Move-Item -examples".
For more information, type: "get-help Move-Item -detailed".
For technical information, type: "get-help Move-Item -full".

NAME
Move-ItemProperty

SYNOPSIS
Moves a property from one location to another.


SYNTAX
Move-ItemProperty [-LiteralPath] <string[]> [-Destination] <string> [-Name]
<string[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <st
ring>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-Us
eTransaction] [<CommonParameters>]

Move-ItemProperty [-Path] <string[]> [-Destination] <string> [-Name] <strin
g[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>]
[-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransa
ction] [<CommonParameters>]


DESCRIPTION
The Move-ItemProperty cmdlet moves a property of an item from one item to a
nother item. For example, it can move a registry entry from one registry ke
y to another registry key. When you move an item property, it is added to
the new location and deleted from its original location.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Destination <string>
Specifies the path to the destination location.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to move properties to or from items that cannot other
wise be accessed by the user. Implementation varies from provider to pr
ovider. For more information, see about_Providers.

-Include <string[]>
Moves only the specified items. The value of this parameter qualifies t
he Path parameter. Enter a path element or pattern, such as "*.txt". Wi
ldcards are permitted.

-LiteralPath <string[]>
Specifies the path to the current location of the property. Unlike Path
, the value of LiteralPath is used exactly as it is typed. No character
s are interpreted as wildcards. If the path includes escape characters,
enclose it in single quotation marks. Single quotation marks tell Wind
ows PowerShell not to interpret any characters as escape sequences.

-Name <string[]>
Specifies the name of the property to be moved.

-PassThru [<SwitchParameter>]
Passes an object representing the item property. By default, this cmdle
t does not generate any output.

-Path <string[]>
Specifies the path to the current location of the property. Wildcards a
re permitted.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>move-itemproperty HKLM:\Software\MyCompany\MyApp -Name `
Version -Destination HKLM:\Software\MyCompany\NewApp

Description
-----------
This command moves the "Version" registry value, and its data, from the MyA
pp subkey to the NewApp subkey of the HKLM\Software\MyCompany registry key.




REMARKS
To see the examples, type: "get-help Move-ItemProperty -examples".
For more information, type: "get-help Move-ItemProperty -detailed".
For technical information, type: "get-help Move-ItemProperty -full".

NAME
Move-ItemProperty

SYNOPSIS
Moves a property from one location to another.


SYNTAX
Move-ItemProperty [-LiteralPath] <string[]> [-Destination] <string> [-Name]
<string[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <st
ring>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-Us
eTransaction] [<CommonParameters>]

Move-ItemProperty [-Path] <string[]> [-Destination] <string> [-Name] <strin
g[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>]
[-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransa
ction] [<CommonParameters>]


DESCRIPTION
The Move-ItemProperty cmdlet moves a property of an item from one item to a
nother item. For example, it can move a registry entry from one registry ke
y to another registry key. When you move an item property, it is added to
the new location and deleted from its original location.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Destination <string>
Specifies the path to the destination location.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to move properties to or from items that cannot other
wise be accessed by the user. Implementation varies from provider to pr
ovider. For more information, see about_Providers.

-Include <string[]>
Moves only the specified items. The value of this parameter qualifies t
he Path parameter. Enter a path element or pattern, such as "*.txt". Wi
ldcards are permitted.

-LiteralPath <string[]>
Specifies the path to the current location of the property. Unlike Path
, the value of LiteralPath is used exactly as it is typed. No character
s are interpreted as wildcards. If the path includes escape characters,
enclose it in single quotation marks. Single quotation marks tell Wind
ows PowerShell not to interpret any characters as escape sequences.

-Name <string[]>
Specifies the name of the property to be moved.

-PassThru [<SwitchParameter>]
Passes an object representing the item property. By default, this cmdle
t does not generate any output.

-Path <string[]>
Specifies the path to the current location of the property. Wildcards a
re permitted.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>move-itemproperty HKLM:\Software\MyCompany\MyApp -Name `
Version -Destination HKLM:\Software\MyCompany\NewApp

Description
-----------
This command moves the "Version" registry value, and its data, from the MyA
pp subkey to the NewApp subkey of the HKLM\Software\MyCompany registry key.




REMARKS
To see the examples, type: "get-help Move-ItemProperty -examples".
For more information, type: "get-help Move-ItemProperty -detailed".
For technical information, type: "get-help Move-ItemProperty -full".

NAME
Move-Item

SYNOPSIS
Moves an item from one location to another.


SYNTAX
Move-Item [-LiteralPath] <string[]> [[-Destination] <string>] [-Credential
<PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include
<string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonPar
ameters>]

Move-Item [-Path] <string[]> [[-Destination] <string>] [-Credential <PSCred
ential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <strin
g[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters
>]


DESCRIPTION
The Move-Item cmdlet moves an item, including its properties, contents, and
child items, from one location to another location. The locations must be
supported by the same provider. For example, it can move a file or subdirec
tory from one directory to another or move a registry subkey from one key t
o another. When you move an item, it is added to the new location and delet
ed from its original location.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Destination <string>
Specifies the path to the location where the items are being moved. The
default is the current directory. Wildcards are permitted, but the res
ult must specify a single location.

To rename the item being moved, specify a new name in the value of the
Destination parameter.

-Exclude <string[]>
Omits the specified items. The value of this parameter qualifies the Pa
th parameter. Enter a path element or pattern, such as "*.txt". Wildcar
ds are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter. The syntax of the filter, i
ncluding the use of wildcards, depends on the provider. Filters are mor
e efficient than other parameters, because the provider applies them wh
en retrieving the objects, rather than having Windows PowerShell filter
the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to move an item that writes over an existing read-onl
y item. Implementation varies from provider to provider. For more infor
mation, see about_Providers. Even using the Force parameter, the cmdlet
cannot override security restrictions.

-Include <string[]>
Moves only the specified items. The value of this parameter qualifies t
he Path parameter. Enter a path element or pattern, such as "*.txt". Wi
ldcards are permitted.

-LiteralPath <string[]>
Specifies the path to the current location of the items. Unlike Path, t
he value of LiteralPath is used exactly as it is typed. No characters a
re interpreted as wildcards. If the path includes escape characters, en
close it in single quotation marks. Single quotation marks tell Windows
PowerShell not to interpret any characters as escape sequences.

-PassThru [<SwitchParameter>]
Passes an object representing the item to the pipeline. By default, thi
s cmdlet does not generate any output.

-Path <string[]>
Specifies the path to the current location of the items. The default is
the current directory. Wildcards are permitted.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>move-item -path C:\test.txt -destination E:\Temp\tst.txt

Description
-----------
This command moves the Test.txt file from the C: drive to the E:\Temp direc
tory and renames it from "test.txt" to "tst.txt".




-------------------------- EXAMPLE 2 --------------------------

C:\PS>move-item -path C:\Temp -destination C:\Logs

Description
-----------
This command moves the C:\Temp directory and its contents to the C:\Logs di
rectory. The Temp directory, and all of its subdirectories and files, then
appear in the Logs directory.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>move-item -path .\*.txt -destination C:\Logs

Description
-----------
This command moves all of the text files (*.txt) in the current directory (
represented by a dot (.)) to the C:\Logs directory.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-childitem -path . -recurse -include *.txt | move-item -destinatio
n C:\TextFiles

Description
-----------
This command moves all of the text files from the current directory and all
subdirectories, recursively, to the C:\TextFiles directory.

The command uses the Get-ChildItem cmdlet to get all of the child items in
the current directory (represented by the dot [.]) and its subdirectories t
hat have a *.txt file name extension. It uses the Recurse parameter to make
the retrieval recursive and the Include parameter to limit the retrieval t
o *.txt files.

The pipeline operator (|) sends the results of this command to Move-Item, w
hich moves the text files to the TextFiles directory.

If files being moved to C:\Textfiles have the same name, Move-Item displays
an error and continues, but it moves only one file with each name to C:\Te
xtfiles. The other files remain in their original directories.

If the Textfiles directory (or any other element of the destination path) d
oes not exist, the command fails. The missing directory is not created for
you, even if you use the Force parameter. Move-Item moves the first item to
a file called "Textfiles" and then displays an error explaining that the f
ile already exists.

Also, by default, Get-ChildItem does not move hidden files. To move hidden
files, use the Force parameter with Get-ChildItem.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>move-item hklm:\software\mycompany\* hklm:\software\mynewcompany

Description
-----------
This command moves the registry keys and values within the MyCompany regist
ry key in HKLM\Software to the MyNewCompany key. The wildcard character (*)
indicates that the contents of the MyCompany key should be moved, not the
key itself. In this command, the optional Path and Destination parameter na
mes are omitted.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>move-item -literalpath 'Logs[Sept`06]' -destination 'Logs[2006]'

Description
-----------
This command moves the Logs[Sept`06] directory (and its contents) into the
Logs[2006] directory.

The LiteralPath parameter is used instead of Path, because the original dir
ectory name includes left bracket and right bracket characters ("[" and "]"
). The path is also enclosed in single quotation marks (' '), so that the b
acktick symbol (`) is not misinterpreted.

The Destination parameter does not require a literal path, because the Dest
ination variable also must be enclosed in single quotation marks, because i
t includes brackets that can be misinterpreted.




REMARKS
To see the examples, type: "get-help Move-Item -examples".
For more information, type: "get-help Move-Item -detailed".
For technical information, type: "get-help Move-Item -full".

N:

NAME
New-Alias

SYNOPSIS
Creates a new alias.


SYNTAX
New-Alias [-Name] <string> [-Value] <string> [-Description <string>] [-Forc
e] [-Option {None | ReadOnly | Constant | Private | AllScope}] [-PassThru]
[-Scope <string>] [-Confirm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The New-Alias cmdlet creates a new alias in the current Windows PowerShell
session. Aliases created by using New-Alias are not saved after you exit th
e session or close Windows PowerShell. You can use the Export-Alias cmdlet
to save your alias information to a file. You can later use Import-Alias to
retrieve that saved alias information.

PARAMETERS
-Description <string>
Specifies a description of the alias. You can type any string. If the d
escription includes spaces, enclose it in quotation marks.

-Force [<SwitchParameter>]
If set, act like set-alias if the alias named already exists.

-Name <string>
Specifies the new alias. You can use any alphanumeric characters in an
alias, but the first character cannot be a number.

-Option <ScopedItemOptions>
Sets one or more optional properties of the alias. Valid values are:

-- None: Sets no options. (default)

-- ReadOnly: The alias cannot be changed unless you use the Force param
eter.

-- Constant: The alias cannot be changed, even by using the Force param
eter.

-- Private: The alias is available only within the scope specified by t
he Scope parameter. It is invisible in all other scopes.

-PassThru [<SwitchParameter>]
Returns an object representing the new alias. By default, this cmdlet d
oes not generate any output.

-Scope <string>
Specifies the scope of the new alias. Valid values are "Global", "Local
", or "Script", or a number relative to the current scope (0 through th
e number of scopes, where 0 is the current scope and 1 is its parent).
"Local" is the default. For more information, see about_Scopes.

-Value <string>
Specifies the name of the cmdlet or command element that is being alias
ed.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-alias list get-childitem

Description
-----------
This command creates an alias named "list" to represent the Get-ChildItem c
mdlet.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>new-alias -name w -value get-wmiobject -description "quick wmi alias"
-option ReadOnly

C:\PS> get-alias -name w | format-list *

Description
-----------
This command creates an alias named "w" to represent the Get-WMIObject cmdl
et. It creates a description, "quick wmi alias", for the alias and makes it
read only. The last line of the command uses Get-Alias to get the new alia
s and pipes it to Format-List to display all of the information about it.




REMARKS
To see the examples, type: "get-help New-Alias -examples".
For more information, type: "get-help New-Alias -detailed".
For technical information, type: "get-help New-Alias -full".

NAME
New-PSDrive

SYNOPSIS
Creates a Windows PowerShell drive in the current session.


SYNTAX
New-PSDrive [-Name] <string> [-PSProvider] <string> [-Root] <string> [-Cred
ential <PSCredential>] [-Description <string>] [-Scope <string>] [-Confirm]
[-WhatIf] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The New-PSDrive cmdlet creates a Windows PowerShell drive that is "mapped"
to or associated with a location in a data store, such as a network drive,
a directory on the local computer, or a registry key.

You can use the Windows PowerShell drives that you create to access data in
the associated data store, just like you would do with any mapped drive. Y
ou can change locations into the drive (using "set-location", "cd", or "chd
ir") and access the contents of the drive (using "get-item", "get-childitem
", or "dir").

However, the Windows PowerShell drives are known only to Windows PowerShell
. You cannot access them by using Windows Explorer, Windows Management Inst
rumentation (WMI), Component Object Model (COM), or the Microsoft .NET Fram
ework, or by using tools such as Net Use.

Windows PowerShell drives exist only in the current Windows PowerShell ses
sion. To make the drive persistent, you can export the session to which you
have added the drive, or you can save a New-PSDrive command in your Window
s PowerShell profile.

To delete a drive that was created by New-PSDrive, use the Remove-PSDrive c
mdlet.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01". Or, enter a PS
Credential object, such as one generated by the Get-Credential cmdlet.
If you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Description <string>
Specifies a brief text description of the drive. Type any string.

To see the descriptions of all of the Windows PowerShell drives on your
system, type "get-psdrive | format name, description". To see the desc
ription of a particular Windows PowerShell drives, type "(get-psdrive <
DriveName>).description".

-Name <string>
Specifies a name for the new drive. You can use any valid string for th
e name. You are not limited to drive letters. Windows PowerShell drives
names are case-sensitive.

-PSProvider <string>
Specifies the Windows PowerShell provider that supports drives of this
type.

For example, if the Windows PowerShell drives is associated with a net
work share or file system directory, the Windows PowerShell provider is
"FileSystem". If the Windows PowerShell drive is associated with a reg
istry key, the provider is "Registry".

To see a list of the providers in your Windows PowerShell session, type
"get-psprovider".

-Root <string>
Specifies the data store location that the Windows PowerShell drive is
mapped to.

For example, specify a network share (such as \\Server01\Public), a loc
al directory (such as C:\Program Files), or a registry key (such as HKL
M:\Software\Microsoft).

-Scope <string>
Specifies a scope for the drive. Valid values are "Global", "Local", or
"Script", or a number relative to the current scope (0 through the num
ber of scopes, where 0 is the current scope and 1 is its parent). "Loca
l" is the default. For more information, see about_Scopes.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-psdrive -name P -psprovider FileSystem -root \\Server01\Public

Name Provider Root
---- -------- ----
P FileSystem \\Server01\Public

Description
-----------
This command creates a Windows PowerShell drive that functions like a mappe
d network drive in Windows. The command creates a Windows PowerShell drive
named P: that is mapped to the \\Server01\Public network share.

It uses the Name parameter to specify a name for the drive, the PSProvider
parameter to specify the Windows PowerShell FileSystem provider, and the Ro
ot parameter to specify the network share.

When the command completes, the contents of the \\Server01\Public share app
ear in the P: drive. To see them, type: "dir p:".




-------------------------- EXAMPLE 2 --------------------------

C:\PS>new-psdrive -name MyDocs -psprovider FileSystem -root "C:\Documents a
nd Settings\User01\My Documents" -Description "Maps to my My Documents fold
er."

Name Provider Root
---- -------- ----
MyDocs FileSystem C:\Documents and Settings\User01\My Documents

Description
-----------
This command creates a Windows PowerShell drive that provides quick access
to a local directory. It creates a drive named MyDocs: that is mapped to th
e
"C:\Documents and Settings\User01\My Documents" directory on the local comp
uter.

It uses the Name parameter to specify a name for the drive, the PSProvider
parameter to specify the Windows PowerShell FileSystem provider, the Root p
arameter to specify the path to the My Documents folder, and the Descriptio
n parameter to create a description of the drive.


When the command completes, the contents of the My Documents folder appear
in the MyDocs: drive. To see them, type: "dir mydocs:".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>new-psdrive -name MyCompany -psprovider Registry -root HKLM:\Software
\MyCompany

Name Provider Root
---- -------- ----
MyCompany Registry HKEY_LOCAL_MACHINE\Software\MyCo...

Description
-----------
This command creates a Windows PowerShell drive that provides quick access
to a frequently checked registry key. It creates a drive named MyCompany th
at is mapped to the HKLM\Software\MyCompany registry key.

It uses the Name parameter to specify a name for the drive, the PSProvider
parameter to specify the Windows PowerShell Registry provider, and the Root
parameter to specify the registry key.


When the command completes, the contents of the MyCompany key appear in the
MyCompany: drive. To see them, type: "dir MyCompany:".




-------------------------- EXAMPLE 4 --------------------------

C:\PS>new-psdrive -name PsDrive -psprovider FileSystem -root \\Server01\Pub
lic

C:\PS> $drive = new-object -com wscript.network
C:\PS> $drive.MapNetworkDrive("X:", "\\Server01\Public")


C PS:\> get-psdrive public, x

Name Provider Root
---- -------- ----
PsDrive FileSystem \\Server01\public
X FileSystem X:\


C:\PS>get-psdrive psdrive, x | get-member

TypeName: System.Management.Automation.PSDriveInfo
Name MemberType Definition
---- ---------- ----------
CompareTo Method System.Int32 CompareTo(PSDriveInfo drive),
Equals Method System.Boolean Equals(Object obj),
GetHashCode Method System.Int32 GetHashCode()
...



C:\PS> net use
Status Local Remote Network
---------------------------------------------------------------------------
X: \\server01\public Microsoft Windows Network


C:\PS> get-wmiobject win32_logicaldisk | ft deviceid
deviceid
--------
C:
D:
X:

C:\PS> get-wmiobject win32_networkconnection
LocalName RemoteName ConnectionState
Status
--------- ---------- ---------------
------
X: \\products\public Disconnected
Unavailable

Description
-----------
This example shows the difference between a Windows drive that is mapped to
a network share and a Windows PowerShell drive that is mapped to the same
network share.

The first command uses the New-PSDrive cmdlet to create a Windows PowerShel
l drive called PSDrive: that is mapped to the \\Server01\Public network sha
re.

The second set of commands uses the New-Object cmdlet to create a Wscript.N
etwork COM object and then use its MapNetworkDrive method to map the \\Serv
er01\Public network share to the X: drive on the local computer.

Now, you can examine the two drives. Using a Get-PSDrive drive command, the
drives appear to be the same, although the network share name appears only
in the root of the PSDrive: drive.

Sending the drive objects to Get-Member shows that they have the same objec
t type, System.Management.Automation.PSDriveInfo.

However, a "net use" command, a Get-WmiObject command to the Win32_LogicalD
isk class, and a Get-WmiObject command to the Win32_NetworkConnection class
find only the X: drive that was created by using the Wscript.Network objec
t. That is because Windows PowerShell drives are known only to Windows Powe
rShell.

If you close the Windows PowerShell session and then open a new one, the PS
Drive: drive is gone, and the X: drive persists.

Therefore, when deciding which method to use to map network drives, conside
r how you will use the drive, whether it needs to be persistant, and whethe
r the drive needs to be visible to other Windows features.




REMARKS
To see the examples, type: "get-help New-PSDrive -examples".
For more information, type: "get-help New-PSDrive -detailed".
For technical information, type: "get-help New-PSDrive -full".

NAME
New-Alias

SYNOPSIS
Creates a new alias.


SYNTAX
New-Alias [-Name] <string> [-Value] <string> [-Description <string>] [-Forc
e] [-Option {None | ReadOnly | Constant | Private | AllScope}] [-PassThru]
[-Scope <string>] [-Confirm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The New-Alias cmdlet creates a new alias in the current Windows PowerShell
session. Aliases created by using New-Alias are not saved after you exit th
e session or close Windows PowerShell. You can use the Export-Alias cmdlet
to save your alias information to a file. You can later use Import-Alias to
retrieve that saved alias information.

PARAMETERS
-Description <string>
Specifies a description of the alias. You can type any string. If the d
escription includes spaces, enclose it in quotation marks.

-Force [<SwitchParameter>]
If set, act like set-alias if the alias named already exists.

-Name <string>
Specifies the new alias. You can use any alphanumeric characters in an
alias, but the first character cannot be a number.

-Option <ScopedItemOptions>
Sets one or more optional properties of the alias. Valid values are:

-- None: Sets no options. (default)

-- ReadOnly: The alias cannot be changed unless you use the Force param
eter.

-- Constant: The alias cannot be changed, even by using the Force param
eter.

-- Private: The alias is available only within the scope specified by t
he Scope parameter. It is invisible in all other scopes.

-PassThru [<SwitchParameter>]
Returns an object representing the new alias. By default, this cmdlet d
oes not generate any output.

-Scope <string>
Specifies the scope of the new alias. Valid values are "Global", "Local
", or "Script", or a number relative to the current scope (0 through th
e number of scopes, where 0 is the current scope and 1 is its parent).
"Local" is the default. For more information, see about_Scopes.

-Value <string>
Specifies the name of the cmdlet or command element that is being alias
ed.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-alias list get-childitem

Description
-----------
This command creates an alias named "list" to represent the Get-ChildItem c
mdlet.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>new-alias -name w -value get-wmiobject -description "quick wmi alias"
-option ReadOnly

C:\PS> get-alias -name w | format-list *

Description
-----------
This command creates an alias named "w" to represent the Get-WMIObject cmdl
et. It creates a description, "quick wmi alias", for the alias and makes it
read only. The last line of the command uses Get-Alias to get the new alia
s and pipes it to Format-List to display all of the information about it.




REMARKS
To see the examples, type: "get-help New-Alias -examples".
For more information, type: "get-help New-Alias -detailed".
For technical information, type: "get-help New-Alias -full".

NAME
New-Event

SYNOPSIS
Creates a new event.


SYNTAX
New-Event [-SourceIdentifier] <string> [[-Sender] <psobject>] [[-EventArgum
ents] <PSObject[]>] [[-MessageData] <psobject>] [<CommonParameters>]


DESCRIPTION
The New-Event cmdlet creates a new custom event.

You can use custom events to notify users about state changes in your progr
am and any change that your program can detect, including hardware or syste
m conditions, application status, disk status, network status, or the compl
etion of a background job.

Custom events are automatically added to the event queue in your session wh
enever they are raised; you do not need to subscribe to them. However, if y
ou want to forward an event to the local session or specify an action to re
spond to the event, use the Register-EngineEvent cmdlet to subscribe to the
custom event.

When you subscribe to a custom event, the event subscriber is added to your
session. If you cancel the event subscription by using the Unregister-Even
t cmdlet, the event subscriber and custom event are deleted from the sessio
n. If you do not subscribe to the custom event, to delete the event, you mu
st change the program conditions or close the Windows PowerShell session.

PARAMETERS
-EventArguments <PSObject[]>
Specifies an object that contains options for the event.

-MessageData <psobject>
Specifies additional data associated with the event. The value of this
parameter appears in the MessageData property of the event object.

-Sender <psobject>
Specifies the object that raises the event. The default is the Windows
PowerShell engine.

-SourceIdentifier <string>
Specifies a name for the new event. This parameter is required, and it
must be unique in the session.

The value of this parameter appears in the SourceIdentifier property of
the events.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-event -sourceidentifier Timer -sender windows.timer -messagedata
"Test"

Description
-----------
This command creates a new event in the Windows PowerShell event queue. It
uses a Windows.Timer object to send the event.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>function Enable-ProcessCreationEvent
{
$query = New-Object System.Management.WqlEventQuery "__InstanceCreationE
vent", (New-Object TimeSpan 0,0,1), "TargetInstance isa 'Win32_Process'"
$processWatcher = New-Object System.Management.ManagementEventWatcher $q
uery
$identifier = "WMI.ProcessCreated"

Register-ObjectEvent $processWatcher "EventArrived" -SupportEvent $ident
ifier -Action {
[void] (New-Event -sourceID "PowerShell.ProcessCreated" -Sender $arg
s[0] -EventArguments $args[1].SourceEventArgs.NewEvent.TargetInstance)
}
}

Description
-----------
This sample function uses the New-Event cmdlet to raise an event in respons
e to another event. The command uses the Register-ObjectEvent cmdlet to sub
scribe to the Windows Management Instrumentation (WMI) event that is raised
when a new process is created. The command uses the Action parameter of th
e cmdlet to call the New-Event cmdlet, which creates the new event.

Because the events that New-Event raises are automatically added to the Win
dows PowerShell event queue, you do not need to register for that event.




REMARKS
To see the examples, type: "get-help New-Event -examples".
For more information, type: "get-help New-Event -detailed".
For technical information, type: "get-help New-Event -full".

NAME
New-EventLog

SYNOPSIS
Creates a new event log and a new event source on a local or remote compute
r.


SYNTAX
New-EventLog [-LogName] <string> [-Source] <string[]> [[-ComputerName] <str
ing[]>] [-CategoryResourceFile <string>] [-MessageResourceFile <string>] [-
ParameterResourceFile <string>] [<CommonParameters>]


DESCRIPTION
This cmdlet creates a new classic event log on a local or remote computer.
It can also register an event source that writes to the new log or to an ex
isting log.

The cmdlets that contain the EventLog noun (the Event log cmdlets) work onl
y on classic event logs. To get events from logs that use the Windows Event
Log technology in Windows Vista and later versions of Windows, use Get-Win
Event.

PARAMETERS
-CategoryResourceFile <string>
Specifies the path to the file that contains category strings for the s
ource events. This file is also known as the Category Message File.

The file must be present on the computer on which the event log is bein
g created. This parameter does not create or move files.

-ComputerName <string[]>
Creates the new event logs on the specified computers. The default is t
he local computer.

Type the NetBIOS name, an Internet Protocol (IP) address, or a fully qu
alified domain name of a remote computer. To specify the local computer
, type the computer name, a dot (.), or "localhost".

This parameter does not rely on Windows PowerShell remoting. You can us
e the ComputerName parameter of Get-EventLog even if your computer is n
ot configured to run remote commands.

-LogName <string>
Specifies the name of the event log.

If the log does not exist, New-EventLog creates the log and uses this v
alue for the Log and LogDisplayName properties of the new event log. If
the log exists, New-EventLog registers a new source for the event log.

-MessageResourceFile <string>
Specifies the path to the file that contains message formatting strings
for the source events. This file is also known as the Event Message Fi
le.

The file must be present on the computer on which the event log is bein
g created. This parameter does not create or move files.

-ParameterResourceFile <string>
Specifies the path to the file that contains strings used for parameter
substitutions in event descriptions. This file is also known as the Pa
rameter Message File.

The file must be present on the computer on which the event log is bein
g created. This parameter does not create or move files.

-Source <string[]>
Specifies the names of the event log sources, such as application progr
ams that write to the event log. This parameter is required.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-eventlog -source TestApp -logname TestLog -MessageResourceFile C:
\Test\TestApp.dll

Description
-----------
This command creates the TestLog event log on the local computer and regist
ers a new source for it.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$file = "C:\Program Files\TestApps\NewTestApp.dll"

C:\PS> new-eventlog -computername Server01 -source NewTestApp -logname Appl
ication -MessageResourceFile $file -CategoryResourceFile $file

Description
-----------
This command adds a new event source, NewTestApp, to the Application log on
the Server01 remote computer.

The command requires that the NewTestApp.dll file is located on the Server0
1 computer.




REMARKS
To see the examples, type: "get-help New-EventLog -examples".
For more information, type: "get-help New-EventLog -detailed".
For technical information, type: "get-help New-EventLog -full".

NAME
New-Item

SYNOPSIS
Creates a new item.


SYNTAX
New-Item [-Path] <string[]> [-Credential <PSCredential>] [-Force] [-ItemTyp
e <string>] [-Value <Object>] [-Confirm] [-WhatIf] [-UseTransaction] [<Comm
onParameters>]

New-Item -Name <string> [[-Path] <string[]>] [-Credential <PSCredential>] [
-Force] [-ItemType <string>] [-Value <Object>] [-Confirm] [-WhatIf] [-UseTr
ansaction] [<CommonParameters>]


DESCRIPTION
The New-Item cmdlet creates a new item and sets its value. The types of ite
ms that can be created depend upon the location of the item. For example, i
n the file system, New-Item is used to create files and folders. In the reg
istry, New-Item creates registry keys and entries.

New-Item can also set the value of the items that it creates. For example,
when creating a new file, New-Item can add initial content to the file.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell

-Force [<SwitchParameter>]
Allows the cmdlet to create an item that writes over an existing read-o
nly item. Implementation varies from provider to provider. For more inf
ormation, see about_Providers. Even using the Force parameter, the cmdl
et cannot override security restrictions.

-ItemType <string>
Specifies the provider-specified type of the new item.

-Name <string>
Specifies the name of the new item. You can use this parameter to speci
fy the name of the new item, or include the name in the value of the Pa
th parameter.

-Path <string[]>
Specifies the path to the location of the new item. Wildcards are permi
tted.

You can specify the name of the new item in the Name parameter, or incl
ude it in the Path parameter.

-Value <Object>
Specifies the value of the new item. You can also pipe a value to New-I
tem.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-item -path . -name testfile1.txt -type "file" -value "This is a t
ext string."

Description
-----------
This command creates a text file named testfile1.txt in the current directo
ry. The dot (.) in the value of the Path parameter indicates the current di
rectory. The quoted text that follows the Value parameter is added to the f
ile as content.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>new-item -path c:\ -name logfiles -type directory

Description
-----------
This command creates a directory named Logfiles in the C: drive. The Type p
arameter specifies that the new item is a directory, not a file or other fi
le system object.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>new-item -path $profile -type file -force

Description
-----------
This command creates a Windows PowerShell profile in the path that is speci
fied by the $profile variable.

You can use profiles to customize Windows PowerShell. $Profile is an automa
tic (built-in) variable that stores the path and file name of the CurrentUs
er/CurrentHost profile. By default, the profile does not exist, even though
Windows PowerShell stores a path and file name for it.

In this command, the $profile variable represents the path to the file. The
Type parameter (or InfoType) specifies that the command creates a file. Th
e Force parameter lets you create a file in the profile path, even when the
directories in the path do not exist (Windows PowerShell creates them).

After you use this command to create a profile, you can enter aliases, func
tions, and scripts in the profile to customize your shell.

For more information, see about_Automatic_Variables and about_Profiles.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>new-item -type directory -path c:\ps-test\scripts

Description
-----------
This command creates a new Scripts directory in the C:\PS-Test directory.

The name of the new directory item, Scripts, is included in the value of th
e Path parameter, instead of being specified in the value of the Name param
eter. As indicated by the syntax, either command form is valid.




REMARKS
To see the examples, type: "get-help New-Item -examples".
For more information, type: "get-help New-Item -detailed".
For technical information, type: "get-help New-Item -full".

NAME
New-ItemProperty

SYNOPSIS
Creates a new property for an item and sets its value. For example, you can
use New-ItemProperty to create and change registry values and data, which
are properties of a registry key.


SYNTAX
New-ItemProperty [-LiteralPath] <string[]> [-Name] <string> [-Credential <P
SCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <
string[]>] [-PropertyType <string>] [-Value <Object>] [-Confirm] [-WhatIf]
[-UseTransaction] [<CommonParameters>]

New-ItemProperty [-Path] <string[]> [-Name] <string> [-Credential <PSCreden
tial>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[
]>] [-PropertyType <string>] [-Value <Object>] [-Confirm] [-WhatIf] [-UseTr
ansaction] [<CommonParameters>]


DESCRIPTION
The New-ItemProperty cmdlet creates a new property for a specified item and
sets its value. Typically, this cmdlet is used to create new registry valu
es, because registry values are properties of a registry key item.

This cmdlet does not add properties to an object. To add a property to an i
nstance of an object, use the Add-Member cmdlet. To add a property to all o
bjects of a particular type, edit the Types.ps1xml file.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Exclude <string[]>
Omits the specified items. Wildcards are permitted.

-Filter <string>
Specifies a filter in the provider's format or language. The value of t
his parameter qualifies the Path parameter.

The syntax of the filter, including the use of wildcards, depends on th
e provider. Filters are more efficient than other parameters, because t
he provider applies them when retrieving the objects rather than having
Windows PowerShell filter the objects after they are retrieved.

-Force [<SwitchParameter>]
Allows the cmdlet to create a property on an object that cannot otherwi
se be accessed by the user. Implementation varies from provider to prov
ider. For more information, see about_Providers.

-Include <string[]>
The value of this parameter qualifies the Path parameter. Enter a path
element or pattern, such as "*.txt". Wildcards are permitted.

-LiteralPath <string[]>
Specifies a path to the item property. The value of LiteralPath is used
exactly as it is typed. No characters are interpreted as wildcards. If
the path includes escape characters, enclose it in single quotation ma
rks. Single quotation marks tell Windows PowerShell not to interpret an
y characters as escape sequences.

-Name <string>
Specifies a name for the new property. If the property is a registry en
try, this parameter specifies the name of the entry.

-Path <string[]>
Specifies the path to the item. This parameter identifies the item to w
hich the new property will be added.

-PropertyType <string>
Specifies the type of property that will be added.

-Value <Object>
Specifies the property value. If the property is a registry entry, this
parameter specifies the value of the entry.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-itemproperty -path HKLM:\Software\MyCompany -name NoOfEmployees -
value 822

C:\PS> get-itemproperty hklm:\software\mycompany


PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\soft
ware\mycompany
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\soft
ware
PSChildName : mycompany
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
NoOfLocations : 2
NoOfEmployees : 822

Description
-----------
This command adds a new registry entry, NoOfEmployees, to the MyCompany key
of the HKLM:\Software hive.

The first command uses the Path parameter to specify the path to the MyComp
any registry key. It uses the Name parameter to specify a name for the entr
y and the Value parameter to specify its value.

The second command uses the Get-ItemProperty cmdlet to see the new registry
entry.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-item -path HKLM:\Software\MyCompany | new-Itemproperty -name NoOf
Locations -value 3

Description
-----------
This command adds a new registry entry to a registry key. To specify the ke
y, it uses a pipeline operator (|) to send an object representing the key t
o the New-ItemProperty cmdlet.

The first part of the command uses the Get-Item cmdlet to get the MyCompany
registry key. The pipeline operator (|) sends the results of the command t
o the New-ItemProperty cmdlet, which adds the new registry entry, NoOfLocat
ions, and its value, 3, to the MyCompany key.

This command works because the parameter-binding feature of Windows PowerSh
ell associates the path of the RegistryKey object that Get-Item returns wit
h the LiteralPath parameter of New-ItemProperty. For more information, see
about_Pipelines.




REMARKS
To see the examples, type: "get-help New-ItemProperty -examples".
For more information, type: "get-help New-ItemProperty -detailed".
For technical information, type: "get-help New-ItemProperty -full".

NAME
New-Module

SYNOPSIS
Creates a new dynamic module that exists only in memory.


SYNTAX
New-Module [-Name] <string> [-ScriptBlock] <scriptblock> [-ArgumentList <Ob
ject[]>] [-AsCustomObject] [-Cmdlet <string[]>] [-Function <string[]>] [-Re
turnResult] [<CommonParameters>]

New-Module [-ScriptBlock] <scriptblock> [-ArgumentList <Object[]>] [-AsCust
omObject] [-Cmdlet <string[]>] [-Function <string[]>] [-ReturnResult] [<Com
monParameters>]


DESCRIPTION
The New-Module cmdlet creates a dynamic module from a script block. The mem
bers of the dynamic module, such as functions and variables, are immediatel
y available in the session and remain available until you close the session
.

Like static modules, by default, the cmdlets and functions in a dynamic mod
ule are exported and the variables and aliases are not. However, you can us
e the Export-ModuleMember cmdlet and the parameters of New-Module to overri
de the defaults.

Dynamic modules exist only in memory, not on disk. Like all modules, the m
embers of dynamic modules run in a private module scope that is a child of
the global scope. Get-Module cannot get a dynamic module, but Get-Command c
an get the exported members.

To make a dynamic module available to Get-Module, pipe a New-Module command
to Import-Module, or pipe the module object that New-Module returns to Imp
ort-Module. This action adds the dynamic module to the Get-Module list, but
it does not save the module to disk or make it persistent.

PARAMETERS
-ArgumentList <Object[]>
Specifies arguments (parameter values) that are passed to the script bl
ock.

-AsCustomObject [<SwitchParameter>]
Returns a custom object with members that represent the module members.


When you use the AsCustomObject parameter, New-Module creates the dynam
ic module, imports the module members into the current session, and the
n returns a PSCustomObject object instead of a PSModuleInfo object. You
can save the custom object in a variable and use dot notation to invok
e the members.

If the module has multiple members with the same name, such as a functi
on and a variable that are both named "A," only one member with each na
me is accessible from the custom object.

-Cmdlet <string[]>
Exports only the specified cmdlets from the module into the current ses
sion. Enter a comma-separated list of cmdlets. Wildcard characters are
permitted. By default, all cmdlets in the module are exported.

You cannot define cmdlets in a script block, but a dynamic module can i
nclude cmdlets if it imports the cmdlets from a binary module.

-Function <string[]>
Exports only the specified functions from the module into the current s
ession. Enter a comma-separated list of functions. Wildcard characters
are permitted. By default, all functions defined in a module are export
ed.

-Name <string>
Specifies a name for the new module. You can also pipe a module name to
New-Module.

The default value is an autogenerated name that begins with "__DynamicM
odule_" and is followed by a GUID that specifies the path to the dynami
c module.

-ReturnResult [<SwitchParameter>]
Runs the script block and returns the script block results instead of r
eturning a module object.

-ScriptBlock <scriptblock>
Specifies the contents of the dynamic module. Enclose the contents in b
races ( { } ) to create a script block. This parameter is required.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-module -scriptblock {function Hello {"Hello!"}}

Name : __DynamicModule_2ceb1d0a-990f-45e4-9fe4-89f0f6ead0e5
Path : 2ceb1d0a-990f-45e4-9fe4-89f0f6ead0e5
Description :
Guid : 00000000-0000-0000-0000-000000000000
Version : 0.0
ModuleBase :
ModuleType : Script
PrivateData :
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {}
ExportedFunctions : {[Hello, Hello]}
ExportedVariables : {}
NestedModules : {}

Description
-----------
This command creates a new dynamic module with a function called "Hello". T
he command returns a module object that represents the new dynamic module.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>new-module -scriptblock {function Hello {"Hello!"}}

Name : __DynamicModule_2ceb1d0a-990f-45e4-9fe4-89f0f6ead0e5
Path : 2ceb1d0a-990f-45e4-9fe4-89f0f6ead0e5
Description :
Guid : 00000000-0000-0000-0000-000000000000
Version : 0.0
ModuleBase :
ModuleType : Script
PrivateData :
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {}
ExportedFunctions : {[Hello, Hello]}
ExportedVariables : {}
NestedModules : {}

C:\PS> get-module
C:\PS>

C:\PS> get-command Hello

CommandType Name Definition
----------- ---- ----------
Function Hello "Hello!"

Description
-----------
This example demonstrates that dynamic modules are not returned by the Get-
Module cmdlet, but the members that they export are returned by the Get-Com
mand cmdlet.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>New-Module -scriptblock {$SayHelloHelp="Type 'SayHello', a space, and
a name."; function SayHello ($name) { "Hello, $name" }; Export-ModuleMembe
r -function SayHello -Variable SayHelloHelp}

C:\PS> $SayHelloHelp
Type 'SayHello', a space, and a name.

C:\PS> SayHello Jeffrey
Hello, Jeffrey

Description
-----------
This command uses the Export-ModuleMember cmdlet to export a variable into
the current session. Without the Export-ModuleMember command, only the func
tion is exported.

The output shows that both the variable and the function were exported into
the session.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>new-module -scriptblock {function Hello {"Hello!"}} -name GreetingMod
ule | import-module

C:\PS> get-module


Name : GreetingModule
Path : d54dfdac-4531-4db2-9dec-0b4b9c57a1e5
Description :
Guid : 00000000-0000-0000-0000-000000000000
Version : 0.0
ModuleBase :
ModuleType : Script
PrivateData :
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {}
ExportedFunctions : {[Hello, Hello]}
ExportedVariables : {}
NestedModules : {}


C:\PS> get-command hello

CommandType Name
Definition
----------- ----
----------
Function Hello
"Hello!"

Description
-----------
This command demonstrates that you can make a dynamic module available to t
he Get-Module cmdlet by piping the dynamic module to the Import-Module cmdl
et.

The first command uses a pipeline operator (|) to send the module object th
at New-Module generates to the Import-Module cmdlet. The command uses the N
ame parameter of New-Module to assign a friendly name to the module. Becaus
e Import-Module does not return any objects by default, there is no output
from this command.

The second command uses the Get-Module cmdlet to get the modules in the ses
sion. The result shows that Get-Module can get the new dynamic module.

The third command uses the Get-Command cmdlet to get the Hello function tha
t the dynamic module exports.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>$m = new-module -scriptblock {function Hello ($name) {"Hello, $name"}
; function Goodbye ($name) {"Goodbye, $name"}} -AsCustomObject

C:\PS> $m

C:\PS> $m | get-member

TypeName: System.Management.Automation.PSCustomObject

Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Goodbye ScriptMethod System.Object Goodbye();
Hello ScriptMethod System.Object Hello();

PS C:\ps-test> $m.goodbye("Jane")
Goodbye, Jane

PS C:\ps-test> $m.hello("Manoj")
Hello, Manoj

PS C:\ps-test> goodbye Jane
Goodbye, Jane

PS C:\ps-test> hello Manoj
Hello, Manoj

Description
-----------
This example shows how to use the AsCustomObject parameter of New-Module to
generate a custom object with script methods that represent the exported f
unctions.

The first command uses the New-Module cmdlet to generate a dynamic module w
ith two functions, Hello and Goodbye. The command uses the AsCustomObject p
arameter to generate a custom object instead of the PSModuleInfo object tha
t New-Module generates by default. The command saves the custom object in t
he $m variable.

The second command attempts to display the value of the $m variable. No con
tent appears.

The third command uses a pipeline operator (|) to send the custom object to
the Get-Member cmdlet, which displays the properties and methods of the cu
stom object. The output shows that the object has script methods that repre
sent the Hello and Goodbye functions.

The fourth and fifth commands use the script method format to call the Hell
o and Goodbye functions.

The sixth and seventh commands call the functions by specifying the functio
n name and parameter value.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>new-module -scriptblock {function SayHello {"Hello, World!"}; SayHell
o} -returnResult

Hello, World!

Description
-----------
This command uses the ReturnResult parameter to request the results of runn
ing the script block instead of requesting a module object.

The script block in the new module defines the SayHello function and then c
alls the function.




REMARKS
To see the examples, type: "get-help New-Module -examples".
For more information, type: "get-help New-Module -detailed".
For technical information, type: "get-help New-Module -full".

NAME
New-ModuleManifest

SYNOPSIS
Creates a new module manifest.


SYNTAX
New-ModuleManifest [-Path] <string> -Author <string> -CompanyName <string>
-Copyright <string> -Description <string> -FileList <string[]> -FormatsToPr
ocess <string[]> -ModuleToProcess <string> -NestedModules <string[]> -Requi
redAssemblies <string[]> -TypesToProcess <string[]> [-AliasesToExport <stri
ng[]>] [-ClrVersion <Version>] [-CmdletsToExport <string[]>] [-DotNetFramew
orkVersion <Version>] [-FunctionsToExport <string[]>] [-Guid <Guid>] [-Modu
leList <Object[]>] [-ModuleVersion <Version>] [-PassThru] [-PowerShellHostN
ame <string>] [-PowerShellHostVersion <Version>] [-PowerShellVersion <Versi
on>] [-PrivateData <Object>] [-ProcessorArchitecture {None | MSIL | X86 | I
A64 | Amd64}] [-RequiredModules <Object[]>] [-ScriptsToProcess <string[]>]
[-VariablesToExport <string[]>] [-Confirm] [-WhatIf] [<CommonParameters>]


DESCRIPTION
The New-ModuleManifest cmdlet creates a new module manifest (.psd1) file, p
opulates its values, and saves the manifest file in the specified path.

Module authors can use this cmdlet to create a manifest for their module. A
module manifest is a .psd1 file that contains a hash table. The keys and v
alues in the hash table describe the contents and attributes of the module,
define the prerequisites, and determine how the components are processed.
Manifests are not required for a module.

New-ModuleManifest creates a manifest that includes all of the commonly use
d manifest keys, so you can use the default output as a manifest template.
To add or change values, or to add module keys that this cmdlet does not ad
d, open the resulting file in a text editor.

Each parameter of this cmdlet (except for Path and PassThru) creates a modu
le manifest key and its value. In a module manifest, only the ModuleVersion
key is required. However, several other parameters of this cmdlet are mand
atory. As a result, you can type a "New-ModuleManifest" command without par
ameters and the cmdlet will prompt you for values for other commonly used k
eys. To leave the value empty, press ENTER.

For a complete description of the format, effects, and requirements of a mo
dule manifest, see "How to Write a Module Manifest" in the MSDN (Microsoft
Developer Network) library at http://go.microsoft.com/fwlink/?LinkId=143613
.

PARAMETERS
-AliasesToExport <string[]>
Specifies the aliases that the module exports. Wildcards are permitted.

You can use this parameter to restrict the aliases that are exported by
the module. It can remove aliases from the list of exported aliases, b
ut it cannot add aliases to the list.

If you omit this parameter, New-ModuleManifest creates an AliasesToExpo
rt key with a value of * (all), meaning that all aliases that are expor
ted by the module are exported by the manifest.

-Author <string>
Specifies the module author.

This parameter is required by the cmdlet, but the Author key is not req
uired in the manifest. If you omit this parameter and do not enter a va
lue when prompted, New-ModuleManifest creates an Author key with the na
me of the current user.

-ClrVersion <Version>
Specifies the version of the Common Language Runtime (CLR) of the Micro
soft .NET Framework that the module requires.

If you omit this parameter, New-ModuleManifest creates a CLRVersion key
with an empty string value.

-CmdletsToExport <string[]>
Specifies the cmdlets that the module exports. Wildcards are permitted.

You can use this parameter to restrict the cmdlets that are exported by
the module. It can remove cmdlets from the list of exported cmdlets, b
ut it cannot add cmdlets to the list.

If you omit this parameter, New-ModuleManifest creates a CmdletsToExpor
t key with a value of * (all), meaning that all cmdlets that are export
ed by the module are exported by the manifest.

-CompanyName <string>
Identifies the company or vendor who created the module.

This parameter is required by the cmdlet, but the CompanyName key is no
t required in the manifest. If you omit this parameter and do not enter
a value when prompted, New-ModuleManifest creates a CompanyName key wi
th a value of "Unknown".

-Copyright <string>
Specifies a copyright statement for the module.

This parameter is required by the cmdlet, but the Copyright key is not
required in the manifest. If you omit this parameter and do not enter a
value when prompted, New-ModuleManifest creates a Copyright key with a
value of "(c) <year> <username>. All rights reserved." where <year> i
s the current year and <username> is the value of the Author key (if on
e is specified) or the name of the current user.

-Description <string>
Describes the contents of the module.

This parameter is required by the cmdlet, but the Description key is no
t required in the manifest. If you omit this parameter and do not enter
a value when prompted, New-ModuleManifest creates a Description key wi
th an empty string value.

-DotNetFrameworkVersion <Version>
Specifies the version of the Microsoft .NET Framework that the module r
equires.

If you omit this parameter, New-ModuleManifest creates a DotNetFrameWor
kVersion key with an empty string value.

-FileList <string[]>
Specifies all items that are included in the module.

This key is designed to act as a module inventory. These files are not
automatically exported with the module.

This parameter is required by the cmdlet, but the FileList key is not r
equired in the manifest. If you omit this parameter and do not enter a
value when prompted, New-ModuleManifest creates a FileList key with an
empty array value.

-FormatsToProcess <string[]>
Specifies the formatting files (.ps1xml) that run when the module is im
ported.

When you import a module, Windows PowerShell runs the Update-FormatData
cmdlet with the specified files. Because formatting files are not scop
ed, they affect all session states in the session.

This parameter is required by the cmdlet, but the FormatsToProcess key
is not required in the manifest. If you omit this parameter and do not
enter a value when prompted, New-ModuleManifest creates a FormatsToProc
ess key with an empty array value.

-FunctionsToExport <string[]>
Specifies the functions that the module exports. Wildcards are permitte
d.

You can use this parameter to restrict the functions that are exported
by the module. It can remove functions from the list of exported aliase
s, but it cannot add functions to the list.

If you omit this parameter, New-ModuleManifest creates an FunctionsToEx
port key with a value of * (all), meaning that all functions that are e
xported by the module are exported by the manifest.

-Guid <Guid>
Specifies a unique identifier for the module. The GUID can be used to d
istinguish among modules with the same name.

If you omit this parameter, New-ModuleManifest creates a GUID key in th
e manifest and generates a GUID for the value.

To create a new GUID in Windows PowerShell, type "[guid]::NewGuid()".

-ModuleList <Object[]>
Lists all modules that are packaged with this module.

Enter each module name as a string or enter a hash table with ModuleNam
e and GUID keys. The hash table can also have an optional ModuleVersion
key.

This key is designed to act as a module inventory. These modules are no
t automatically processed.

If you omit this parameter, New-ModuleManifest creates a ModuleList key
in the manifest with an empty array value.

-ModuleToProcess <string>
Specifies the primary or "root" file of the module. When the module is
imported, the members that are exported from the root module file are i
mported into the caller's session state. Enter the file name of one scr
ipt module (.psm1) or binary module (.dll).

If a module has a manifest file and no root file has been designated in
the ModuleToProcess key, the manifest becomes the primary file for the
module, and the module becomes a "manifest module" (ModuleType = Manif
est).

To export members from .psm1 or .dll files in a module that has a manif
est, the names of those files must be specified in the values of the Mo
duleToProcess or NestedModules keys in the manifest. Otherwise, their m
embers are not exported.

This parameter is required by the cmdlet, but the ModuleToProcess key i
s not required in the manifest. If you omit this parameter and do not e
nter a value when prompted, New-ModuleManifest creates a ModuleToProces
s key with an empty string value.

-ModuleVersion <Version>
Specifies the version of the module.

This parameter is not required by the cmdlet, but a ModuleVersion key i
s required in the manifest. If you omit this parameter, New-ModuleManif
est creates a ModuleVersion key with a value of "1.0".

-NestedModules <string[]>
Specifies script modules (.psm1) and binary modules (.dll) that are imp
orted into the module's session state. The files in the NestedModules k
ey run in the order in which they are listed in the value.

Typically, nested modules contain commands that the root module needs f
or its internal processing. By default, the commands in nested modules
are exported from the module's session state into the caller's session
state, but the root module can restrict the commands that it exports (f
or example, by using an Export-Module command).

Nested modules in the module session state are available to the root mo
dule, but they are not returned by a Get-Module command in the caller's
session state.

Scripts (.ps1) that are listed in the NestedModules key are run in the
module's session state, not in the caller's session state. To run a scr
ipt in the caller's session state, list the script file name in the val
ue of the ScriptsToProcess key in the manifest.

This parameter is required by the cmdlet, but the NestedModules key is
not required in the manifest. If you omit this parameter and do not ent
er a value when prompted, New-ModuleManifest creates a NestedModules ke
y with an empty array value.

-PassThru [<SwitchParameter>]
Writes the resulting module manifest to the console, in addition to cre
ating a .psd1 file. By default, this cmdlet does not generate any outpu
t.

-Path <string>
Specifies the path and file name of the new module manifest. Enter a pa
th and file name with a .psd1 file name extension, such as "$pshome\Mod
ules\MyModule\MyModule.psd1". This parameter is required.

If you specify the path to an existing file, New-ModuleManifest replace
s the file without warning unless the file has the read-only attribute.

The manifest should be located in the module's directory, and the manif
est file name should be the same as the module directory name, but with
a .psd1 file name extension.

Note: You cannot use variables, such as $pshome or $home, in response t
o a prompt for a Path parameter value. To use a variable, include the
Path parameter in the command.

-PowerShellHostName <string>
Specifies the name of the Windows PowerShell host program that the modu
le requires. Enter the name of the host program, such as "Windows Power
Shell ISE Host" or "ConsoleHost". Wildcards are not permitted.

To find the name of a host program, in the program, type "$host.name".

If you omit this parameter, New-ModuleManifest creates a PowerShellHost
Name key with an empty string value.

-PowerShellHostVersion <Version>
Specifies the minimum version of the Windows PowerShell host program th
at works with the module. Enter a version number, such as 1.1.

If you omit this parameter, New-ModuleManifest creates a PowerShellHost
Name key with an empty string value.

-PowerShellVersion <Version>
Specifies the minimum version of Windows PowerShell that will work with
this module. Enter 1.0 or 2.0. Requirements for versions greater than
2.0 are not enforced.

If you omit this parameter, New-ModuleManifest creates a PowerShellVers
ion key with an empty string value.

-PrivateData <Object>
Specifies data that is passed to the module when it is imported.

If you omit this parameter, New-ModuleManifest creates a PrivateData ke
y with an empty string value.

-ProcessorArchitecture <ProcessorArchitecture>
Specifies the processor architecture that the module requires. Valid va
lues are x86, AMD64, IA64, and None (unknown or unspecified).

If you omit this parameter, New-ModuleManifest creates a ProcessorArchi
tecture key with an empty string value.

-RequiredAssemblies <string[]>
Specifies the assembly (.dll) files that the module requires. Windows P
owerShell loads the specified assemblies before updating types or forma
ts, importing nested modules, or importing the module file that is spec
ified in the value of the ModuleToProcess key.

Use this parameter to list all the assemblies that the module requires,
including assemblies that must be loaded to update any formatting or t
ype files that are listed in the FormatsToProcess or TypesToProcess key
s, even if those assemblies are also listed as binary modules in the Ne
stedModules key.

This parameter is required by the cmdlet, but the RequiredAssemblies ke
y is not required in the manifest. If you omit this parameter and do no
t enter a value when prompted, New-ModuleManifest creates a RequiredAss
emblies key with an empty array value.

-RequiredModules <Object[]>
Specifies modules that must be in the global session state. If the req
uired modules are not in the global session state, attempts to import t
his module will fail.

Enter each module name as a string or enter a hash table with the Modul
eName and GUID keys. The hash table can also have an optional ModuleVer
sion key. For more information, see the examples.

Windows PowerShell does not import required modules automatically. It v
erifies only that the required modules are present. However, modules ca
n include scripts (.ps1) that import the required modules into the glob
al session state.

If you omit this parameter, New-ModuleManifest creates a RequiredModule
s key with an empty array value.

-ScriptsToProcess <string[]>
Specifies script (.ps1) files that run in the caller's session state wh
en the module is imported. You can use these scripts to prepare an envi
ronment, just as you might use a login script.

To specify scripts that run in the module's session state, use the Nest
edModules key.

If you omit this parameter, New-ModuleManifest creates a ScriptsToProce
ss key with an empty array value.

-TypesToProcess <string[]>
Specifies the type files (.ps1xml) that run when the module is imported
.

When you import the module, Windows PowerShell runs the Update-TypeData
cmdlet with the specified files. Because type files are not scoped, th
ey affect all session states in the session.

This parameter is required by the cmdlet, but the TypesToProcess key is
not required in the manifest. If you omit this parameter and do not en
ter a value when prompted, New-ModuleManifest creates a TypesToProcess
key with an empty array value.

-VariablesToExport <string[]>
Specifies the variables that the module exports. Wildcards are permitte
d.

You can use this parameter to restrict the variables that are exported
by the module. It can remove variables from the list of exported variab
les, but it cannot add variables to the list.

If you omit this parameter, New-ModuleManifest creates a VariablesToExp
ort key with a value of * (all), meaning that all variables that are ex
ported by the module are exported by the manifest.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>New-ModuleManifest

Path: C:\Users\User01\Documents\WindowsPowerShell\Modules\Test-Module\Test-
Module.psd1
NestedModules[0]: BackgroundModule.psm1
Author: Jinghao Liu
CompanyName: Fabrikam, Inc.
Copyright: Copyright © 2009 Liu Jinghao. All rights reserved.
ModuleToProcess: TestModule.psm1
Description: Cmdlets to find common errors in scripts.
TypesToProcess[0]: TestTypes.ps1xml
FormatsToProcess[0]: TestFormat.ps1xml
RequiredAssemblies[0]: Test.dll
FileList[0]: Test-Module.psd1
FileList[1]: Test-Module.psm1
FileList[2]: BackgroundModule.psm1
FileList[3]: TestTypes.ps1xml
FileList[4]: TestFormat.ps1xml
FileList[5]: Test.dll
FileList[6]: TestIcon.ico

Description
-----------
This command creates a new module manifest. The cmdlet prompts you for the
parameters that it requires, including the Path parameter, and creates a ma
nifest file in the specified location.

The output of this command shows sample responses to the prompts. To use de
fault values, press ENTER.

The actual prompt, and its handling of quoted and non-quoted phrases, depen
ds on the host program in which Windows PowerShell is running.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>New-ModuleManifest -PowerShellVersion 1.0 -AliasesToExport JKBC, DRC,
TAC

Description
-----------
This command creates a new module manifest. The command includes parameters
that the cmdlet does not require (or prompt for). You can include other ma
nifest key values at the prompt.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>New-ModuleManifest -RequiredModules FileTransfer,@{ModuleName="Backgr
oundModule";GUID="486569a2-2784-48bf-af15-70ba837a64d0";ModuleVersion="3.5"
}

Description
-----------
This example shows how to use the string and hash table formats of the Requ
iredModules parameter value. Strings and hash tables can be used in the sam
e command.

This command commands creates a module manifest for a module that requires
the FileTransfer module and a (fictitious) module named "BackgroundModule".


The command uses a string format to specify the name of the FileTransfer mo
dule and the hash table format to specify the name, a GUID, and a version o
f the BackgroundModule.




REMARKS
To see the examples, type: "get-help New-ModuleManifest -examples".
For more information, type: "get-help New-ModuleManifest -detailed".
For technical information, type: "get-help New-ModuleManifest -full".

NAME
New-Object

SYNOPSIS
Creates an instance of a Microsoft .NET Framework or COM object.


SYNTAX
New-Object -ComObject <string> [-Strict] [-Property <hashtable>] [<CommonPa
rameters>]

New-Object [-TypeName] <string> [[-ArgumentList] <Object[]>] [-Property <ha
shtable>] [<CommonParameters>]


DESCRIPTION
The New-Object cmdlet creates an instance of a .NET Framework or COM object
.

You can specify either the type of a .NET Framework class or a ProgID of a
COM object. By default, you type the fully qualified name of a .NET Framewo
rk class and the cmdlet returns a reference to an instance of that class. T
o create an instance of a COM object, use the ComObject parameter and speci
fy the ProgID of the object as its value.

PARAMETERS
-ArgumentList <Object[]>
Specifies a list of arguments to pass to the constructor of the .NET Fr
amework class. Separate elements in the list by using commas (,). The a
lias for ArgumentList is Args.

-ComObject <string>
Specifies the programmatic identifier (ProgID) of the COM object.

-Property <hashtable>
Sets property values and invokes methods of the new object.

Enter a hash table in which the keys are the names of properties or met
hods and the values are property values or method arguments. New-Object
creates the object and sets each property value and invokes each metho
d in the order that they appear in the hash table.

If the new object is derived from the PSObject class, and you specify a
property that does not exist on the object, New-Object adds the specif
ied property to the object as a NoteProperty. If the object is not a PS
Object, the command generates a non-terminating error.

-Strict [<SwitchParameter>]
Specifies that an error should be raised if the COM object that you att
empt to create uses an interop assembly. This enables you to distinguis
h actual COM objects from .NET Framework objects with COM-callable wrap
pers.

-TypeName <string>
Specifies the fully qualified name of the .NET Framework class. You can
not specify both the TypeName parameter and the ComObject parameter.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-object -typename System.Version -argumentlist "1.2.3.4"

Major Minor Build Revision
----- ----- ----- --------
1 2 3 4

Description
-----------
This command creates a System.Version object using the string "1.2.3.4" as
the constructor.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$ie = new-object -comobject InternetExplorer.Application -property @{
navigate2="www.microsoft.com"; visible = $true}

Description
-----------
This command creates an instance of the COM object that represents the Inte
rnet Explorer application. It uses the Property parameter to call the Navig
ate2 method and to set the Visible property of the object to $true to make
the application visible.

This command is the equivalent of the following:

$ie = new-object -comobject InternetExplorer.Application
$ie.navigate2("www.microsoft.com")
$ie.visible = $true




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$a=new-object -comobject Word.Application -strict -property @{visible
=$true}

New-Object : The object written to the pipeline is an instance of the type
"Microsoft.Office.Interop.Word.ApplicationClass" from the component's prima
ry interop assembly. If this type exposes different members than the IDispa
tch members, scripts written to work with this object might not work if the
primary interop assembly is not installed.
At line:1 char:14
+ $a=New-Object <<<< -COM Word.Application -Strict; $a.visible=$true

Description
-----------
This command demonstrates that specifying the Strict parameter causes the N
ew-Object cmdlet to generate a non-terminating error when the COM object th
at is created uses an interop assembly.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$objshell = new-object -comobject "Shell.Application"

C:\PS> $objshell | get-member

C:\PS> $objshell.ToggleDesktop()

Description
-----------
The command uses the ComObject parameter to create a COM object with the "S
hell.Application" ProgID. It stores the resulting object in the $objShell v
ariable.

The second command pipes the $objShell variable to the Get-Member cmdlet, w
hich displays the properties and methods of the COM object.

The third command calls the ToggleDesktop method of the object to minimize
the open windows on your desktop.




REMARKS
To see the examples, type: "get-help New-Object -examples".
For more information, type: "get-help New-Object -detailed".
For technical information, type: "get-help New-Object -full".

NAME
New-PSDrive

SYNOPSIS
Creates a Windows PowerShell drive in the current session.


SYNTAX
New-PSDrive [-Name] <string> [-PSProvider] <string> [-Root] <string> [-Cred
ential <PSCredential>] [-Description <string>] [-Scope <string>] [-Confirm]
[-WhatIf] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
The New-PSDrive cmdlet creates a Windows PowerShell drive that is "mapped"
to or associated with a location in a data store, such as a network drive,
a directory on the local computer, or a registry key.

You can use the Windows PowerShell drives that you create to access data in
the associated data store, just like you would do with any mapped drive. Y
ou can change locations into the drive (using "set-location", "cd", or "chd
ir") and access the contents of the drive (using "get-item", "get-childitem
", or "dir").

However, the Windows PowerShell drives are known only to Windows PowerShell
. You cannot access them by using Windows Explorer, Windows Management Inst
rumentation (WMI), Component Object Model (COM), or the Microsoft .NET Fram
ework, or by using tools such as Net Use.

Windows PowerShell drives exist only in the current Windows PowerShell ses
sion. To make the drive persistent, you can export the session to which you
have added the drive, or you can save a New-PSDrive command in your Window
s PowerShell profile.

To delete a drive that was created by New-PSDrive, use the Remove-PSDrive c
mdlet.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01". Or, enter a PS
Credential object, such as one generated by the Get-Credential cmdlet.
If you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell.

-Description <string>
Specifies a brief text description of the drive. Type any string.

To see the descriptions of all of the Windows PowerShell drives on your
system, type "get-psdrive | format name, description". To see the desc
ription of a particular Windows PowerShell drives, type "(get-psdrive <
DriveName>).description".

-Name <string>
Specifies a name for the new drive. You can use any valid string for th
e name. You are not limited to drive letters. Windows PowerShell drives
names are case-sensitive.

-PSProvider <string>
Specifies the Windows PowerShell provider that supports drives of this
type.

For example, if the Windows PowerShell drives is associated with a net
work share or file system directory, the Windows PowerShell provider is
"FileSystem". If the Windows PowerShell drive is associated with a reg
istry key, the provider is "Registry".

To see a list of the providers in your Windows PowerShell session, type
"get-psprovider".

-Root <string>
Specifies the data store location that the Windows PowerShell drive is
mapped to.

For example, specify a network share (such as \\Server01\Public), a loc
al directory (such as C:\Program Files), or a registry key (such as HKL
M:\Software\Microsoft).

-Scope <string>
Specifies a scope for the drive. Valid values are "Global", "Local", or
"Script", or a number relative to the current scope (0 through the num
ber of scopes, where 0 is the current scope and 1 is its parent). "Loca
l" is the default. For more information, see about_Scopes.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-psdrive -name P -psprovider FileSystem -root \\Server01\Public

Name Provider Root
---- -------- ----
P FileSystem \\Server01\Public

Description
-----------
This command creates a Windows PowerShell drive that functions like a mappe
d network drive in Windows. The command creates a Windows PowerShell drive
named P: that is mapped to the \\Server01\Public network share.

It uses the Name parameter to specify a name for the drive, the PSProvider
parameter to specify the Windows PowerShell FileSystem provider, and the Ro
ot parameter to specify the network share.

When the command completes, the contents of the \\Server01\Public share app
ear in the P: drive. To see them, type: "dir p:".




-------------------------- EXAMPLE 2 --------------------------

C:\PS>new-psdrive -name MyDocs -psprovider FileSystem -root "C:\Documents a
nd Settings\User01\My Documents" -Description "Maps to my My Documents fold
er."

Name Provider Root
---- -------- ----
MyDocs FileSystem C:\Documents and Settings\User01\My Documents

Description
-----------
This command creates a Windows PowerShell drive that provides quick access
to a local directory. It creates a drive named MyDocs: that is mapped to th
e
"C:\Documents and Settings\User01\My Documents" directory on the local comp
uter.

It uses the Name parameter to specify a name for the drive, the PSProvider
parameter to specify the Windows PowerShell FileSystem provider, the Root p
arameter to specify the path to the My Documents folder, and the Descriptio
n parameter to create a description of the drive.


When the command completes, the contents of the My Documents folder appear
in the MyDocs: drive. To see them, type: "dir mydocs:".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>new-psdrive -name MyCompany -psprovider Registry -root HKLM:\Software
\MyCompany

Name Provider Root
---- -------- ----
MyCompany Registry HKEY_LOCAL_MACHINE\Software\MyCo...

Description
-----------
This command creates a Windows PowerShell drive that provides quick access
to a frequently checked registry key. It creates a drive named MyCompany th
at is mapped to the HKLM\Software\MyCompany registry key.

It uses the Name parameter to specify a name for the drive, the PSProvider
parameter to specify the Windows PowerShell Registry provider, and the Root
parameter to specify the registry key.


When the command completes, the contents of the MyCompany key appear in the
MyCompany: drive. To see them, type: "dir MyCompany:".




-------------------------- EXAMPLE 4 --------------------------

C:\PS>new-psdrive -name PsDrive -psprovider FileSystem -root \\Server01\Pub
lic

C:\PS> $drive = new-object -com wscript.network
C:\PS> $drive.MapNetworkDrive("X:", "\\Server01\Public")


C PS:\> get-psdrive public, x

Name Provider Root
---- -------- ----
PsDrive FileSystem \\Server01\public
X FileSystem X:\


C:\PS>get-psdrive psdrive, x | get-member

TypeName: System.Management.Automation.PSDriveInfo
Name MemberType Definition
---- ---------- ----------
CompareTo Method System.Int32 CompareTo(PSDriveInfo drive),
Equals Method System.Boolean Equals(Object obj),
GetHashCode Method System.Int32 GetHashCode()
...



C:\PS> net use
Status Local Remote Network
---------------------------------------------------------------------------
X: \\server01\public Microsoft Windows Network


C:\PS> get-wmiobject win32_logicaldisk | ft deviceid
deviceid
--------
C:
D:
X:

C:\PS> get-wmiobject win32_networkconnection
LocalName RemoteName ConnectionState
Status
--------- ---------- ---------------
------
X: \\products\public Disconnected
Unavailable

Description
-----------
This example shows the difference between a Windows drive that is mapped to
a network share and a Windows PowerShell drive that is mapped to the same
network share.

The first command uses the New-PSDrive cmdlet to create a Windows PowerShel
l drive called PSDrive: that is mapped to the \\Server01\Public network sha
re.

The second set of commands uses the New-Object cmdlet to create a Wscript.N
etwork COM object and then use its MapNetworkDrive method to map the \\Serv
er01\Public network share to the X: drive on the local computer.

Now, you can examine the two drives. Using a Get-PSDrive drive command, the
drives appear to be the same, although the network share name appears only
in the root of the PSDrive: drive.

Sending the drive objects to Get-Member shows that they have the same objec
t type, System.Management.Automation.PSDriveInfo.

However, a "net use" command, a Get-WmiObject command to the Win32_LogicalD
isk class, and a Get-WmiObject command to the Win32_NetworkConnection class
find only the X: drive that was created by using the Wscript.Network objec
t. That is because Windows PowerShell drives are known only to Windows Powe
rShell.

If you close the Windows PowerShell session and then open a new one, the PS
Drive: drive is gone, and the X: drive persists.

Therefore, when deciding which method to use to map network drives, conside
r how you will use the drive, whether it needs to be persistant, and whethe
r the drive needs to be visible to other Windows features.




REMARKS
To see the examples, type: "get-help New-PSDrive -examples".
For more information, type: "get-help New-PSDrive -detailed".
For technical information, type: "get-help New-PSDrive -full".

NAME
New-PSSession

SYNOPSIS
Creates a persistent connection to a local or remote computer.


SYNTAX
New-PSSession [[-ComputerName] <string[]>] [-ApplicationName <string>] [-Au
thentication {Default | Basic | Negotiate | NegotiateWithImplicitCredential
| Credssp | Digest | Kerberos}] [-CertificateThumbprint <string>] [-Config
urationName <string>] [-Credential <PSCredential>] [-Name <string[]>] [-Por
t <int>] [-SessionOption <PSSessionOption>] [-UseSSL] [-ThrottleLimit <int>
] [<CommonParameters>]

New-PSSession [[-Session] <PSSession[]>] [-Name <string[]>] [-ThrottleLimit
<int>] [<CommonParameters>]

New-PSSession [-ConnectionURI] <Uri[]> [-AllowRedirection] [-Authentication
{Default | Basic | Negotiate | NegotiateWithImplicitCredential | Credssp |
Digest | Kerberos}] [-CertificateThumbprint <string>] [-ConfigurationName
<string>] [-Credential <PSCredential>] [-Name <string[]>] [-SessionOption <
PSSessionOption>] [-ThrottleLimit <int>] [<CommonParameters>]


DESCRIPTION
The New-PSSession cmdlet creates a Windows PowerShell session (PSSession) o
n a local or remote computer. When you create a PSSession, Windows PowerSh
ell establishes a persistent connection to the remote computer.

Use a PSSession to run multiple commands that share data, such as a functio
n or the value of a variable. To run commands in a PSSession, use the Invok
e-Command cmdlet. To use the PSSession to interact directly with a remote c
omputer, use the Enter-PSSession cmdlet. For more information, see about_PS
Sessions.

You can run commands on a remote computer without creating a PSSession by u
sing the ComputerName parameters of Enter-PSSession or Invoke-Command. When
you use the ComputerName parameter, Windows PowerShell creates a temporary
connection that is used for the interactive session or for a single comman
d and is then closed.

PARAMETERS
-AllowRedirection [<SwitchParameter>]
Allows redirection of this connection to an alternate Uniform Resource
Identifier (URI).

When you use the ConnectionURI parameter, the remote destination can re
turn an instruction to redirect to a different URI. By default, Windows
PowerShell does not redirect connections, but you can use the AllowRed
irection parameter to allow it to redirect the connection.

You can also limit the number of times that the connection is redirecte
d by setting the MaximumConnectionRedirectionCount property of the $PSS
essionOption preference variable, or the MaximumConnectionRedirectionCo
unt property of the value of the SessionOption parameter.
The default value is 5. For more information, see the description of th
e SessionOption parameter, and see New-PSSessionOption.

-ApplicationName <string>
Specifies the application name segment of the connection URI. Use this
parameter to specify the application name when you are not using the Co
nnectionURI parameter in the command.

The default value is the value of the $PSSessionApplicationName prefere
nce variable on the local computer. If this preference variable is not
defined, the default value is "WSMAN". This value is appropriate for mo
st uses. For more information, see about_Preference_Variables.

The WinRM service uses the application name to select a listener to ser
vice the connection request. The value of this parameter should match t
he value of the URLPrefix property of a listener on the remote computer
.

-Authentication <AuthenticationMechanism>
Specifies the mechanism that is used to authenticate the user's credent
ials. Valid values are "Default", "Basic", "Credssp", "Digest", "Kerb
eros", "Negotiate", and "NegotiateWithImplicitCredential". The default
value is "Default".

CredSSP authentication is available only in Windows Vista, Windows Serv
er 2008, and later versions of Windows.

For more information about the values of this parameter, see the descri
ption of the System.Management.Automation.Runspaces.AuthenticationMecha
nism enumeration in the MSDN (Microsoft Developer Network) library at h
ttp://go.microsoft.com/fwlink/?LinkID=144382.

Caution: Credential Security Service Provider (CredSSP) authentication,
in which the user's credentials are passed to a remote computer to be
authenticated, is designed for commands that require authentication on
more than one resource, such as accessing a remote network share. This
mechanism increases the security risk of the remote operation. If the r
emote computer is compromised, the credentials that are passed to it ca
n be used to control the network session.

-CertificateThumbprint <string>
Specifies the digital public key certificate (X509) of a user account t
hat has permission to perform this action. Enter the certificate thumbp
rint of the certificate.

Certificates are used in client certificate-based authentication. They
can be mapped only to local user accounts; they do not work with domain
accounts.

To get a certificate thumbprint, use the Get-Item or Get-ChildItem comm
and in the Windows PowerShell Cert: drive.

-ComputerName <string[]>
Creates a persistent connection (PSSession) to the specified computer.
If you enter multiple computer names, New-PSSession creates multiple PS
Sessions, one for each computer. The default is the local computer.

Type the NetBIOS name, an IP address, or a fully qualified domain name
of one or more remote computers. To specify the local computer, type th
e computer name, "localhost", or a dot (.). When the computer is in a d
ifferent domain than the user, the fully qualified domain name is requi
red. You can also pipe a computer name (in quotes) to New-PSSession.

To use an IP address in the value of the ComputerName parameter, the co
mmand must include the Credential parameter. Also, the computer must be
configured for HTTPS transport or the IP address of the remote compute
r must be included in the WinRM TrustedHosts list on the local computer
. For instructions for adding a computer name to the TrustedHosts list,
see "How to Add a Computer to the Trusted Host List" in about_Remote_
Troubleshooting.

Note: In Windows Vista and later versions of Windows, to include the l
ocal computer in the value of the ComputerName parameter, you must star
t Windows PowerShell with the "Run as administrator" option.

-ConfigurationName <string>
Specifies the session configuration that is used for the new PSSession.


Enter a configuration name or the fully qualified resource Uniform Reso
urce Identifier (URI) for a session configuration. If you specify only
the configuration name, the following schema URI is prepended: http://
schemas.microsoft.com/powershell.

The session configuration for a session is located on the remote comput
er. If the specified session configuration does not exist on the remote
computer, the command fails.

The default value is the value of the $PSSessionConfigurationName prefe
rence variable on the local computer. If this preference variable is no
t set, the default is Microsoft.PowerShell. For more information, see a
bout_Preference_Variables.

-ConnectionURI <Uri[]>
Specifies a Uniform Resource Identifier (URI) that defines the connecti
on endpoint. The URI must be fully qualified.

The format of this string is as follows:
<Transport>://<ComputerName>:<Port>/<ApplicationName>

The default value is as follows:
http://localhost:80/WSMAN

Valid values for the Transport segment of the URI are HTTP and HTTPS. I
f you do not specify a ConnectionURI, you can use the UseSSL, ComputerN
ame, Port, and ApplicationName parameters to specify the URI values.

If the destination computer redirects the connection to a different URI
, Windows PowerShell prevents the redirection unless you use the AllowR
edirection parameter in the command.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01", "Domain01\User01", or "User@Domain.
com", or enter a PSCredential object, such as one returned by the Get-C
redential cmdlet.

When you type a user name, you will be prompted for a password.

-Name <string[]>
Specifies a friendly name for the PSSession.

You can use the name to refer to the PSSession when using other cmdlets
, such as Get-PSSession and Enter-PSSession. The name is not required t
o be unique to the computer or the current session.

-Port <int>
Specifies the network port on the remote computer that is used for thi
s command. The default is port 80 (the HTTP port).

Before using an alternate port, you must configure the WinRM listener o
n the remote computer to listen at that port. Use the following command
s to configure the listener:

1. winrm delete winrm/config/listener?Address=*+Transport=HTTP
2. winrm create winrm/config/listener?Address=*+Transport=HTTP @{Port=&
quot;&lt;port-number&gt;&quot;}

Do not use the Port parameter unless you must. The port setting in the
command applies to all computers and sessions in which the command runs
. An alternate port setting might prevent the command from running on a
ll computers.

-Session <PSSession[]>
Uses the specified PSSession as a model for the new PSSession. This par
ameter creates new PSSessions with the same properties as the specified
PSSessions.

Enter a variable that contains the PSSessions or a command that creates
or gets the PSSessions, such as a New-PSSession or Get-PSSession comma
nd.

The resulting PSSessions have the same computer name, application name,
connection URI, port, configuration name, throttle limit, and Secure S
ockets Layer (SSL) value as the originals, but they have a different di
splay name, ID, and instance ID (GUID).

-SessionOption <PSSessionOption>
Sets advanced options for the session. Enter a SessionOption object th
at you create by using the New-PSSessionOption cmdlet.

The default values for the options are determined by the value of the $
PSSessionOption preference variable, if it is set. Otherwise, the sessi
on uses the system defaults.

For a description of the session options, including the default values,
see New-PSSessionOption. For information about the $PSSessionOption pr
eference variable, see about_Preference_Variables.

-ThrottleLimit <int>
Specifies the maximum number of concurrent connections that can be esta
blished to run this command. If you omit this parameter or enter a valu
e of 0 (zero), the default value, 32, is used.

The throttle limit applies only to the current command, not to the sess
ion or to the computer.

-UseSSL [<SwitchParameter>]
Uses the Secure Sockets Layer (SSL) protocol to establish a connection
to the remote computer. By default, SSL is not used.

WS-Management encrypts all Windows PowerShell content transmitted over
the network. UseSSL is an additional protection that sends the data acr
oss an HTTPS connection instead of an HTTP connection.

If you use this parameter, but SSL is not available on the port used fo
r the command, the command fails.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$s = new-pssession

Description
-----------
This command creates a new PSSession on the local computer and saves the PS
Session in the $s variable.

You can now use this PSSession to run commands on the local computer.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$Server01 = new-pssession -ComputerName Server01

Description
-----------
This command creates a new PSSession on the Server01 computer and saves it
in the $Server01 variable.

When creating multiple PSSessions, assign them to variables with useful nam
es. This will help you manage the PSSessions in subsequent commands.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$s1, $s2, $s3 = new-session -computername server1,server2,server3

Description
-----------
This command creates three new PSSessions, one on each of the computers spe
cified by the ComputerName parameter.

The command uses the assignment operator (=) to assign the new PSSessions t
o an array of variables: $s1, $s2, $s3. It assigns the Server01 PSSession t
o $s1, the Server02 PSSession to $s2, and the Server03 PSSession to $s3.

When you assign multiple objects to an array of variables, Windows PowerShe
ll assigns each object to a variable in the array respectively. If there ar
e more objects than variables, all remaining objects are assigned to the la
st variable. If there are more variables than objects, the remaining variab
les are empty (null).




-------------------------- EXAMPLE 4 --------------------------

C:\PS>new-pssession -computername Server01 -port 8081 -useSSL -Configuratio
nName E12

Description
-----------
This command creates a new PSSession on the Server01 computer that connects
to server port 8081 and uses the SSL protocol. The new PSSession uses an a
lternate session configuration called "E12".

Before setting the port, you must configure the WinRM listener on the remot
e computer to listen on port 8081. For more information, see the descriptio
n of the Port parameter.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>new-pssession -session $s -credential domain01\user01

Description
-----------
This command creates a new PSSession with the same properties as an existin
g PSSession. You can use this command format when the resources of an exist
ing PSSession are exhausted and a new PSSession is needed to offload some o
f the demand.

The command uses the Session parameter of New-PSSession to specify the PSSe
ssion saved in the $s variable. It uses the credentials of the Domain1\Admi
n01 user to complete the command.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>$global:s = new-pssession -computername server1.domain44.corpnet.fabr
ikam.com -credential domain01\admin01

Description
-----------
This example shows how to create a PSSession with a global scope on a compu
ter in a different domain.

By default, PSSessions created at the command line are created with local s
cope and PSSessions created in a script have script scope.

To create a PSSession with global scope, create a new PSSession and then st
ore the PSSession in a variable that is cast to a global scope. In this cas
e, the $s variable is cast to a global scope.

The command uses the ComputerName parameter to specify the remote computer.
Because the computer is in a different domain than the user account, the f
ull name of the computer is specified along with the credentials of the use
r.




-------------------------- EXAMPLE 7 --------------------------

C:\PS>$rs = get-content c:\test\servers.txt | new-PSsession -throttleLimit
50

Description
-----------
This command creates a PSSession on each of the 200 computers listed in the
Servers.txt file and it stores the resulting PSSession in the $rs variable
. The PSSessions have a throttle limit of 50.

You can use this command format when the names of computers are stored in a
database, spreadsheet, text file, or other text-convertible format.




-------------------------- EXAMPLE 8 --------------------------

C:\PS>$s = new-PSSession -URI http://Server01:91/NewSession -credential dom
ain01\user01

Description
-----------
This command creates a PSSession on the Server01 computer and stores it in
the $s variable. It uses the URI parameter to specify the transport protoco
l, the remote computer, the port, and an alternate session configuration. I
t also uses the Credential parameter to specify a user account with permiss
ion to create a session on the remote computer.




-------------------------- EXAMPLE 9 --------------------------

C:\PS>$s = new-PSSession -computername (import-csv servers.csv) -credential
domain01\admin01 -throttlelimit 16

C:\PS> invoke-command -session $s -scriptblock {get-process powershell} -As
Job

Description
-----------
These commands create a set of PSSessions and then run a background job in
each of the PSSessions.

The first command creates a new PSSession on each of the computers listed i
n the Servers.csv file. It uses the New-PSSession cmdlet to create the PSSe
ssion. The value of the ComputerName parameter is a command that uses the I
mport-Csv cmdlet to import the Servers.csv file and read its contents.

The command uses the Credential parameter to create the PSSessions with the
permission of a domain administrator, and it uses the ThrottleLimit parame
ter to limit the command to 16 concurrent connections. The command saves th
e PSSessions in the $s variable.

The second command uses the AsJob parameter of Invoke-Command to start a ba
ckground job that runs a "Get-Process PowerShell" command in each of the PS
Sessions in $s.

For more information about background jobs, see about_Jobs and about_Remote
_Jobs.




-------------------------- EXAMPLE 10 --------------------------

C:\PS>new-PSSession -ConnectionURI https://management.exchangelabs.com/Mana
gement

Description
-----------
This command creates a new PSSession that connects to a computer that is sp
ecified by a URI instead of a computer name.




-------------------------- EXAMPLE 11 --------------------------

C:\PS>$so = New-WSManSessionOption -SkipCACheck

PS C:\> new-pssession -ConnectionUri https://management.exchangelabs.com/Ma
nagement -SessionOption $so -credential server01\admin01

Description
-----------
This example shows how to create and use a SessionOption parameter.

The first command uses the New-WSManSessionOption cmdlet to create a sessio
n option. It saves the resulting SessionOption object in the $so parameter.

The second command uses the option in a new session. The command uses the N
ew-PSSession cmdlet to create a new session. The value of the SessionOption
parameter is the SessionOption object in the $so variable.




REMARKS
To see the examples, type: "get-help New-PSSession -examples".
For more information, type: "get-help New-PSSession -detailed".
For technical information, type: "get-help New-PSSession -full".

NAME
New-PSSessionOption

SYNOPSIS
Creates an object that contains advanced options for a PSSession.


SYNTAX
New-PSSessionOption [-ApplicationArguments <PSPrimitiveDictionary>] [-Cance
lTimeOut <int>] [-Culture <CultureInfo>] [-IdleTimeOut <int>] [-MaximumRece
ivedDataSizePerCommand <int>] [-MaximumReceivedObjectSize <int>] [-MaximumR
edirection <int>] [-NoCompression] [-NoEncryption] [-NoMachineProfile] [-Op
enTimeOut <int>] [-OperationTimeOut <int>] [-ProxyAccessType {None | IEConf
ig | WinHttpConfig | AutoDetect | NoProxyServer}] [-ProxyAuthentication {De
fault | Basic | Negotiate | NegotiateWithImplicitCredential | Credssp | Dig
est | Kerberos}] [-ProxyCredential <PSCredential>] [-SkipCACheck] [-SkipCNC
heck] [-SkipRevocationCheck] [-UICulture <CultureInfo>] [-UseUTF16] [<Commo
nParameters>]


DESCRIPTION
The New-PSSessionOption cmdlet creates an object that contains advanced opt
ions for a PSSession. You can use the object as the value of the SessionOpt
ion parameter of cmdlets that create a PSSession, such as New-PSSession, En
ter-PSSession, and Invoke-Command.

Without parameters, New-PSSessionOption generates an object that contains t
he default values for all of the options. Because all of the properties can
be edited, you can use the resulting object as a template, and create stan
dard option objects for your enterprise.

PARAMETERS
-ApplicationArguments <PSPrimitiveDictionary>
Specifies a hash table that is sent directly to the session configurati
on without interpretation. This hash table is available to the session
configuration as a property of the PSSenderInfo class.

-CancelTimeOut <int>
Determines how long Windows PowerShell waits for a cancel operation (CT
RL + C) to complete before terminating it. Enter a value in millisecon
ds.

The default value is 60000 (one minute). A value of 0 (zero) means no t
imeout; the command continues indefinitely.

-Culture <CultureInfo>
Specifies the culture to use for the PSSession. Enter a culture name in
<languagecode2>-<country/regioncode2> format, such as "ja-jP", a vari
able that contains a CultureInfo object, or a command that gets a Cultu
reInfo object, such as "get-culture".

The default value is $null, and the culture that is set in the operatin
g system when the PSSession is created is used in the PSSession.

-IdleTimeOut <int>
Determines how long the PSSession stays open if the remote computer doe
s not receive any communication from the local computer, including the
heartbeat signal. When the interval expires, the PSSession closes.

Enter a value in milliseconds. The default value is 240000 (4 minutes).
The minimum value is 60000 (1 minute).

If both the local and remote computers specify an idle timeout value, t
he PSSession uses the shorter timeout value. The local computer can set
an idle timeout value by using this parameter or by setting an idle ti
meout in the $PSSessionOption preference variable. The remote computer
can specify an idle timeout value in the WS-Management configuration (W
SMAN:\localhost\shell\idletimeout).

-MaximumReceivedDataSizePerCommand <int>
Specifies the maximum number of bytes that the local computer can recei
ve from the remote computer in a single command. Enter a value in bytes
. By default, there is no data size limit.

This option is designed to protect the resources on the client computer
.

-MaximumReceivedObjectSize <int>
Specifies the maximum size of an object that the local computer can rec
eive from the remote computer. Enter a value in bytes. By default, ther
e is no data size limit.

This option is designed to protect the resources on the client computer
.

-MaximumRedirection <int>
Determines how many times Windows PowerShell redirects a connection to
an alternate Uniform Resource Identifier (URI) before the connection fa
ils. The default value is 5. A value of 0 (zero) prevents all redirecti
on.

This option is used in the PSSession only when the AllowRedirection par
ameter is used in the command that creates the PSSession.

-NoCompression [<SwitchParameter>]
Turns off packet compression in the PSSession. Compression uses more pr
ocessor cycles, but it makes transmission faster.

-NoEncryption [<SwitchParameter>]
Turns off data encryption.

-NoMachineProfile [<SwitchParameter>]
Prevents loading the user's Windows user profile. As a result, the PSSe
ssion might be created faster, but user-specific registry settings, ite
ms such as environment variables, and certificates are not available in
the PSSession.

-OpenTimeOut <int>
Determines how long the client computer waits for the session connectio
n to be established. When the interval expires, the command to establis
h the connection fails. Enter a value in milliseconds.

The default value is 180000 (3 minutes). A value of 0 (zero) means no t
ime-out; the command continues indefinitely.

-OperationTimeOut <int>
Determines the maximum time that any operation in the PSSession can run
. When the interval expires, the operation fails. Enter a value in mill
iseconds.

The default value is 180000 (3 minutes). A value of 0 (zero) means no t
ime-out; the operation continues indefinitely.

-ProxyAccessType <ProxyAccessType>
Determines which mechanism is used to resolve the host name. Valid valu
es are IEConfig, WinHttpConfig, AutoDetect, NoProxyServer and None. The
default value is None.

For information about the values of this parameter, see the description
of the System.Management.Automation.Remoting.ProxyAccessType enumerati
on in the MSDN (Microsoft Developer Network) Library at http://go.micro
soft.com/fwlink/?LinkId=144756.

-ProxyAuthentication <AuthenticationMechanism>
Specifies the authentication method that is used for proxy resolution.
Valid values are Basic, Digest, and Negotiate. The default value is Neg
otiate.

For information about the values of this parameter, see the description
of the System.Management.Automation.Runspaces.AuthenticationMechanism
enumeration in the MSDN library at http://go.microsoft.com/fwlink/?Link
ID=144382.

-ProxyCredential <PSCredential>
Specifies the credentials to use for proxy authentication. Enter a vari
able that contains a PSCredential object or a command that gets a PSCre
dential object, such as Get-Credential. If this option is not set, no c
redentials are specified.

-SkipCACheck [<SwitchParameter>]
Specifies that when connecting over HTTPS, the client does not validate
that the server certificate is signed by a trusted certificate authori
ty (CA).

Use this option only when the remote computer is trusted by using anoth
er mechanism, such as when the remote computer is part of a network tha
t is physically secure and isolated, or the remote computer is listed a
s a trusted host in a WinRM configuration.

-SkipCNCheck [<SwitchParameter>]
Specifies that the certificate common name (CN) of the server does not
need to match the hostname of the server. This option is used only in r
emote operations that use the HTTPS protocol.

Use this option only for trusted computers.

-SkipRevocationCheck [<SwitchParameter>]
Does not validate the revocation status of the server certificate.

-UICulture <CultureInfo>
Specifies the UI culture to use for the PSSession.

Enter a culture name in <languagecode2>-<country/regioncode2> format, s
uch as "ja-jP", a variable that contains a CultureInfo object, or a co
mmand that gets a CultureInfo object, such as Get-Culture.

The default value is $null, and the UI culture that is set in the opera
ting system when the PSSession is created is used in the PSSession.

-UseUTF16 [<SwitchParameter>]
Encode the request in UTF16 format rather than UTF8 format.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>New-PSSessionOption


MaximumConnectionRedirectionCount : 5
NoCompression : False
NoMachineProfile : False
ProxyAccessType : IEConfig
ProxyAuthentication : Negotiate
ProxyCredential :
SkipCACheck : False
SkipCNCheck : False
SkipRevocationCheck : False
OperationTimeout : 00:03:00
NoEncryption : False
UseUTF16 : False
Culture :
UICulture :
MaximumReceivedDataSizePerCommand :
MaximumReceivedObjectSize :
ApplicationArguments :
OpenTimeout : 00:03:00
CancelTimeout : 00:01:00
IdleTimeout : 00:04:00

Description
-----------
This command creates a session option object with all of the default values
.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$pso = new-pssessionoption -Culture "fr-fr" -MaximumReceivedObjectSiz
e 10MB

C:\PS> new-pssession -computerName Server01 -SessionOption $pso

Description
-----------
This example shows how to use a session option object to configure a sessio
n.

The first command creates a new session option object and saves it in the v
alue of the $pso variable.

The second command uses the New-PSSession cmdlet to create a PSSession on t
he Server01 remote computer. The command uses the session option object in
the value of the $pso variable as the value of the SessionOption parameter
of the command.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>enter-pssession -computername Server01 -sessionOption (new-pssessiono
ption -noEncryption -noCompression)

Description
-----------
This command uses the Enter-PSSession cmdlet to start an interactive sessio
n with the Server01 computer. The value of the SessionOption parameter is a
New-PSSessionOption command with the NoEncryption and NoCompression switch
parameters.

The New-PSSessionOption command is enclosed in parentheses to make sure tha
t it runs before the Enter-PSSession command.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$a = new-pssessionoption


MaximumConnectionRedirectionCount : 5
NoCompression : False
NoMachineProfile : False
ProxyAccessType : IEConfig
ProxyAuthentication : Negotiate
ProxyCredential :
SkipCACheck : False
SkipCNCheck : False
SkipRevocationCheck : False
OperationTimeout : 00:03:00
NoEncryption : False
UseUTF16 : False
Culture :
UICulture :
MaximumReceivedDataSizePerCommand :
MaximumReceivedObjectSize :
ApplicationArguments :
OpenTimeout : 00:03:00
CancelTimeout : 00:01:00
IdleTimeout : 00:04:00

C:\PS> $a.UICulture = (get-UICulture)
C:\PS> $a.OpenTimeout = (new-timespan -minutes 4)
C:\PS> $a.MaximumConnectionRedirectionCount = 1

C:\PS> $a

MaximumConnectionRedirectionCount : 1
NoCompression : False
NoMachineProfile : False
ProxyAccessType : IEConfig
ProxyAuthentication : Negotiate
ProxyCredential :
SkipCACheck : False
SkipCNCheck : False
SkipRevocationCheck : False
OperationTimeout : 00:03:00
NoEncryption : False
UseUTF16 : False
Culture :
UICulture : en-US
MaximumReceivedDataSizePerCommand :
MaximumReceivedObjectSize :
ApplicationArguments :
OpenTimeout : 00:04:00
CancelTimeout : 00:01:00
IdleTimeout : 00:04:00

Description
-----------
This example demonstrates that you can edit the session option object. All
properties have read/write values.

Use this method to create a standard session object for your enterprise, an
d then create customized versions of it for particular uses.




-------------------------- EXAMPLE 5 --------------------------

C:\PS>$PSSessionOption = New-PSSessionOption -OpenTimeOut 120000

Description
-----------
This command creates a $PSSessionOption preference variable.

When the $PSSessionOption preference variable exists in the session, it est
ablishes default values for options in the PSSessions that are created by u
sing the New-PSSession, Enter-PSSession, and Invoke-Command cmdlets.

To make the $PSSessionOption variable available in all sessions, add it to
your Windows PowerShell session and to your Windows PowerShell profile.

For more information about the $PSSessionOption variable, see about_Prefere
nce_Variables. For more information about profiles, see about_Profiles.




-------------------------- EXAMPLE 6 --------------------------

C:\PS>$skipCN = new-pssessionoption -SkipCNCheck

C:\PS> new-pssession -computername 171.09.21.207 -UseSSL -credential domain
01\user01 -sessionOption $skipCN

Description
-----------
This example shows how to use a SessionOption object to fulfill the require
ments for a remote session configuration.

The first command uses the New-PSSessionOption cmdlet to create a session o
ption object with the SkipCNCheck property. The command saves the resulting
session object in the $skipCN variable.

The second command uses the New-PSSession cmdlet to create a new PSSession
on a remote computer. The $skipCN check variable is used in the value of th
e SessionOption parameter.

Because the computer is identified by its IP address, the value of the Comp
uterName parameter does not match any of the common names in the certificat
e used for Secure Sockets Layer (SSL). As a result, the SkipCNCheck option
is required.




REMARKS
To see the examples, type: "get-help New-PSSessionOption -examples".
For more information, type: "get-help New-PSSessionOption -detailed".
For technical information, type: "get-help New-PSSessionOption -full".

NAME
New-Service

SYNOPSIS
Creates a new Windows service.


SYNTAX
New-Service [-Name] <string> [-BinaryPathName] <string> [-Credential <PSCre
dential>] [-DependsOn <string[]>] [-Description <string>] [-DisplayName <st
ring>] [-StartupType {Automatic | Manual | Disabled}] [-Confirm] [-WhatIf]
[<CommonParameters>]


DESCRIPTION
The New-Service cmdlet creates a new entry for a Windows service in the reg
istry and in the service database. A new service requires an executable fil
e that executes during the service.

The parameters of this cmdlet let you set the display name, description, st
artup type, and dependencies of the service.

PARAMETERS
-BinaryPathName <string>
Specifies the path to the executable file for the service. This paramet
er is required.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Ty
pe a user name, such as "User01" or "Domain01\User01". Or, enter a PSCr
edential object, such as one from the Get-Credential cmdlet. If you typ
e a user name, you will be prompted for a password.

-DependsOn <string[]>
Specifies the names of other services upon which the new service depend
s. To enter multiple service names, use a comma to separate the names.

-Description <string>
Specifies a description of the service.

-DisplayName <string>
Specifies a display name for the service.

-Name <string>
Specifies the name of the service. This parameter is required.

-StartupType <ServiceStartMode>
Sets the startup type of the service. "Automatic" is the default.

Valid values are:

-- Manual: The service is started only manually, by a user (using
the Service Control Manager) or by an application.

-- Automatic: The service is to be started (or was started) by the op
erating system, at system start-up. If an automatically started service
depends on a manually started service, the manually started service is
also started automatically at system startup.

-- Disabled: The service is disabled and cannot be started by a user or
application.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-service -name TestService -binaryPathName "C:\WINDOWS\System32\sv
chost.exe -k netsvcs"

Description
-----------
This command creates a new service named "TestService".




-------------------------- EXAMPLE 2 --------------------------

C:\PS>new-service -name TestService -path "C:\WINDOWS\System32\svchost.exe
-k netsvcs" -dependson NetLogon -displayName "Test Service" -StartupType Ma
nual -Description "This is a test service."

Description
-----------
This command creates a new service named "TestService". It uses the paramet
ers of the New-Service cmdlet to specify a description, startup type, and d
isplay name for the new service.

To specify the BinaryPathName parameter, the command uses the Path paramete
r alias. You can also use "-bpn".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-wmiobject win32_service -filter "name='testservice'"

ExitCode : 0
Name : testservice
ProcessId : 0
StartMode : Auto
State : Stopped
Status : OK

Description
-----------
This command uses the Get-WmiObject cmdlet to get the Win32_Service object
for the new service. This object includes the start mode and the service de
scription.




REMARKS
To see the examples, type: "get-help New-Service -examples".
For more information, type: "get-help New-Service -detailed".
For technical information, type: "get-help New-Service -full".

NAME
New-TimeSpan

SYNOPSIS
Creates a TimeSpan object.


SYNTAX
New-TimeSpan [[-Start] <DateTime>] [[-End] <DateTime>] [<CommonParameters>]

New-TimeSpan [-Days <int>] [-Hours <int>] [-Minutes <int>] [-Seconds <int>]
[<CommonParameters>]


DESCRIPTION
The New-TimeSpan cmdlet creates a TimeSpan object that represents a time. i
nterval You can use a TimeSpan object to add or subtract time from DateTime
objects.

Without parameters, a "New-Timespan" command returns a timespan object that
represents a time interval of zero.

PARAMETERS
-Days <int>
Indicates the days in the time span. The default is 0.

-End <DateTime>
Indicates the end of a time span. The default is the current date and t
ime.

-Hours <int>
Indicates the hours in the time span. The default is zero.

-Minutes <int>
Indicates the minutes in the time span. The default is 0.

-Seconds <int>
Indicates the length of the time span in seconds. The default is 0.

-Start <DateTime>
Indicates the start of a time span. Enter a string that represents the
date and time, such as "3/15/09" or a DateTime object, such as one from
a Get-Date command.

The default is the current date and time.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$timespan = new-timespan -hour 1 -minute 25

Description
-----------
This command creates a TimeSpan object with a duration of 1 hour and 25 min
utes and stores it in a variable named $timespan. It displays a representat
ion of the TimeSpan object.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>new-timespan -end (get-date -year 2010 -month 1 -day 1)

Description
-----------
This example creates a new TimeSpan object that represents the interval bet
ween the time that the command is run and January 1, 2010.

This command does not require the Start parameter, because the default valu
e of the Start parameter is the current date and time.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$90days = new-timespan -days 90

C:\PS> (get-date) + $90days

Description
-----------
These commands return the date that is 90 days after the current date.




REMARKS
To see the examples, type: "get-help New-TimeSpan -examples".
For more information, type: "get-help New-TimeSpan -detailed".
For technical information, type: "get-help New-TimeSpan -full".

NAME
New-Variable

SYNOPSIS
Creates a new variable.


SYNTAX
New-Variable [-Name] <string> [[-Value] <Object>] [-Description <string>] [
-Force] [-Option {None | ReadOnly | Constant | Private | AllScope}] [-PassT
hru] [-Scope <string>] [-Visibility {Public | Private}] [-Confirm] [-WhatIf
] [<CommonParameters>]


DESCRIPTION
The New-Variable cmdlet creates a new variable in Windows PowerShell. You c
an assign a value to the variable while creating it or assign or change the
value after it is created.

You can use the parameters of New-Variable to set the properties of the var
iable (such as those that create read-only or constant variables), set the
scope of a variable, and determine whether variables are public or private.

Typically, you create a new variable by typing the variable name and its va
lue, such as "$var = 3", but you can use the New-Variable cmdlet to use its
parameters.

PARAMETERS
-Description <string>
Specifies a description of the variable.

-Force [<SwitchParameter>]
Allows you to create a new variable with the same name as an existing r
ead-only variable.

By default, you can overwrite a variable unless the variable has an opt
ion value of ReadOnly or Constant. For more information, see the Option
parameter.

-Name <string>
Specifies a name for the new variable.

-Option <ScopedItemOptions>
Sets the value of the Options property of the new variable.

Valid values are:

-- None: Sets no options. ("None" is the default.)

-- ReadOnly: The value of the variable cannot be changed except by usin
g the Force parameter. You can use Remove-Variable to delete the variab
le.

-- Constant: The variable cannot be deleted, and its properties cannot
be changed. "Constant" is available only when you are creating an alias
. You cannot change the option of an existing variable to "Constant".

-- Private: The variable is available only within the scope specified b
y the Scope parameter. It is inherited by child scopes. (This value is
not related to the "Private" value of the Visibility parameter.)

-- AllScope: The variable is copied to any new scopes that are created.

To see the Options property of the variables, type "get-variable| forma
t-table -property name, options -autosize".

-PassThru [<SwitchParameter>]
Returns an object representing the new variable. By default, this cmdle
t does not generate any output.

-Scope <string>
Determines the scope of the new variable. Valid values are "Global", "L
ocal", or "Script", or a number relative to the current scope (0 throug
h the number of scopes, where 0 is the current scope and 1 is its paren
t). "Local" is the default. For more information, see about_Scopes.

-Value <Object>
Specifies the initial value of the variable.

-Visibility <SessionStateEntryVisibility>
Determines whether the variable is visible outside of the session in wh
ich it was created. This parameter is designed for use in scripts and
commands that will be delivered to other users.

Valid values are:

-- Public: The variable is visible. ("Public" is the default.)
-- Private: The variable is not visible.

When a variable is private, it does not appear in lists of variables, s
uch as those returned by Get-Variable, or in displays of the Variable:
drive. Commands to read or change the value of a private variable retur
n an error. However, the user can run commands that use a private varia
ble if the commands were written in the session in which the variable w
as defined.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-variable days

Description
-----------
This command creates a new variable named "days". It has no value immediate
ly following the command.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>new-variable zipcode -value 98033

Description
-----------
This command creates a variable named "zipcode" and assigns it the value "9
8033".




-------------------------- EXAMPLE 3 --------------------------

C:\PS>new-variable -name max -value 256 -option readonly

new-variable -name max -value 1024

new-variable -name max -value 1024 -force

C:\PS> new-variable -name max -value 256 -option readonly

C:\PS> new-variable -name max -value 1024
New-Variable : A variable with name 'max' already exists.
At line:1 char:13
+ new-variable <<<< -name max -value 1024

C:\PS> new-variable -name max -value 1024 -force

Description
-----------
This example shows how to use the ReadOnly option of New-Variable to protec
t a variable from being overwritten.

The first command creates a new variable named Max and sets its value to "2
56". It uses the Option parameter with a value of ReadOnly.

The second command tries to create a second variable with the same name. Th
is command returns an error, because the read-only option is set on the var
iable.

The third command uses the Force parameter to override the read-only protec
tion on the variable. In this case, the command to create a new variable wi
th the same name succeeds.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>new-variable -name counter -visibility private

#Effect of private variable in a module.

C:\PS> get-variable c*

Name Value
---- -----
Culture en-US
ConsoleFileName
ConfirmPreference High
CommandLineParameters {}

C:\PS> $counter
"Cannot access the variable '$counter' because it is a private variable"

C:\PS> Get-Counter
Name Value
---- -----
Counter1 3.1415
...

Description
-----------
This command demonstrates the behavior of a private variable in a module. T
he module contains the Get-Counter cmdlet, which has a private variable nam
ed "Counter". The command uses the Visibility parameter with a value of "Pr
ivate" to create the variable.

The sample output shows the behavior of a private variable. The user who ha
s loaded the module cannot view or change the value of the Counter variable
, but the Counter variable can be read and changed by the commands in the m
odule.




REMARKS
To see the examples, type: "get-help New-Variable -examples".
For more information, type: "get-help New-Variable -detailed".
For technical information, type: "get-help New-Variable -full".

NAME
New-WebServiceProxy

SYNOPSIS
Creates a Web service proxy object that lets you use and manage the Web ser
vice in Windows PowerShell.


SYNTAX
New-WebServiceProxy [-URI] <Uri> [[-Class] <string>] [[-Namespace] <string>
] [<CommonParameters>]

New-WebServiceProxy [-URI] <Uri> [[-Class] <string>] [[-Namespace] <string>
] [-Credential <PSCredential>] [<CommonParameters>]

New-WebServiceProxy [-URI] <Uri> [[-Class] <string>] [[-Namespace] <string>
] [-UseDefaultCredential] [<CommonParameters>]


DESCRIPTION
The New-WebServiceProxy cmdlet lets you use a Web service in Windows PowerS
hell. The cmdlet connects to a Web service and creates a Web service proxy
object in Windows PowerShell. You can use the proxy object to manage the We
b service.

A Web service is an XML-based program that exchanges data over a network, p
articularly over the Internet. The Microsoft .NET Framework provides Web se
rvice proxy objects that represent the Web service as a .NET Framework obje
ct.

PARAMETERS
-Class <string>
Specifies a name for the proxy class that the cmdlet creates for the We
b service. The value of this parameter is used with the Namespace param
eter to provide a fully qualified name for the class. The default value
is generated from the URI.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user. This is an alternative to using the UseD
efaultCredential parameter.

Type a user name, such as "User01" or "Domain01\User01". Or, enter a PS
Credential object, such as one generated by the Get-Credential cmdlet.
If you type a user name, you will be prompted for a password.

-Namespace <string>
Specifies a namespace for the new class.

The value of this parameter is used with the value of the Class paramet
er to generate a fully qualified name for the class. The default value
is Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes
plus a type that is generated from the URI.

You can set the value of the Namespace parameter so that you can access
multiple Web services with the same name.

-URI <Uri>
Specifies the URI of the Web service. Enter a URI or the path and file
name of a file that contains a service description.

The URI must refer to an .asmx page or to a page that returns a service
description. To return a service description of a Web service that was
created by using ASP.NET, append "?WSDL" to the URL of the Web service
(for example, http://www.contoso.com/MyWebService.asmx?WSDL).

-UseDefaultCredential [<SwitchParameter>]
Sets the UseDefaultCredential parameter in the resulting proxy object t
o True. This is an alternative to using the Credential parameter.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>$zip = New-WebServiceProxy -uri http://www.webservicex.net/uszip.asmx
?WSDL

Description
-----------
This command uses the New-WebServiceProxy command to create a .NET Framewor
k proxy of the US Zip Web service in Windows PowerShell.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>$URI = "http://www.webservicex.net/uszip.asmx?WSDL"

C:\PS> $zip = New-WebServiceProxy -uri $URI -namespace WebServiceProxy -cla
ss ZipClass

Description
-----------
This command uses the New-WebServiceProxy cmdlet to create a .NET Framework
proxy of the US Zip Web service.

The first command stores the URI of the Web service in the $URI variable.

The second command creates the Web service proxy. The command uses the URI
parameter to specify the URI and the Namespace and Class parameters to spec
ify the namespace and class of the object.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>$zip | get-member -type method

TypeName: WebServiceProxy.USZip

Name MemberType Definition
---- ---------- ----------
Abort Method System.Void Abort(
BeginGetInfoByAreaCode Method System.IAsyncResul
BeginGetInfoByCity Method System.IAsyncResul
BeginGetInfoByState Method System.IAsyncResul
BeginGetInfoByZIP Method System.IAsyncResul
CreateObjRef Method System.Runtime.Rem
Discover Method System.Void Discov
Dispose Method System.Void Dispos
EndGetInfoByAreaCode Method System.Xml.XmlNode
EndGetInfoByCity Method System.Xml.XmlNode
EndGetInfoByState Method System.Xml.XmlNode
EndGetInfoByZIP Method System.Xml.XmlNode
Equals Method System.Boolean Equ
GetHashCode Method System.Int32 GetHa
GetInfoByAreaCode Method System.Xml.XmlNode
GetInfoByCity Method System.Xml.XmlNode
GetInfoByState Method System.Xml.XmlNode
GetInfoByZIP Method System.Xml.XmlNode
GetLifetimeService Method System.Object GetL
GetType Method System.Type GetTyp
InitializeLifetimeService Method System.Object Init
ToString Method System.String ToSt

Description
-----------
This command uses the Get-Member cmdlet to display the methods of the Web s
ervice proxy object in the $zip variable. We will use these methods in the
following example.

Notice that the TypeName of the proxy object, WebServiceProxy, reflects the
namespace and class names that were specified in the previous example.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$zip.getinfobyzip(20500).table

CITY : Washington
STATE : DC
ZIP : 20500
AREA_CODE : 202
TIME_ZONE : E

Description
-----------
This command uses the Web service proxy stored in the Zip variable. The com
mand uses the GetInfoByZip method of the proxy and its Table property.




REMARKS
To see the examples, type: "get-help New-WebServiceProxy -examples".
For more information, type: "get-help New-WebServiceProxy -detailed".
For technical information, type: "get-help New-WebServiceProxy -full".

NAME
New-WSManInstance

SYNOPSIS
Creates a new instance of a management resource.


SYNTAX
New-WSManInstance [-ApplicationName <string>] [-ComputerName <string>] [-Cr
edential <PSCredential>] [-Port <int>] [-UseSSL] [-SelectorSet] <hashtable>
-ResourceURI <Uri> [-AuthenticationMechanism <AuthenticationMechanism>] [-
SessionOption <hashtable>] [-ValueSet <hashtable>] [<CommonParameters>]

New-WSManInstance [-ConnectionURI <Uri>] [-SelectorSet] <hashtable> -Resour
ceURI <Uri> [-AuthenticationMechanism <AuthenticationMechanism>] [-SessionO
ption <hashtable>] [-ValueSet <hashtable>] [<CommonParameters>]


DESCRIPTION
The New-WSManInstance cmdlet creates a new instance of a management resourc
e. It uses a resource URI and a value set or input file to create the new i
nstance of the management resource.

This cmdlet uses the WinRM connection/transport layer to create the managem
ent resource instance.

PARAMETERS
-ApplicationName <string>
Specifies the application name in the connection. The default value of
the ApplicationName parameter is "WSMAN". The complete identifier for t
he remote endpoint is in the following format:

<transport>://<server>:<port>/<ApplicationName>

For example:

http://server01:8080/WSMAN

Internet Information Services (IIS), which hosts the session, forwards
requests with this endpoint to the specified application. This default
setting of "WSMAN" is appropriate for most uses. This parameter is desi
gned to be used when numerous computers establish remote connections to
one computer that is running Windows PowerShell. In this case, IIS hos
ts Web Services for Management (WS-Management) for efficiency.

-AuthenticationMechanism <AuthenticationMechanism>
Specifies the authentication mechanism to be used at the server. Possib
le values are:

- Basic: Basic is a scheme in which the user name and password are sent
in clear text to the server or proxy.
- Default : Use the authentication method implemented by the WS-Managem
ent protocol. This is the default.
- Digest: Digest is a challenge-response scheme that uses a server-spec
ified data string for the challenge.
- Kerberos: The client computer and the server mutually authenticate by
using Kerberos certificates.
- Negotiate: Negotiate is a challenge-response scheme that negotiates w
ith the server or proxy to determine the scheme to use for authenticati
on. For example, this parameter value allows negotiation to determine w
hether the Kerberos protocol or NTLM is used.
- CredSSP: Use Credential Security Service Provider (CredSSP) authentic
ation, which allows the user to delegate credentials. This option is de
signed for commands that run on one remote computer but collect data fr
om or run additional commands on other remote computers.

Caution: CredSSP delegates the user's credentials from the local comput
er to a remote computer. This practice increases the security risk of t
he remote operation. If the remote computer is compromised, when creden
tials are passed to it, the credentials can be used to control the netw
ork session.

-ComputerName <string>
Specifies the computer against which you want to run the management ope
ration. The value can be a fully qualified domain name, a NetBIOS name,
or an IP address. Use the local computer name, use localhost, or use a
dot (.) to specify the local computer. The local computer is the defau
lt. When the remote computer is in a different domain from the user, yo
u must use a fully qualified domain name must be used. You can pipe a v
alue for this parameter to the cmdlet.

-ConnectionURI <Uri>
Specifies the connection endpoint. The format of this string is:

<Transport>://<Server>:<Port>/<ApplicationName>

The following string is a properly formatted value for this parameter:

http://Server01:8080/WSMAN

The URI must be fully qualified.

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user. Type a user name, such as "User01", "Dom
ain01\User01", or "User@Domain.com". Or, enter a PSCredential object, s
uch as one returned by the Get-Credential cmdlet. When you type a user
name, you will be prompted for a password.

-File <File>
Specifies the path of a file that is used to create a management resour
ce. You specify the management resource by using the ResourceURI parame
ter and the SelectorSet parameter . For example, the following command
uses the File parameter:

invoke-wsmanaction -action stopservice -resourceuri wmicimv2/Win32_Serv
ice -SelectorSet @{Name="spooler"} -File c:\input.xml -authentication d
efault

This command calls the StopService method [descriptor] on the Spooler
service by using input from a file. The file, Input.xml, contains the f
ollowing content:

<p:StopService_INPUT xmlns:p="http://schemas.microsoft.com/wbem/wsman/1
/wmi/root/cimv2/Win32_Service"/>

-OptionSet <hashtable>
Passes a set of switches to a service to modify or refine the nature of
the request. These are similar to switches used in command-line shells
because they are service specific. Any number of options can be spec
ified.

The following example demonstrates the syntax that passes the values 1,
2, and 3 for the a, b, and c parameters:

-OptionSet @{a=1;b=2;c=3}

-Port <int>
Specifies the port to use when the client connects to the WinRM service
. When the transport is HTTP, the default port is 80. When the transpor
t is HTTPS, the default port is 443. When you use HTTPS as the transpor
t, the value of the ComputerName parameter must match the server's cert
ificate common name (CN). However, if the SkipCNCheck parameter is spec
ified as part of the SessionOption parameter, then the certificate comm
on name of the server does not have to match the host name of the serve
r. The SkipCNCheck parameter should be used only for trusted computers.

-ResourceURI <Uri>
Contains the Uniform Resource Identifier (URI) of the resource class or
instance. The URI is used to identify a specific type of resource, suc
h as disks or processes, on a computer.

A URI consists of a prefix and a path to a resource. For example:

http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Log
icalDisk
http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_NumericSenso
r

-SelectorSet <hashtable>
Specifies a set of value pairs that are used to select particular manag
ement resource instances. The SelectorSet parameter is used when more t
han one instance of the resource exists. The value of the SelectorSet p
arameter must be a hash table.

The following example shows how to enter a value for this parameter:

-SelectorSet @{Name="WinRM";ID="yyy"}

-SessionOption <hashtable>
Defines a set of extended options for the WS-Management session. Enter
a SessionOption object that you create by using the New-WSManSessionOpt
ion cmdlet. For more information about the options that are available,
see New-WSManSessionOption.

-UseSSL [<SwitchParameter>]
Specifies that the Secure Sockets Layer (SSL) protocol should be used t
o establish a connection to the remote computer. By default, SSL is not
used.

WS-Management encrypts all the Windows PowerShell content that is trans
mitted over the network. The UseSSL parameter lets you specify the addi
tional protection of HTTPS instead of HTTP. If SSL is not available on
the port that is used for the connection and you specify this parameter
, the command fails.

-ValueSet <hashtable>
Specifies a hash table that helps modify a management resource. You spe
cify the management resource by using the ResourceURI parameter and the
SelectorSet parameter. The value of the ValueSet parameter must be a h
ash table.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>New-WSManInstance winrm/config/Listener -SelectorSet @{Transport=HTTP
S} -ValueSet @{Hostname="HOST";CertificateThumbprint="XXXXXXXXXX"}

Description
-----------
This command creates an instance of a WS-Management HTTPS listener on all I
P addresses.




REMARKS
To see the examples, type: "get-help New-WSManInstance -examples".
For more information, type: "get-help New-WSManInstance -detailed".
For technical information, type: "get-help New-WSManInstance -full".

NAME
New-WSManSessionOption

SYNOPSIS
Creates a WS-Management session option hash table to use as input parameter
s to the following WS-Management cmdlets:
Get-WSManInstance
Set-WSManInstance
Invoke-WSManAction
Connect-WSMan


SYNTAX
New-WSManSessionOption [-NoCompression <switch>] [-NoProxy <switch>] [-Prox
yAuthentication <string>] [-ProxyPassword <string>] [-ProxyUserName <string
>] [-SkipCACheck <switch>] [-SkipCNCheck <switch>] [-SkipRevocation <switch
>] [-SPNPort <int>] [-Timeout <int>] [-UnEncrypted <switch>] [-UseIEProxyco
nfig <switch>] [-UseProxyAutoDetection <switch>] [-UseWinHTTPProxyConfig <s
witch>] [-UTF16 <switch>] [<CommonParameters>]


DESCRIPTION
Creates a WSMan Session option hashtable which can be passed into WSMan cmd
lets:
Get-WSManInstance
Set-WSManInstance
Invoke-WSManAction
Connect-WSMan

PARAMETERS
-NoCompression <switch>
Turns off packet compression in the session. Compression is enabled by
default and the packets sent between the client and server are compress
ed. Compression uses more processor cycles, but it makes transmission f
aster.

-NoProxy <switch>
Do not use a proxy server. All all host names will be resolved locally.

-ProxyAuthentication <string>
Specifies the authentication method to use at the proxy. Possible value
s are:

- Basic: Basic is a scheme in which the user name and password are sent
in clear-text to the server or proxy.
- Digest: Digest is a challenge-response scheme that uses a server-spec
ified data string for the challenge.
- Negotiate (the default): Negotiate is a challenge-response scheme tha
t negotiates with the server or proxy to determine which scheme to use
for authentication. Examples are the Kerberos protocol and NTLM.

-ProxyPassword <string>
Specifies a password to to be used for proxy authentication.

-ProxyUserName <string>
Specifies a user name to to be used for proxy authentication.

-SkipCACheck <switch>
Specifies that when connecting over HTTPS, the client does not validate
that the server certificate is signed by a trusted certificate authori
ty (CA). Use this option only when the remote computer is trusted by ot
her means, for example, if the remote computer is part of a network tha
t is physically secure and isolated or the remote computer is listed as
a trusted host in the WS-Management configuration.

-SkipCNCheck <switch>
Specifies that the certificate common name (CN) of the server does not
need to match the hostname of the server. This is used only in remote o
perations using HTTPS. This option should only be used for trusted comp
uters.

-SkipRevocation <switch>
Do not validate the revocation status on the server certificate.

-SPNPort <int>
Specifies a port number to append to the connection Service Principal N
ame <SPN> of the remote server. An SPN is used when the authentication
mechanism is Kerberos or Negotiate.

-Timeout <int>
Defines the timeout in milliseconds for the WS-Management operation.

-UnEncrypted <switch>
Do not use encryption when doing remote operations over HTTP.

Note: Unencrypted traffic is not allowed by default and must be enabled
in the local configuration.

-UseIEProxyconfig <switch>
Use the Internet Explorer proxy configuration for the current user. Th
is is the default setting.

-UseProxyAutoDetection <switch>
Force auto-detection of a proxy.

-UseWinHTTPProxyConfig <switch>
Use the proxy settings configured for WinHTTP.

-UTF16 <switch>
Encode the request in UTF16 format rather than UTF8 format. The default
is UTF8 encoding.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

REMARKS
To see the examples, type: "get-help New-WSManSessionOption -examples".
For more information, type: "get-help New-WSManSessionOption -detailed".
For technical information, type: "get-help New-WSManSessionOption -full".

NAME
New-Item

SYNOPSIS
Creates a new item.


SYNTAX
New-Item [-Path] <string[]> [-Credential <PSCredential>] [-Force] [-ItemTyp
e <string>] [-Value <Object>] [-Confirm] [-WhatIf] [-UseTransaction] [<Comm
onParameters>]

New-Item -Name <string> [[-Path] <string[]>] [-Credential <PSCredential>] [
-Force] [-ItemType <string>] [-Value <Object>] [-Confirm] [-WhatIf] [-UseTr
ansaction] [<CommonParameters>]


DESCRIPTION
The New-Item cmdlet creates a new item and sets its value. The types of ite
ms that can be created depend upon the location of the item. For example, i
n the file system, New-Item is used to create files and folders. In the reg
istry, New-Item creates registry keys and entries.

New-Item can also set the value of the items that it creates. For example,
when creating a new file, New-Item can add initial content to the file.

PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Th
e default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSC
redential object, such as one generated by the Get-Credential cmdlet. I
f you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows
PowerShell

-Force [<SwitchParameter>]
Allows the cmdlet to create an item that writes over an existing read-o
nly item. Implementation varies from provider to provider. For more inf
ormation, see about_Providers. Even using the Force parameter, the cmdl
et cannot override security restrictions.

-ItemType <string>
Specifies the provider-specified type of the new item.

-Name <string>
Specifies the name of the new item. You can use this parameter to speci
fy the name of the new item, or include the name in the value of the Pa
th parameter.

-Path <string[]>
Specifies the path to the location of the new item. Wildcards are permi
tted.

You can specify the name of the new item in the Name parameter, or incl
ude it in the Path parameter.

-Value <Object>
Specifies the value of the new item. You can also pipe a value to New-I
tem.

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actuall
y executing the command.

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid
only when a transaction is in progress. For more information, see abou
t_Transactions.

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-item -path . -name testfile1.txt -type "file" -value "This is a t
ext string."

Description
-----------
This command creates a text file named testfile1.txt in the current directo
ry. The dot (.) in the value of the Path parameter indicates the current di
rectory. The quoted text that follows the Value parameter is added to the f
ile as content.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>new-item -path c:\ -name logfiles -type directory

Description
-----------
This command creates a directory named Logfiles in the C: drive. The Type p
arameter specifies that the new item is a directory, not a file or other fi
le system object.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>new-item -path $profile -type file -force

Description
-----------
This command creates a Windows PowerShell profile in the path that is speci
fied by the $profile variable.

You can use profiles to customize Windows PowerShell. $Profile is an automa
tic (built-in) variable that stores the path and file name of the CurrentUs
er/CurrentHost profile. By default, the profile does not exist, even though
Windows PowerShell stores a path and file name for it.

In this command, the $profile variable represents the path to the file. The
Type parameter (or InfoType) specifies that the command creates a file. Th
e Force parameter lets you create a file in the profile path, even when the
directories in the path do not exist (Windows PowerShell creates them).

After you use this command to create a profile, you can enter aliases, func
tions, and scripts in the profile to customize your shell.

For more information, see about_Automatic_Variables and about_Profiles.




-------------------------- EXAMPLE 4 --------------------------

C:\PS>new-item -type directory -path c:\ps-test\scripts

Description
-----------
This command creates a new Scripts directory in the C:\PS-Test directory.

The name of the new directory item, Scripts, is included in the value of th
e Path parameter, instead of being specified in the value of the Name param
eter. As indicated by the syntax, either command form is valid.




REMARKS
To see the examples, type: "get-help New-Item -examples".
For more information, type: "get-help New-Item -detailed".
For technical information, type: "get-help New-Item -full".

NAME
New-Module

SYNOPSIS
Creates a new dynamic module that exists only in memory.


SYNTAX
New-Module [-Name] <string> [-ScriptBlock] <scriptblock> [-ArgumentList <Ob
ject[]>] [-AsCustomObject] [-Cmdlet <string[]>] [-Function <string[]>] [-Re
turnResult] [<CommonP