{"id":1355,"date":"2011-04-18T09:30:26","date_gmt":"2011-04-18T13:30:26","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=1355"},"modified":"2013-04-25T22:18:00","modified_gmt":"2013-04-26T02:18:00","slug":"get-comon-data","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1355\/get-comon-data\/","title":{"rendered":"Get Common Data"},"content":{"rendered":"<p>While judging entries in this year's Scripting Games I realized there were some common properties that were repeatedly used. This got me thinking about a simple way to retrieve that information with a single command Then you could access the data values from within your script. I've put together a relatively simply function called Get-Common that you might find helpful.<\/p>\n<p>There's nothing fancy about this function.<\/p>\n<pre class=\"lang:default decode:true\">Function Get-Common {\r\n\r\n[cmdletbinding()]\r\n\r\nParam()\r\n\r\nSet-StrictMode -Version Latest\r\n\r\nWrite-Verbose \"Starting $($myinvocation.mycommand)\"\r\n\r\n#test if user is an administrator\r\nWrite-Verbose \"Testing for admin rights\"\r\n$currentUser = [Security.Principal.WindowsIdentity]::GetCurrent()\r\n$IsAdmin=(New-Object Security.Principal.WindowsPrincipal $currentUser).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)\r\n\r\nWrite-Verbose \"Get Username\"\r\n#get username from the environmental variable\r\n$username=$env:username\r\n\r\nWrite-Verbose \"Get Computername\"\r\n#get computername from the environmental variable\r\n$computername=$env:computername\r\n\r\nWrite-Verbose \"Get Domain name\"\r\n#get domain name from the environmental variable\r\n$domain=$env:userdomain\r\n\r\nWrite-Verbose \"Get DNS Domain name\"\r\n#get domain DNS name from the environmental variable\r\n#this may not be found on older computers\r\nif ($env:userDNSDomain)\r\n{\r\n$dnsDomain=$env:userdnsdomain\r\n}\r\nelse\r\n{\r\n$dnsDomain=$Null\r\n}\r\nWrite-Verbose \"Get Operating System\"\r\n#get operating system from WMI\r\n$os=Get-WmiObject -Class Win32_OperatingSystem\r\n\r\nWrite-Verbose \"Get last boot up time\"\r\n#use the WMI ConvertToDateTime method\r\n$boot=$os.ConvertToDateTime($os.LastBootUpTime)\r\n\r\nWrite-Verbose \"Write object\"\r\n#write custom object to the pipeline\r\nNew-Object -TypeName PSObject -Property @{\r\nUsername=$username\r\nComputername=$computername\r\nIsAdmin=$IsAdmin\r\nDomain=$domain\r\nDNSDomain=$DNSDomain\r\nOperatingSystem=$os.caption\r\nLastBoot=$boot\r\nPSHost=$host.name\r\nPSVersion=$host.version\r\n}\r\n\r\nWrite-Verbose \"Ending $($myinvocation.mycommand)\"\r\n\r\n} #end function<\/pre>\n<p>I gathers a number of what I think of as common values such as username, computername, PowerShell host and whether the user is running as an administrator. The function writes a custom object to the pipeline, using New-Object.<\/p>\n<pre class=\"lang:default decode:true\">PS S:\\&gt; get-common\r\n\r\nComputername : SERENITY\r\nUsername : Jeff\r\nLastBoot : 4\/15\/2011 2:34:19 PM\r\nIsAdmin : True\r\nDNSDomain :\r\nOperatingSystem : Microsoft Windows 7 Ultimate\r\nPSHost : ConsoleHost\r\nDomain : SERENITY\r\nPSVersion : 2.0<\/pre>\n<p>Assuming you have dot sourced the function, you could use it in your script like this:<\/p>\n<pre class=\"lang:ps decode:true\">$data=Get-Common\r\n\r\nif ($data.IsAdmin)\r\n{\r\n$wsmanPort=(dir WSMan:\\localhost\\Listener -rec | where {$_.name -eq \"Port\"}).value\r\n\r\n$uptime=(Get-Date) - $data.lastBoot\r\nif ($data.OperatingSystem -match \"Windows 7\")\r\n{\r\n$Win7=$True\r\n}\r\nelse\r\n{\r\n$Win7=$False\r\n}\r\nNew-Object -TypeName PSObject -Property @{\r\nComputername=$data.computername\r\nUptime=$uptime\r\nIsWin7=$Win7\r\nWSManPort=$wsmanPort\r\n}\r\n\r\n}\r\nelse\r\n{\r\nWrite-Warning \"You must be an administrator\"\r\n}<\/pre>\n<p>Maybe this will help simplify your scripts or maybe it won't. Of course you can easily extend it to include other core or common data you use frequently in your scripts. If there's something you add, I'm curious to learn what it is.<\/p>\n<p>Download <a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/04\/Get-Common.txt\">Get-Common<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While judging entries in this year&#8217;s Scripting Games I realized there were some common properties that were repeatedly used. This got me thinking about a simple way to retrieve that information with a single command Then you could access the data values from within your script. I&#8217;ve put together a relatively simply function called Get-Common&#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":[75,8],"tags":[32,190,534,540],"class_list":["post-1355","post","type-post","status-publish","format-standard","hentry","category-powershell-v2-0","category-scripting","tag-functions","tag-new-object","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Get Common Data &#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\/scripting\/1355\/get-comon-data\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get Common Data &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"While judging entries in this year&#039;s Scripting Games I realized there were some common properties that were repeatedly used. This got me thinking about a simple way to retrieve that information with a single command Then you could access the data values from within your script. I&#039;ve put together a relatively simply function called Get-Common...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/1355\/get-comon-data\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2011-04-18T13:30:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-04-26T02:18:00+00:00\" \/>\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\\\/scripting\\\/1355\\\/get-comon-data\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1355\\\/get-comon-data\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Get Common Data\",\"datePublished\":\"2011-04-18T13:30:26+00:00\",\"dateModified\":\"2013-04-26T02:18:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1355\\\/get-comon-data\\\/\"},\"wordCount\":174,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"functions\",\"new-object\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell v2.0\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1355\\\/get-comon-data\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1355\\\/get-comon-data\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1355\\\/get-comon-data\\\/\",\"name\":\"Get Common Data &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2011-04-18T13:30:26+00:00\",\"dateModified\":\"2013-04-26T02:18:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1355\\\/get-comon-data\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1355\\\/get-comon-data\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/1355\\\/get-comon-data\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell v2.0\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell-v2-0\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get Common Data\"}]},{\"@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":"Get Common Data &#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\/scripting\/1355\/get-comon-data\/","og_locale":"en_US","og_type":"article","og_title":"Get Common Data &#8226; The Lonely Administrator","og_description":"While judging entries in this year's Scripting Games I realized there were some common properties that were repeatedly used. This got me thinking about a simple way to retrieve that information with a single command Then you could access the data values from within your script. I've put together a relatively simply function called Get-Common...","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1355\/get-comon-data\/","og_site_name":"The Lonely Administrator","article_published_time":"2011-04-18T13:30:26+00:00","article_modified_time":"2013-04-26T02:18:00+00:00","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\/scripting\/1355\/get-comon-data\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1355\/get-comon-data\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Get Common Data","datePublished":"2011-04-18T13:30:26+00:00","dateModified":"2013-04-26T02:18:00+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1355\/get-comon-data\/"},"wordCount":174,"commentCount":1,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["functions","new-object","PowerShell","Scripting"],"articleSection":["PowerShell v2.0","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/1355\/get-comon-data\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1355\/get-comon-data\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1355\/get-comon-data\/","name":"Get Common Data &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2011-04-18T13:30:26+00:00","dateModified":"2013-04-26T02:18:00+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1355\/get-comon-data\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/1355\/get-comon-data\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1355\/get-comon-data\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell v2.0","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},{"@type":"ListItem","position":2,"name":"Get Common Data"}]},{"@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":6855,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/6855\/powershell-scripting-for-linux-is-still-about-the-objects\/","url_meta":{"origin":1355,"position":0},"title":"PowerShell Scripting for Linux is Still About the Objects","author":"Jeffery Hicks","date":"October 8, 2019","format":false,"excerpt":"I've been trying to increase my Linux skills, especially as I begin to write PowerShell scripts and tools that can work cross-platform. One very important concept I want to make sure you don't overlook is that even when scripting for non-Windows platforms, you must still be thinking about objects. The\u2026","rel":"","context":"In &quot;PowerShell 7&quot;","block_context":{"text":"PowerShell 7","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-7\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1423,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1423\/warning-signs\/","url_meta":{"origin":1355,"position":1},"title":"Warning Signs","author":"Jeffery Hicks","date":"May 11, 2011","format":false,"excerpt":"I was working on a project with an advanced PowerShell function. One of the goals was to take advantage of the common parameters like -ErrorVariable and -WarningVariable so that when you run the function you can save errors and warnings and work with them later. Turns out one of these\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":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/warningvariable-300x184.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1603,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1603\/select-object-properties-with-values\/","url_meta":{"origin":1355,"position":2},"title":"Select Object Properties with Values","author":"Jeffery Hicks","date":"August 16, 2011","format":false,"excerpt":"Here's another concept I know I've written about in the past but that needed an update. A common technique I use when exploring and discovering objects is to pipe the object to Select-Object specifying all properties, get-service spooler | select *. There's nothing wrong with this approach but depending on\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":4484,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4484\/an-improved-get-verb-command\/","url_meta":{"origin":1355,"position":3},"title":"An Improved Get-Verb Command","author":"Jeffery Hicks","date":"August 10, 2015","format":false,"excerpt":"A recommended best practice for PowerShell scripting, especially when developing functions, is to follow the standard Verb-Noun naming convention. The Verb\u00a0 should be a value from the list of approved .NET verbs. The easy way to see that list is with the Get-Verb cmdlet. The result will also indicate the\u2026","rel":"","context":"In &quot;Best Practices&quot;","block_context":{"text":"Best Practices","link":"https:\/\/jdhitsolutions.com\/blog\/category\/best-practices\/"},"img":{"alt_text":"get-myverb","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/08\/get-myverb-1024x703.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1483,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1483\/test-port-2-0\/","url_meta":{"origin":1355,"position":4},"title":"Test Port 2.0","author":"Jeffery Hicks","date":"May 31, 2011","format":false,"excerpt":"A few years ago I updated a PowerShell script I came across to scan a computer for open ports. My initial revision was aimed at making it more pipeline friendly in PowerShell v1.0. I recently needed to use the function for a project and realized it could benefit from a\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":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/test-port-300x126.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":407,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/407\/is-that-folder-empty\/","url_meta":{"origin":1355,"position":5},"title":"Is That Folder Empty?","author":"Jeffery Hicks","date":"September 30, 2009","format":false,"excerpt":"In keeping with my recent trend of offering solutions based on PowerShell v2.0, here's a function I've revised to test if a folder is empty. I can't recall where I used the original function or if I ever did. But I came across it recently and decided to give it\u2026","rel":"","context":"In &quot;CommandLine&quot;","block_context":{"text":"CommandLine","link":"https:\/\/jdhitsolutions.com\/blog\/category\/commandline\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/09\/zrtn_003p5cb42026_tn.jpg?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1355","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=1355"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1355\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}