{"id":2198,"date":"2012-04-13T10:34:45","date_gmt":"2012-04-13T14:34:45","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=2198"},"modified":"2012-04-13T10:34:45","modified_gmt":"2012-04-13T14:34:45","slug":"friday-fun-13-more-scriptblocks","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/","title":{"rendered":"Friday Fun: 13 More Scriptblocks"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/13ball.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/13ball-150x150.png\" alt=\"\" title=\"13ball\" width=\"150\" height=\"150\" class=\"alignleft size-thumbnail wp-image-2202\" \/><\/a>In celebration of Friday the 13th I thought I would offer up a menu of 13 more script blocks. If you missed the first course, you can find the original 13 scrptblocks <a href=\"http:\/\/jdhitsolutions.com\/blog\/2010\/08\/friday-the-13-script-blocks\/\" target=\"_blank\">here<\/a>. I'm not going to spend a lot of time going over these. Many of them are simple one liners. Some of them take parameters just like functions and scripts. The easiest way to execute any of the scriptblocks is to use the & operator. But these might also come in handy with any cmdlet that takes a scriptblock as a parameter value such as Invoke-Command.<\/p>\n<p>I think of scriptblocks as \"quick and dirty\" blocks of re-usable code. If you find something very useful, you might expand it into a full-blown function complete with error handling and verbose output. Or you might find a handy technique in one of these examples.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\n#1 Get top problem source from the last 500 event log entries<br \/>\n$topprob={Param($log=\"System\") Get-EventLog -LogName $log -newest 500 -entrytype Error |<br \/>\n Group Source -NoElement | Sort Count | Select -last 1}<br \/>\n#&$topprob<\/p>\n<p>#2 Get folder usage by owner in MB<br \/>\n$usage={Param($path=\".\") dir $path -recurse | Where {-Not $_.PSIsContainer} |<br \/>\nSelect Fullname,Length,@{N='Owner';E={($_ | Get-ACL).Owner}} |<br \/>\nGroup Owner | Sort Count -descending|<br \/>\nSelect Count,Name,@{N='SizeMB';E={(($_.Group | Measure length -sum).sum)\/1MB}}<br \/>\n}<br \/>\n#&$usage <\/p>\n<p>#3 get empty event logs<br \/>\n$emptylog={get-eventlog -list | where {$_.entries.count -eq 0}}<br \/>\n#&$emptylog<\/p>\n<p>#4 Get OS Install date<br \/>\n$install={Param($Computername=$env:computername) Get-WmiObject win32_operatingsystem -comp $computername |<br \/>\nselect CSName,Caption, @{N=\"Install\";E={$_.ConvertToDateTime($_.InstallDate)}}}<br \/>\n#&$install<\/p>\n<p>#5 Test if running Windows 8<br \/>\n$test8={Param($Computername=$env:computername)<br \/>\n(Get-WmiObject win32_operatingsystem -comp $computername).Caption -match \"Windows 8\"<br \/>\n}<br \/>\n#&$test8 MyWin8<\/p>\n<p>#6 Test if running PowerShell v3<br \/>\n$testPS3={Param($Computername=$env:computername)<br \/>\n(test-wsman -ComputerName $computername).Productversion -match \"Stack: 3.0\"}<br \/>\n#&$testPS3 MyWin8<\/p>\n<p>#7 Get code snippets from help examples<br \/>\n$excode={Param($command=\"get-service\") (get-help $command).examples.example | select code}<br \/>\n#&$excode get-process<\/p>\n<p>#8 Count by 13<br \/>\n$countup={Param($count=5) $x=0; For ($i=0;$i -lt $Count; $i++) {$x+=13;$x}}<br \/>\n#&$countup 13<\/p>\n<p>#9 get a 13 character random password<br \/>\n$randpass={ Param($length=13) $chars=[char[]](33..126) ; -join ($chars | get-random -count $length)}<br \/>\n#&$randpass<\/p>\n<p>#10 Test if profile scripts exist<br \/>\n$profileCheck={<br \/>\n  $profile | Select @{N=\"Type\";E={\"AllUsersAllHosts\"}},@{N=\"Path\";E={$_.AllUsersAllHosts}},@{N=\"Exists\";E={Test-Path $_.AllUsersAllHosts}}<br \/>\n  $profile | Select @{N=\"Type\";E={\"AllUsersCurrentHost\"}},@{N=\"Path\";E={$_.AllUsersCurrentHost}},@{N=\"Exists\";E={Test-Path $_.AllUsersCurrentHost}}<br \/>\n  $profile | Select @{N=\"Type\";E={\"CurrentUsersAllHosts\"}},@{N=\"Path\";E={$_.CurrentUserAllHosts}},@{N=\"Exists\";E={Test-Path $_.CurrentUserAllHosts}}<br \/>\n  $profile | Select @{N=\"Type\";E={\"CurrentUserCurrentHost\"}},@{N=\"Path\";E={$_.CurrentUserCurrentHost}},@{N=\"Exists\";E={Test-Path $_.CurrentUserCurrentHost}}<br \/>\n}<br \/>\n#&$profileCheck | format-list<\/p>\n<p>#11 get default printer<br \/>\n$defaultPrint={get-wmiobject win32_printer -filter \"Default='True'\"}<br \/>\n#&$defaultPrint<\/p>\n<p>#12 get timezone<br \/>\n$tz={Param($computername=$env:computername) Get-WmiObject win32_timezone -computername $computername |<br \/>\nSelect @{N=\"Computername\";E={$_.__SERVER}},Description}<br \/>\n#&$tz <\/p>\n<p>#13 find expired certificates<br \/>\n$expired={dir cert:\\ -recurse | where {$_.NotAfter -AND $_.NotAfter -lt (Get-date)}}<br \/>\n#&$expired<br \/>\n#Invoke-command $expired -comp server01<br \/>\n<\/code><\/p>\n<p><a href='http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/13ScriptBlocks-v2.txt'>Download the script file<\/a> and watch out for black cats under ladders!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In celebration of Friday the 13th I thought I would offer up a menu of 13 more script blocks. If you missed the first course, you can find the original 13 scrptblocks here. I&#8217;m not going to spend a lot of time going over these. Many of them are simple one liners. Some of them&#8230;<\/p>\n","protected":false},"author":1,"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,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[271,4,8,19],"tags":[373,230,374,534,363,82,547],"class_list":["post-2198","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-powershell","category-scripting","category-wmi","tag-acl","tag-fridayfun","tag-password","tag-powershell","tag-random","tag-scriptblock","tag-wmi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun: 13 More Scriptblocks &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun: 13 More Scriptblocks &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"In celebration of Friday the 13th I thought I would offer up a menu of 13 more script blocks. If you missed the first course, you can find the original 13 scrptblocks here. I&#039;m not going to spend a lot of time going over these. Many of them are simple one liners. Some of them...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2012-04-13T14:34:45+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/13ball-150x150.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2198\\\/friday-fun-13-more-scriptblocks\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2198\\\/friday-fun-13-more-scriptblocks\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun: 13 More Scriptblocks\",\"datePublished\":\"2012-04-13T14:34:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2198\\\/friday-fun-13-more-scriptblocks\\\/\"},\"wordCount\":157,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2198\\\/friday-fun-13-more-scriptblocks\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/04\\\/13ball-150x150.png\",\"keywords\":[\"ACL\",\"FridayFun\",\"password\",\"PowerShell\",\"Random\",\"ScriptBlock\",\"WMI\"],\"articleSection\":[\"Friday Fun\",\"PowerShell\",\"Scripting\",\"WMI\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2198\\\/friday-fun-13-more-scriptblocks\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2198\\\/friday-fun-13-more-scriptblocks\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2198\\\/friday-fun-13-more-scriptblocks\\\/\",\"name\":\"Friday Fun: 13 More Scriptblocks &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2198\\\/friday-fun-13-more-scriptblocks\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2198\\\/friday-fun-13-more-scriptblocks\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/04\\\/13ball-150x150.png\",\"datePublished\":\"2012-04-13T14:34:45+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2198\\\/friday-fun-13-more-scriptblocks\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2198\\\/friday-fun-13-more-scriptblocks\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2198\\\/friday-fun-13-more-scriptblocks\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/04\\\/13ball.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/04\\\/13ball.png\",\"width\":\"819\",\"height\":\"1024\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/2198\\\/friday-fun-13-more-scriptblocks\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Friday Fun\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/friday-fun\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun: 13 More Scriptblocks\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Friday Fun: 13 More Scriptblocks &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun: 13 More Scriptblocks &#8226; The Lonely Administrator","og_description":"In celebration of Friday the 13th I thought I would offer up a menu of 13 more script blocks. If you missed the first course, you can find the original 13 scrptblocks here. I'm not going to spend a lot of time going over these. Many of them are simple one liners. Some of them...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/","og_site_name":"The Lonely Administrator","article_published_time":"2012-04-13T14:34:45+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/13ball-150x150.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun: 13 More Scriptblocks","datePublished":"2012-04-13T14:34:45+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/"},"wordCount":157,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/13ball-150x150.png","keywords":["ACL","FridayFun","password","PowerShell","Random","ScriptBlock","WMI"],"articleSection":["Friday Fun","PowerShell","Scripting","WMI"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/","name":"Friday Fun: 13 More Scriptblocks &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/13ball-150x150.png","datePublished":"2012-04-13T14:34:45+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/13ball.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/13ball.png","width":"819","height":"1024"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2198\/friday-fun-13-more-scriptblocks\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Friday Fun","item":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},{"@type":"ListItem","position":2,"name":"Friday Fun: 13 More Scriptblocks"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":826,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/826\/friday-the-13-script-blocks\/","url_meta":{"origin":2198,"position":0},"title":"Friday the 13 Script Blocks","author":"Jeffery Hicks","date":"August 13, 2010","format":false,"excerpt":"In celebration of Friday the 13th and to help ward off any triskaidekaphobia I thought I'd offer up 13 PowerShell scriptblocks. These are scriptblocks that might solve a legitimate business need like finding how long a server has been running to the more mercurial such as how many hours before\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1653,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1653\/the-powershell-day-care-building-scriptblocks\/","url_meta":{"origin":2198,"position":1},"title":"The PowerShell Day Care: Building ScriptBlocks","author":"Jeffery Hicks","date":"September 22, 2011","format":false,"excerpt":"Good morning kids and welcome to the PowerShell Day Care center. We offer a creative and nurturing environment for PowerShell professionals of all ages. Later there might even be juice and cookies. But first let's get out our blocks, our scriptblocks, and start building. I've written a number of posts\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1814,"url":"https:\/\/jdhitsolutions.com\/blog\/google-plus\/1814\/re-use-powershell-scriptblocks-i-commented\/","url_meta":{"origin":2198,"position":2},"title":"Re-Use PowerShell Scriptblocks","author":"Jeffery Hicks","date":"October 24, 2011","format":false,"excerpt":"\/\/Re-Use PowerShell Scriptblocks\/\/I commented on a blog post today that showed how to use a hash table with Select-Object to format file sizes say as KB.dir $env:temp -rec | select fullname,@{Name=\"KB\";Expression={$_.length\/1kb}}Since you most likely will want to use something similar for other directories, don't feel you have to re-invent the\u2026","rel":"","context":"In &quot;Google Plus&quot;","block_context":{"text":"Google Plus","link":"https:\/\/jdhitsolutions.com\/blog\/category\/google-plus\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1962,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1962\/friday-fun-whats-my-variable\/","url_meta":{"origin":2198,"position":3},"title":"Friday Fun What&#8217;s My Variable","author":"Jeffery Hicks","date":"January 6, 2012","format":false,"excerpt":"I use scriptblocks quite a bit in my PowerShell work, often saved as variables. These are handy for commands you want to run again, but don't necessarily need to turn into permanent functions. $freec={(get-wmiobject win32_logicaldisk -filter \"deviceid='c:'\" -property Freespace).FreeSpace\/1mb} Now in PowerShell I can invoke the scriptblock. PS S:\\> &$freec\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/get-variabletype-1-300x197.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1517,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1517\/scriptblocks-on-the-fly\/","url_meta":{"origin":2198,"position":4},"title":"ScriptBlocks On the Fly","author":"Jeffery Hicks","date":"June 20, 2011","format":false,"excerpt":"I'm always preaching about writing PowerShell scripts and functions with reuse and modularization in mind. You should never have to write the same block of code twice. But what about in the shell during your daily grind? Perhaps today you're dealing with some issue and periodically need to run a\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":693,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/693\/out-clip\/","url_meta":{"origin":2198,"position":5},"title":"Out-Clip","author":"Jeffery Hicks","date":"July 6, 2010","format":false,"excerpt":"I\u2019ve started working on the 2nd edition of Managing Active Directory with Windows PowerShell: TFM. As with almost all of my writing projects it will be full of PowerShell code examples. In the past I\u2019ve always relied on a manual copy and paste to add content to the manuscript. The\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=2198"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2198\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}