New-Object - Powershell 1.0 CmdLet
Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.
More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.
Description Create a new .Net object Usage Options typeName string The fully-qualified name of the .Net class. -argumentList Object A comma separated list of arguments to pass to the constructor of the .Net class. -comObject string Programmatic Identifier (ProgID) of the COM object. -strict Raise an error if the COM object that you attempt to create uses an interop assembly. This enables you to distinguish actual COM objects from .Net objects with COM-callable wrappers. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable. Example(s) Create a COM object "Shell.Application" and store the resulting reference in a variable, display the properties and methods of the COM object (via get-member.) Then use the ToggleDesktop method to minimizes all open desktop windows: PS C:\>$objshell = new-object -comobject "Shell.Application" $objshell | get-member $objshell.ToggleDesktop() Create a COM object "Word.Application" and store the resulting reference in a variable: PS C:\>$myWord=new-object -comobject Word.Application $myWord.visible=$true Send email: # Instantiate an SmtpClient object $SMTP_Mail = new-object Net.Mail.SmtpClient -arg "mailserver.example.com" # Instantiate a new MailMessage object, with sender, destination,subject and body $Message = new-object Net.Mail.MailMessage("firstname.lastname@example.org","email@example.com", "Subject", "Here is some email") # Add an attachment to the message $Attach = new-object Net.Mail.Attachment("c:\\demo.txt") $Message.Attachments.Add($Attach) # Send the mail $SMTP_Mail.Send($Message) For more examples, type: "get-help New-Object -detailed"