{"id":1290,"date":"2009-03-16T05:45:30","date_gmt":"2009-03-16T13:45:30","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/2009\/03\/16\/show-cspace\/"},"modified":"2009-03-16T05:45:30","modified_gmt":"2009-03-16T13:45:30","slug":"show-cspace","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2009\/03\/16\/show-cspace\/","title":{"rendered":"Show-CSpace"},"content":{"rendered":"<p>My latest Prof. PowerShell <a href=\"http:\/\/mcpmag.com\/columns\/article.asp?editorialsid=3035\" target=\"_blank\">column<\/a> has a function that takes a computername as pipelined input. It then returns a custom object showing free space on drive C:\\. The point of the column was to demonstrate how to make a function behave like a cmdlet and take pipelined input so it&#8217;s not necessarily the most glamorous function I&#8217;ve ever written.<\/p>\n<p>Anyway, the function got mangled in formatting for the web.&nbsp; This is what it should be:<\/p>\n<div style=\"border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4\">\n<div style=\"padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none\">\n<pre style=\"padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none\">Function Show-CSpace {<\/pre>\n<pre style=\"padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none\">  Begin {}<\/pre>\n<pre style=\"padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none\">  Process {<\/pre>\n<pre style=\"padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none\">    $c=Get-WmiObject win32_logicaldisk -<span style=\"color: #0000ff\">filter<\/span> <span style=\"color: #006080\">\"deviceid='c:'\"<\/span> -computername $_<\/pre>\n<pre style=\"padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none\">    $c | Select-Object @{name=<span style=\"color: #006080\">\"Server\"<\/span>;Expression={$_.__SERVER}},Size,FreeSpace<\/pre>\n<pre style=\"padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none\">  }<\/pre>\n<pre style=\"padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none\">  End {}<\/pre>\n<pre style=\"padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none\">}<\/pre>\n<\/div>\n<\/div>\n<div class=\"wlWriterSmartContent\" id=\"scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:86c409f9-1130-4223-ac4b-fd6e2db1acd9\" style=\"padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px\">\n<p>Download a text file with the function <a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2009\/03\/show-cspace.txt\" target=\"_blank\">here.<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>My latest Prof. PowerShell column has a function that takes a computername as pipelined input. It then returns a custom object showing free space on drive C:\\. The point of the column was to demonstrate how to make a function behave like a cmdlet and take pipelined input so it&#8217;s not necessarily the most glamorous function I&#8217;ve ever written.<\/p>\n<p>Anyway, the function got mangled in formatting for the web.  This is what it should be&#8230;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[25],"tags":[198,468,28,57],"class_list":["post-1290","post","type-post","status-publish","format-standard","hentry","category-windows-powershell","tag-function","tag-pipeline","tag-powershell","tag-scripting"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/1290","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=1290"}],"version-history":[{"count":0,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/1290\/revisions"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=1290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=1290"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=1290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}