Creates an instance of a Microsoft .NET Framework or COM object. (New-Object)



Creates an instance of a Microsoft .NET Framework or COM object.

New-Object -ComObject <string> [-Strict] [-Property <hashtable>] [<CommonParameters>]

New-Object [-TypeName] <string> [[-ArgumentList] <Object[]>] [-Property <hashtable>] [<CommonParameters>]

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 Framework class and the cmdlet returns a reference to an instance of that class. To create an instance of a COM object, use the ComObject parameter and specify the ProgID of the object as its value.

-ArgumentList <Object[]>
Specifies a list of arguments to pass to the constructor of the .NET Framework class. Separate elements in the list by using commas (,). The alias for ArgumentList is Args.

Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false

-ComObject <string>
Specifies the programmatic identifier (ProgID) of the COM object.

Required? true
Position? named
Default value None
Accept pipeline input? false
Accept wildcard characters? false

-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 methods and the values are property values or method arguments. New-Object creates the object and sets each property value and invokes each method 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 specified property to the object as a NoteProperty. If the object is not a PSObject, the command generates a non-terminating error.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Strict [<SwitchParameter>]
Specifies that an error should be raised if the COM object that you attempt to create uses an interop assembly. This enables you to distinguish actual COM objects from .NET Framework objects with COM-callable wrappers.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-TypeName <string>
Specifies the fully qualified name of the .NET Framework class. You cannot specify both the TypeName parameter and the ComObject parameter.

Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false

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

You cannot pipe input to this cmdlet.

New-Object returns the object that is created.


New-Object provides the most commonly-used functionality of the VBScript CreateObject function. A statement like Set objShell = CreateObject("Shell.Application") in VBScript can be translated to $objShell = new-object -comobject "Shell.Application" in Windows PowerShell.

New-Object expands upon the functionality available in the Windows Script Host environment by making it easy to work with .NET Framework objects from the command line and within scripts.


C:\PS>new-object -typename System.Version -argumentlist ""

Major Minor Build Revision
----- ----- ----- --------
1 2 3 4

# Description
This command creates a System.Version object using the string "" as the constructor.


C:\PS>$ie = new-object -comobject InternetExplorer.Application -property @{navigate2=""; visible = $true}

# Description
This command creates an instance of the COM object that represents the Internet Explorer application. It uses the Property parameter to call the Navigate2 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.visible = $true


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 New-Object cmdlet to generate a non-terminating error when the COM object that is created uses an interop assembly.


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 "Shell.Application" ProgID. It stores the resulting object in the $objShell variable.

The second command pipes the $objShell variable to the Get-Member cmdlet, which 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.

Online version:

C:\Windows>powershell get-help Select-Object -full

ColorConsole [Version 1.7.1000] PowerShell 2.0-Export
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2014 Microsoft Corporation.

OS: Windows 10, 8.1, 8, 7, Vista / Windows Server 2016, 2012, 2008
»»»» ColorConsole

... Home  
... Impressum
... ColorConsole

... CMD
... Netsh-XP
... Netsh-7
... Netsh-Vista
... Powershell
... FAQ
HTTP: ... PS_Windows/en/New-Object.htm


Q-Dir and Windows x64. How does it work?


Bei der Mausrad das Aktivieren des Fensters in den Vordergrund bringen ersparen?


Windows-8 Download?


To make Q-Dir truly portable!


How to enable the guest account for guest access under Windows 8.1?


How to enable Screen-Saver Password on Windows 7?


Desktop icons Hide and Show, Without the timer!


How can I uninstall the ExperienceIndexOK?