{"id":76841,"date":"2016-02-15T11:59:37","date_gmt":"2016-02-15T11:59:37","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/?p=76841"},"modified":"2019-02-18T09:19:52","modified_gmt":"2019-02-18T16:19:52","slug":"powertip-send-output-to-file-and-screen-at-the-same-time","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-send-output-to-file-and-screen-at-the-same-time\/","title":{"rendered":"PowerTip: Send output to file and screen at the same time"},"content":{"rendered":"<p><strong>Summary<\/strong>: Cloud &amp; Datacenter Management MVP, Thomas Rayner, shows how to easily send data to the output of a script.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>\u00a0How can I use Windows PowerShell to send the same data that I\u2019m writing to a file to the standard output of my script?<\/p>\n<p style=\"padding-left: 30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>\u00a0In Windows PowerShell 5.0, use <strong>Tee-Object<\/strong>, for example:<\/p>\n<p style=\"padding-left: 90px\">PS C:\\WINDOWS\\system32&gt; Tee-Object -InputObject &#8216;Some text&#8217; -FilePath &#8216;C:\\temp\\some file.txt&#8217;<\/p>\n<p style=\"padding-left: 90px\">Some text<\/p>\n<p style=\"padding-left: 90px\">PS C:\\WINDOWS\\system32&gt; Get-Content -Path &#8216;C:\\temp\\some file.txt&#8217;<\/p>\n<p style=\"padding-left: 90px\">Some text<\/p>\n<p style=\"padding-left: 30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\" alt=\" \" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Cloud &amp; Datacenter Management MVP, Thomas Rayner, shows how to easily send data to the output of a script. \u00a0How can I use Windows PowerShell to send the same data that I\u2019m writing to a file to the standard output of my script? \u00a0In Windows PowerShell 5.0, use Tee-Object, for example: PS C:\\WINDOWS\\system32&gt; Tee-Object [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[639],"tags":[56,356,3,652,45],"class_list":["post-76841","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powertip","tag-guest-blogger","tag-powertip","tag-scripting-guy","tag-thomas-rayner","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Cloud &amp; Datacenter Management MVP, Thomas Rayner, shows how to easily send data to the output of a script. \u00a0How can I use Windows PowerShell to send the same data that I\u2019m writing to a file to the standard output of my script? \u00a0In Windows PowerShell 5.0, use Tee-Object, for example: PS C:\\WINDOWS\\system32&gt; Tee-Object [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/76841","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=76841"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/76841\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=76841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=76841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=76841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}