{"id":9981,"date":"2006-07-15T18:02:00","date_gmt":"2006-07-15T18:02:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2006\/07\/15\/psmdtagfaq-what-is-ofs\/"},"modified":"2019-02-18T13:21:32","modified_gmt":"2019-02-18T20:21:32","slug":"psmdtagfaq-what-is-ofs","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/psmdtagfaq-what-is-ofs\/","title":{"rendered":"PSMDTAG:FAQ: What is $OFS"},"content":{"rendered":"<p>In my blog entry regarding Cascading Type Casts ( <a href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/2006\/07\/15\/Cascading_Type_Casts.aspx\">http:\/\/blogs.msdn.com\/powershell\/archive\/2006\/07\/15\/Cascading_Type_Casts.aspx<\/a>&nbsp;) there was an example:<\/p>\n<p>PS&gt; [string][char[]][int[]][char[]]&#8221;PowerShell&#8221; <br \/>P o w e r S h e l l <\/p>\n<p>And in a comment was a question asking why there were spaces between the letters.&nbsp; The answer is $OFS<\/p>\n<p>&nbsp;<\/p>\n<p>PSMDTAG:FAQ: What is $OFS<\/p>\n<p>$OFS is a special variable that contains the string to be used as the Ouptut Field Sperator.&nbsp;&nbsp; This string is used when an array is converted to a&nbsp;string.&nbsp; By default, this is &#8221; &#8221; but you can change it.<\/p>\n<p>Here are some examples to clarify:<\/p>\n<p><font face=\"Courier New\" size=\"1\">PS&gt;<strong> $a=&#8221;1&#8243;,&#8221;2&#8243;,&#8221;3&#8243;,&#8221;4&#8243;<br \/><\/strong>PS&gt; <strong>$a<br \/><\/strong>1<br \/>2<br \/>3<br \/>4<br \/>PS&gt; <strong>[string]$a<br \/><\/strong>1 2 3 4<br \/>PS&gt;<strong> $OFS=&#8221;&#8221;;[string]$a<br \/><\/strong>1234<br \/>PS&gt; <strong>$OFS=&#8221;,&#8221;;[string]$a<br \/><\/strong>1,2,3,4<br \/>PS&gt; <strong>$OFS=&#8221;&#8211;PowerShellRocks&#8211;&#8220;;[string]$a<br \/><\/strong>1&#8211;PowerShellRocks&#8211;2&#8211;PowerShellRocks&#8211;3&#8211;PowerShellRocks&#8211;4<br \/>PS&gt; <strong>$OFS=&#8221;`n`n&#8221;;[string]$a<br \/><\/strong>1<\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\">2<\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\">3<\/font><\/p>\n<p><font face=\"Courier New\" size=\"1\">4<br \/>PS&gt;<\/font><\/p>\n<p>Experiment and Enjoy!<\/p>\n<p>Jeffrey Snover [MSFT]<br \/>Windows PowerShell\/Aspen Architect<br \/>Visit the Windows PowerShell Team blog at:&nbsp;&nbsp;&nbsp; <a href=\"http:\/\/blogs.msdn.com\/PowerShell\">http:\/\/blogs.msdn.com\/PowerShell<\/a><br \/>Visit the Windows PowerShell ScriptCenter at:&nbsp; <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx\">http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my blog entry regarding Cascading Type Casts ( http:\/\/blogs.msdn.com\/powershell\/archive\/2006\/07\/15\/Cascading_Type_Casts.aspx&nbsp;) there was an example: PS&gt; [string][char[]][int[]][char[]]&#8221;PowerShell&#8221; P o w e r S h e l l And in a comment was a question asking why there were spaces between the letters.&nbsp; The answer is $OFS &nbsp; PSMDTAG:FAQ: What is $OFS $OFS is a special variable [&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":[29,10],"class_list":["post-9981","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-environment","tag-faq"],"acf":[],"blog_post_summary":"<p>In my blog entry regarding Cascading Type Casts ( http:\/\/blogs.msdn.com\/powershell\/archive\/2006\/07\/15\/Cascading_Type_Casts.aspx&nbsp;) there was an example: PS&gt; [string][char[]][int[]][char[]]&#8221;PowerShell&#8221; P o w e r S h e l l And in a comment was a question asking why there were spaces between the letters.&nbsp; The answer is $OFS &nbsp; PSMDTAG:FAQ: What is $OFS $OFS is a special variable [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/9981","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=9981"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/9981\/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=9981"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=9981"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=9981"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}