Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ PowerShell has the following type operators:
- `-is` |Returns TRUE when the input is an instance of the specified .NET type.

```powershell
(get-date) -is [DateTime] # Result is True
(Get-Date) -is [datetime] # Result is True
```

- `-isnot`|Returns TRUE when the input not an instance of the specified.NET type.

```powershell
(get-date) -isnot [DateTime] # Result is False
(Get-Date) -isnot [datetime] # Result is False
```

- `-as` |Converts the input to the specified .NET type.

```powershell
"5/7/07" -as [DateTime] # Result is Monday, May 7, 2007 12:00:00 AM
"5/7/07" -as [datetime] # Result is Monday, May 7, 2007 12:00:00 AM
```

The syntax of the type operators is as follows:
Expand All @@ -57,7 +57,7 @@ You can also use the following syntax:
```

The .NET type can be written as a type name in brackets or a string, such as
`[DateTime]` or `"DateTime"` for **System.DateTime**. If the type is not at the
`[datetime]` or `"DateTime"` for **System.DateTime**. If the type is not at the
root of the system namespace, specify the full name of the object type. You can
omit "System.". For example, to specify **System.Diagnostics.Process**, enter
`[System.Diagnostics.Process]`, `[Diagnostics.Process]`, or
Expand Down Expand Up @@ -113,7 +113,7 @@ System.IO.DirectoryInfo

#### Converting the DateTime type is culture-sensitive

Unlike type casting, converting to `[DateTime]` type using the `-as` operator
Unlike type casting, converting to `[datetime]` type using the `-as` operator
only works with strings that are formatted according to the rules of the
current culture.

Expand Down Expand Up @@ -148,25 +148,25 @@ System.Globalization.CultureInfo
The following examples show some uses of the Type operators:

```powershell
PS> 32 -is [Float]
PS> 32 -is [float]
False

PS> 32 -is "int"
True

PS> (get-date) -is [DateTime]
PS> (Get-Date) -is [datetime]
True

PS> "12/31/2007" -is [DateTime]
PS> "12/31/2007" -is [datetime]
False

PS> "12/31/2007" -is [String]
PS> "12/31/2007" -is [string]
True

PS> (get-process PowerShell)[0] -is [System.Diagnostics.Process]
PS> (Get-Process powershell)[0] -is [System.Diagnostics.Process]
True

PS> (get-command get-member) -is [System.Management.Automation.CmdletInfo]
PS> (Get-Command Get-Member) -is [System.Management.Automation.CmdletInfo]
True
```

Expand All @@ -179,40 +179,40 @@ return **System.Globalization.CultureInfo** objects, a collection of these
objects is a System.Object array.

```powershell
PS> (get-culture) -is [System.Globalization.CultureInfo]
PS> (Get-Culture) -is [System.Globalization.CultureInfo]
True

PS> (get-uiculture) -is [System.Globalization.CultureInfo]
PS> (Get-UICulture) -is [System.Globalization.CultureInfo]
True

PS> (get-culture), (get-uiculture) -is [System.Globalization.CultureInfo]
PS> (Get-Culture), (Get-UICulture) -is [System.Globalization.CultureInfo]
False

PS> (get-culture), (get-uiculture) -is [Array]
PS> (Get-Culture), (Get-UICulture) -is [array]
True

PS> (get-culture), (get-uiculture) | foreach {
PS> (Get-Culture), (Get-UICulture) | foreach {
$_ -is [System.Globalization.CultureInfo])
}
True
True

PS> (get-culture), (get-uiculture) -is [Object]
PS> (Get-Culture), (Get-UICulture) -is [Object]
True
```

The following examples show how to use the `-as` operator.

```powershell
PS> "12/31/07" -is [DateTime]
PS> "12/31/07" -is [datetime]
False

PS> "12/31/07" -as [DateTime]
PS> "12/31/07" -as [datetime]
Monday, December 31, 2007 12:00:00 AM

PS> $date = "12/31/07" -as [DateTime]
PS> $date = "12/31/07" -as [datetime]

C:\PS>$a -is [DateTime]
C:\PS>$a -is [datetime]
True

PS> 1031 -as [System.Globalization.CultureInfo]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ information about `Update-TypeData`, see [Update-TypeData][01].
Update-TypeData -PrependPath $PSHOME\MyTypes.ps1xml
```

To test the change, run a `Get-ChildItem` command to get the PowerShell.exe
To test the change, run a `Get-ChildItem` command to get the `powershell.exe`
file in the `$PSHOME` directory, and then pipe the file to the `Format-List`
cmdlet to list all of the properties of the file. As a result of the change,
the **Age** property appears in the list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ Update-Help -Module DhcpServer -SourcePath E:\UsbDrive\SavedHelp
Without parameters, `Save-Help` downloads help for all modules in the session
and for all installed modules that support Updatable Help. To be included,
modules must be installed in directories that are listed in the value of the
`$env:PSModulePath` environment variable, on either the local computer or on a
`$Env:PSModulePath` environment variable, on either the local computer or on a
remote computer for which you want to save help. These are also modules that
are returned by running a `Get-Help -ListAvailable` command.

Expand All @@ -330,10 +330,10 @@ However, you can use the **UICulture** parameters of the `Update-Help` and
which they're available.

For example, to save the newest help files for all modules on the session in
Japanese (ja-Jp) and French (fr-FR), type:
Japanese (ja-JP) and French (fr-FR), type:

```powershell
Save-Help -Path \Server\Share -UICulture ja-jp, fr-fr
Save-Help -Path \Server\Share -UICulture ja-JP, fr-FR
```

If help files for the modules aren't available in the languages that you
Expand Down Expand Up @@ -411,7 +411,7 @@ only a module name. They don't accept the path to a module file.

Use this technique to update or save help for any module that's not returned by
the **ListAvailable** parameter of the `Get-Module` cmdlet, such as a module
that's installed in a location that's not listed in the `$env:PSModulePath`
that's installed in a location that's not listed in the `$Env:PSModulePath`
environment variable, or a module that's not well-formed (the module directory
doesn't contain at least one file whose basename is the same as the directory
name).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module. No uncommented statement can precede it, including parameters.

The `using` statement must not contain any variables.

The `using` statement isn't the same as the `using:` scope modifier for
The `using` statement isn't the same as the `Using:` scope modifier for
variables. For more information, see
[about_Remote_Variables](about_Remote_Variables.md).

Expand Down Expand Up @@ -91,7 +91,7 @@ A module specification is a hashtable that has the following keys.
- `RequiredVersion` - Specifies an exact, required version of the module.
This can't be used with the other Version keys.

`Import-Module` and the `#requires` statement only import the module functions,
`Import-Module` and the `#Requires` statement only import the module functions,
aliases, and variables, as defined by the module. Classes and enumerations
aren't imported.

Expand Down Expand Up @@ -120,7 +120,7 @@ following classes:
- **Deck**
- **Card**

`Import-Module` and the `#requires` statement only import the module functions,
`Import-Module` and the `#Requires` statement only import the module functions,
aliases, and variables, as defined by the module. Classes aren't imported. The
`using module` command imports the module and also loads the class definitions.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@ the dollar sign (`$`). This has the same effect as prefixing the variables name
with the dollar sign (`$`).

```powershell
$variable:HOME
$Variable:HOME
```

### Get variables using wildcards

This command gets the variables with names that begin with "max". You can use
This command gets the variables with names that begin with "Max". You can use
this command from any PowerShell drive.

```powershell
Get-ChildItem -Path Variable:max*
Get-ChildItem -Path Variable:Max*
```

### Get the value of the ? variable
Expand All @@ -159,10 +159,12 @@ This command gets the variables that have the values of `ReadOnly` or
`Constant` for their **Options** property.

```powershell
Get-ChildItem -Path Variable: | Where-Object {
$_.options -match "Constant" `
-or $_.options -match "ReadOnly"
} | Format-List -Property name, value, options
Get-ChildItem -Path Variable: |
Where-Object {
$_.Options -match 'Constant' -or
$_.Options -match 'ReadOnly'
} |
Format-List -Property Name, Value, Options
```

## Creating variables
Expand Down Expand Up @@ -273,7 +275,7 @@ Get-Help Get-ChildItem
```

```powershell
Get-Help Get-ChildItem -Path variable:
Get-Help Get-ChildItem -Path Variable:
```

## See also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ The next example assigns multiple values to multiple variables.

```powershell
$i,$j,$k = 10, "red", $true # $i is 10, $j is "red", $k is True
$i,$j = 10, "red", $true # $i is 10, $j is [object[]], Length 2
$i,$j = 10, "red", $true # $i is 10, $j is [Object[]], Length 2
```

For more detailed information, see the **Assigning multiple variables** section
Expand Down Expand Up @@ -367,7 +367,7 @@ The following command gets the child items in the directory that is represented
by the `ProgramFiles(x86)` environment variable.

```powershell
Get-ChildItem ${env:ProgramFiles(x86)}
Get-ChildItem ${Env:ProgramFiles(x86)}
```

To reference a variable name that includes braces, enclose the variable name in
Expand Down Expand Up @@ -400,7 +400,7 @@ global scope, even when it's created in a script or function.
$Global:Computers = "Server01"
```

For any script or command that executes out of session, you need the `Using`
For any script or command that executes out of session, you need the `Using:`
scope modifier to embed variable values from the calling session scope, so that
out of session code can access them.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ the results of a conditional test.
The `while` statement (also known as a `while` loop) is a language construct
for creating a loop that runs commands in a command block as long as a
conditional test evaluates to true. The `while` statement is easier to
construct than a For statement because its syntax is less complicated. In
addition, it is more flexible than the Foreach statement because you specify a
conditional test in the `while` statement to control how many times the loop
construct than a `for` statement because its syntax is less complicated. In
addition, it is more flexible than the `foreach` statement because you specify
a conditional test in the `while` statement to control how many times the loop
runs.

The following shows the While statement syntax:
The following shows the `while` statement syntax:

```powershell
while (<condition>){<statement list>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ includes **Interactive**.
Get-Service | Where-Object {$_.ServiceType -like "*Interactive*"}
```

In the following example, the `If` statement includes a condition that uses
In the following example, the `if` statement includes a condition that uses
wildcard characters to find property values. If the restore point's
**Description** includes **PowerShell**, the command adds the value of the
restore point's **CreationTime** property to a log file.

```powershell
$p = Get-ComputerRestorePoint
foreach ($point in $p) {
if ($point.description -like "*PowerShell*") {
if ($point.Description -like "*PowerShell*") {
Add-Content -Path C:\TechDocs\RestoreLog.txt "$($point.CreationTime)"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ Specifies the instance IDs of the disconnected sessions.

The instance ID is a GUID that uniquely identifies a **PSSession** on a local or remote computer.

The instance ID is stored in the **InstanceID** property of the **PSSession**.
The instance ID is stored in the **InstanceId** property of the **PSSession**.

```yaml
Type: System.Guid[]
Expand Down
2 changes: 1 addition & 1 deletion reference/5.1/Microsoft.PowerShell.Core/Debug-Job.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ command detaches the debugger, and allows the job to continue to run.
This command breaks into a running job with an ID of 3.

```powershell
Debug-Job -ID 3
Debug-Job -Id 3
```

```Output
Expand Down
Loading