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
2 changes: 1 addition & 1 deletion dsc/configurations/reboot-a-node.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
ms.date: 1/17/2019
ms.date: 01/17/2019
keywords: dsc,powershell,configuration,setup
title: Reboot a Node
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
ms.date: 3/18/2019
ms.date: 03/18/2019
title: Creating Get-WinEvent queries with FilterHashtable
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ powershell.exe -Command {
## View the process

The body of the command which PowerShell is executing is stored in the **CommandLine** property
of the [Win32_Process][] class. If the command is an [encoded command][], the **CommandLine**
of the [Win32_Process][] class. If the command is an encoded command, the **CommandLine**
property contains the string "EncodedCommand". Using this information, the encoded command can
be de-obfuscated via the following process.

Expand Down Expand Up @@ -114,4 +114,3 @@ DecodedCommand :
[Task Scheduler]: /windows/desktop/TaskSchd/task-scheduler-start-page
[SQL Server Agent]: /sql/ssms/agent/sql-server-agent
[Win32_Process]: /windows/desktop/CIMWin32Prov/win32-process
[encoded command]: /powershell/scripting/core-powershell/console/powershell.exe-command-line-help#-encodedcommand-
11 changes: 0 additions & 11 deletions reference/docs-conceptual/samples/Working-with-Objects.md

This file was deleted.

36 changes: 18 additions & 18 deletions wmf/whats-new/class-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ PowerShell artifacts (such as DSC resources), and accelerate coverage of managem
- Debug types by using the PowerShell language
- Generate and handle exceptions by using formal mechanisms, and at the right level

# Declare Base Class
## Declare Base Class

You can declare a PowerShell class as a base type for another PowerShell class.

Expand Down Expand Up @@ -53,7 +53,7 @@ $list.Add(100)
$list[0] # return 100
```

# Call Base Class Constructor
### Call Base Class Constructor

To call a base class constructor from a subclass, use the keyword **base**:

Expand Down Expand Up @@ -85,7 +85,7 @@ class C : B
}
```

# Call Base Class Method
### Call Base Class Method

You can override existing methods in subclasses. To do this, declare methods by using the same name
and signature:
Expand Down Expand Up @@ -137,7 +137,7 @@ $list.Add(100)
$list[0] # return 200
```

# Declare Implemented Interface
### Declare Implemented Interface

You can declare implemented interfaces after base types, or immediately after a colon (:), if there
is no base type specified. Separate all type names by using commas. It's similar to C# syntax.
Expand All @@ -160,11 +160,11 @@ class MyComparableBar : bar, system.IComparable
}
```

# New language features in PowerShell 5.0
## New language features in PowerShell 5.0

PowerShell 5.0 introduces the following new language elements in PowerShell:

## Class keyword
### Class keyword

The `class` keyword defines a new class. This is a true .NET Framework type. Class members are
public, but only public within the module scope. You can't refer to the type name as a string (for
Expand All @@ -178,7 +178,7 @@ class MyClass
}
```

## Enum keyword and enumerations
### Enum keyword and enumerations

Support for the `enum` keyword has been added, which uses newline as the delimiter. Currently, you
cannot define an enumerator in terms of itself. However, you can initialize an enum in terms of
Expand Down Expand Up @@ -212,12 +212,12 @@ enum SomeEnum { Max = 42 }
enum OtherEnum { Max = [SomeEnum]::Max + 1 }
```

## Import-DscResource
### Import-DscResource

`Import-DscResource` is now a true dynamic keyword. PowerShell parses the specified module's root
module, searching for classes that contain the **DscResource** attribute.

## ImplementingAssembly
### ImplementingAssembly

A new field, **ImplementingAssembly**, has been added to **ModuleInfo**. It is set to the dynamic
assembly created for a script module if the script defines classes, or the loaded assembly for
Expand Down Expand Up @@ -247,7 +247,7 @@ $s = "hello"

All members are public.

## Constructors and instantiation
### Constructors and instantiation

PowerShell classes can have constructors. They have the same name as their class. Constructors can
be overloaded. Static constructors are supported. Properties with initialization expressions are
Expand All @@ -256,7 +256,7 @@ body of a static constructor, and instance properties are initialized before the
non-static constructor. Currently, there is no syntax for calling a constructor from another
constructor (like the C\# syntax ": this()"). The workaround is to define a common `Init()` method.

### Creating instances
#### Creating instances

> [!NOTE]
> In PowerShell 5.0, `New-Object` does not work with classes defined in PowerShell. Also, the type
Expand Down Expand Up @@ -288,7 +288,7 @@ The pseudo-static method `new()` works with .NET types, as shown in the followin
[hashtable]::new()
```

### Discovering constructors
#### Discovering constructors

You can now see constructor overloads with `Get-Member`, or as shown in this example:

Expand All @@ -304,7 +304,7 @@ hashtable new(int capacity, float loadFactor)
`Get-Member -Static` lists constructors, so you can view overloads like any other method. The
performance of this syntax is also considerably faster than `New-Object`.

## Methods
### Methods

A PowerShell class method is implemented as a **ScriptBlock** that has only an end block. All
methods are public. The following shows an example of defining a method named **DoSomething**.
Expand All @@ -329,15 +329,15 @@ $b.DoSomething(42)

Overloaded methods are also supported.

## Properties
### Properties

All properties are public. Properties require either a newline or semicolon. If no object type is
specified, the property type is object.

Properties that use validation or argument transformation attributes (like `[ValidateSet("aaa")]`)
work as expected.

## Hidden
### Hidden

A new keyword, `Hidden`, has been added. `Hidden` can be applied to properties and methods
(including constructors).
Expand All @@ -349,17 +349,17 @@ the completion occurs in the class defining the hidden member.
A new attribute, **System.Management.Automation.HiddenAttribute** has been added so that C\# code
can have the same semantics within PowerShell.

## Return types
### Return types

Return type is a contract. The return value is converted to the expected type. If no return type is
specified, the return type is **void**. There is no streaming of objects. Objects cannot be written
to the pipeline either intentionally or by accident.

## Attributes
### Attributes

Two new attributes, **DscResource** and **DscProperty** have been added.

## Lexical scoping of variables
### Lexical scoping of variables

The following shows an example of how lexical scoping works in this release.

Expand Down