The Hidden modifier may be used to hide a property or a method from casual discovery. Members marked as Hidden are still visible when using Get-Member, and may still be invoked. In many respects, this is similar to the DontShow property of the Parameter attribute: it hides the member from IntelliSense and tab completion, but does not prevent use.
In the following example, the Initialize method is hidden:
class MyClass {
[String]$Property
MyClass() { $this.Initialize() }
Hidden [Void] Initialize() {
$this.Property = 'defaultValue'
}
}
By default, the Initialize method will be hidden from view. Using Get-Member with the Force parameter will show the method:
PS> [MyClass]::new() | Get-Member Initialize -Force
TypeName: MyClass
Name MemberType Definition
---- ---------- ----------
Initialize Method void Initialize()
It is not possible to make members private in PowerShell at this time.