Skip to main content
Version: v4

New-MockObject

SYNOPSIS​

This function instantiates a .NET object from a type.

SYNTAX​

New-MockObject [-Type] <Type> [<CommonParameters>]

DESCRIPTION​

Using the New-MockObject you can mock an object based on .NET type.

An .NET assembly for the particular type must be available in the system and loaded.

EXAMPLES​

EXAMPLE 1​

$obj = New-MockObject -Type 'System.Diagnostics.Process'
$obj.GetType().FullName
System.Diagnostics.Process

PARAMETERS​

-Type​

The .NET type to create an object based on.

Type: Type
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters​

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS​

OUTPUTS​

NOTES​

EDIT THIS PAGE​

This page was auto-generated using Pester's comment based help. To edit the content of this page, change the corresponding help in the pester/Pester v4 repository. See our contribution guide for more information.