{"id":8511,"date":"2007-02-23T08:26:03","date_gmt":"2007-02-23T08:26:03","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2007\/02\/23\/why-isnt-new-object-aliased-to-new\/"},"modified":"2019-02-18T13:20:43","modified_gmt":"2019-02-18T20:20:43","slug":"why-isnt-new-object-aliased-to-new","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/why-isnt-new-object-aliased-to-new\/","title":{"rendered":"Why isn&#8217;t &#8220;New-Object&#8221; aliased to &#8220;New&#8221;"},"content":{"rendered":"<p>Alistair Young made a <a href=\"http:\/\/weblog.siliconcerebrate.com\/PermaLink,guid,0ce89518-8858-44d1-85ef-71ab49c24f12.aspx\">Note to Self<\/a> :\n<\/p>\n<p style=\"margin-left: 36pt\"><span style=\"color:black;font-family:Verdana;font-size:8pt\">In a standard PowerShell installation, &#8220;new&#8221; is <strong>not<\/strong> an alias for &#8220;new-object&#8221;. You added that. You should therefore know better that to make this kind of dumbass mistake.\n<\/span><\/p>\n<p>We talked about making &#8220;New&#8221; an alias to &#8220;New-Object&#8221; but decided against it in the end because it leaves open the door for us to provide a C#-like NEW keyword sometime in the future.  We want PowerShell to provide a nice glide path to C# so in the future, we&#8217;d like the following to be equivalent:\n<\/p>\n<p style=\"margin-left: 36pt\"><span style=\"font-family:Courier New\">$x = New-Object System.DateTime 2007,12,25\n<\/span><\/p>\n<p style=\"margin-left: 36pt\"><span style=\"font-family:Courier New\">$x = new System.DateTime(2007,12,25)\n<\/span><\/p>\n<p>So if we decide to implement this in the future and you&#8217;ve aliased New to New-Object, your scripts will break.\n<\/p>\n<p>\n\u00a0<\/p>\n<p>Jeffrey Snover [MSFT]<br \/>Windows PowerShell\/MMC Architect<br \/>Visit the Windows PowerShell Team blog at:    <a href=\"http:\/\/blogs.msdn.com\/PowerShell\">http:\/\/blogs.msdn.com\/PowerShell<\/a><br \/>Visit the Windows PowerShell ScriptCenter at:  <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx\">http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/a>\n\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Alistair Young made a Note to Self : In a standard PowerShell installation, &#8220;new&#8221; is not an alias for &#8220;new-object&#8221;. You added that. You should therefore know better that to make this kind of dumbass mistake. We talked about making &#8220;New&#8221; an alias to &#8220;New-Object&#8221; but decided against it in the end because it leaves [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[10],"class_list":["post-8511","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-faq"],"acf":[],"blog_post_summary":"<p>Alistair Young made a Note to Self : In a standard PowerShell installation, &#8220;new&#8221; is not an alias for &#8220;new-object&#8221;. You added that. You should therefore know better that to make this kind of dumbass mistake. We talked about making &#8220;New&#8221; an alias to &#8220;New-Object&#8221; but decided against it in the end because it leaves [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/8511","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=8511"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/8511\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=8511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=8511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=8511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}