You are currently viewing PowerShell New-Object Cmdlet

PowerShell New-Object Cmdlet

PowerShell New-Object Cmdlet

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed Get-Member cmdlet in PowerShell.

https://cloudaffaire.com/powershell-get-member-cmdlet/

In this blog post, we will discuss New-Object cmdlet in PowerShell. The New-Object cmdlet creates an instance of a .NET Framework or COM object. The. NET System Class Type or Progide of a COM object can be defined. You provide the full name of a. NET System class, and the cmdlet returns a reference to that class instance. You can also use the ComObject parameter to construct an instance of a COM object and set a ProgID for the object.

New-Object Cmdlet Syntax:

New-Object Cmdlet Argument List:

  • ArgumentList: Specifies an array of arguments to pass to the constructor of the .NET Framework class.
  • ComObject: Specifies the programmatic identifier (ProgID) of the COM object.
  • Property: Sets property values and invokes methods of the new object.
  • Strict: Indicates that the cmdlet generates a non-terminating error when a COM object that you attempt to create uses an interop assembly.
  • TypeName: Specifies the fully qualified name of the .NET Framework class.

PowerShell New-Object Cmdlet:

Create A Dictionary Object In PowerShell:

Create A Custom Object In PowerShell:

Hope you have enjoyed this article. In the next blog post, we will discuss Select-Object cmdlet in PowerShell.

To get more details on PowerShell, kindly follow below official documentation

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about?view=powershell-5.1

 

Leave a Reply