{"id":1209,"date":"2011-03-10T10:02:47","date_gmt":"2011-03-10T15:02:47","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=1209"},"modified":"2013-06-28T08:36:26","modified_gmt":"2013-06-28T12:36:26","slug":"get-ip-data","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1209\/get-ip-data\/","title":{"rendered":"Get IP Data"},"content":{"rendered":"<p>I was doodling in PowerShell this morning and ended up with what I hope is a useful function to retrieve IP configuration information, sort of like IPCONFIG, but using WMI. The beauty is that I can connect to remote machines and the output is an object which leads to all sorts of possibilities.<\/p>\n<p>My function is called Get-IPData.<\/p>\n<pre class=\"lang:ps decode:true crayon-selected\">Function Get-IPData {\r\n#this function assumes admin credentials\r\n[cmdletBinding()]\r\nParam(\r\n    [Parameter(Position=0,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]\r\n    [ValidateNotNullOrEmpty()]\r\n    [Alias(\"name\")]\r\n    [string[]]$computername=$env:computername\r\n)\r\n\r\nProcess {\r\n    ForEach ($computer in $computername) {\r\n        Write-Verbose \"Querying $($computer.ToUpper())\"\r\n        Try \r\n        {\r\n            #get NICS that are IP and DHCP enabled\r\n            Get-WMIObject -Class win32_networkadapterconfiguration -computername $Computer `\r\n            -Filter \"IPEnabled='TRUE' AND DHCPEnabled='TRUE'\" -ErrorAction \"Stop\" | \r\n            Select Description,DNSHostname,\r\n            @{Name=\"IPAddress\";Expression={$_.IPAddress[0]}},\r\n            @{Name=\"SubnetMask\";Expression={$_.IPSubnet[0]}},\r\n            @{Name=\"DefaultGateway\";Expression={$_.DefaultIPGateway[0]}},DNSDomain,\r\n            @{Name=\"PrimaryDNS\";Expression={$_.DNSServerSearchOrder[0]}},DHCPServer,\r\n            @{Name=\"DHCPLease\";Expression={$_.ConvertToDateTime($_.DHCPLeaseObtained)}},\r\n            @{Name=\"DHCPExpires\";Expression={$_.ConvertToDateTime($_.DHCPLeaseExpires)}},\r\n            @{Name=\"DHCPTimeToLive\";Expression={ $_.ConvertToDateTime($_.DHCPLeaseExpires) - (Get-Date)}},\r\n            MACAddress,\r\n            @{Name=\"Speed\";Expression={\r\n            #use an Associators Of query to get the NIC\r\n              $nic=Get-WmiObject -query \"associators of {Win32_NetworkAdapterConfiguration.Index=$($_.index)}\" -computername $computer\r\n              $nic.Speed\r\n              }}\r\n        } #close Try\r\n        Catch\r\n        {\r\n            Write-Warning \"Failed to retrieve IP configuration from $($computer.ToUpper())\"\r\n            Write-Warning $_.Exception.Message\r\n\r\n        } #close Catch\r\n    } #close ForEach\r\n } #close Process\r\n} #end function<\/pre>\n<p>The function takes computernames as a parameter, uses WMI to get the NetworkAdapterConfiguration for IP and DHCP enabled adapters.<\/p>\n<pre class=\"lang:ps decode:true\">Get-WMIObject -Class win32_networkadapterconfiguration -computername $Computer -Filter \"IPEnabled='TRUE' AND DHCPEnabled='TRUE'\" -ErrorAction \"Stop\"<\/pre>\n<p>The rest of the function simply selects key properties including another WMI query to get the associated adapater's speed. Because some items like IP address are stored as arrays, I use a hash table expression to return the first item only.<\/p>\n<pre class=\"nums:false lang:batch decode:true\">PS C:\\&gt; get-ipdata\r\n\r\nDescription    : Atheros AR8131 PCI-E Gigabit Ethernet Controller (NDIS 6.20)\r\nDNSHostname    : SERENITY\r\nIPAddress      : 172.16.10.124\r\nSubnetMask     : 255.255.0.0\r\nDefaultGateway : 172.16.10.254\r\nDNSDomain      : jdhitsolutions.local\r\nPrimaryDNS     : 172.16.10.1\r\nDHCPServer     : 172.16.10.1\r\nDHCPLease      : 3\/10\/2011 7:30:01 AM\r\nDHCPExpires    : 3\/13\/2011 8:30:01 AM\r\nDHCPTimeToLive : 2.22:43:15.9650056\r\nMACAddress     : 00:26:9E:C7:09:76\r\nSpeed          : 1000000000<\/pre>\n<p>I started to do my usual code polishing but then I realized this might be a good exercise for you. The function works as is with some limited error handling in a Try\/Catch block. But there are several areas for improvement or enhancement. You might want to:<\/p>\n<ul>\n<li>Add support for alternate credentials<\/li>\n<li>Add comment based help<\/li>\n<li>Add support for running as a background job<\/li>\n<li>Create a graphical, WinForm\/WPF version<\/li>\n<li>Add IPv6 information<\/li>\n<li>Add the average ping response time<\/li>\n<li>Add more adapter information<\/li>\n<\/ul>\n<p>I'll leave the rest to you. This could be a nice warmup practice for the upcoming <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2011\/02\/19\/2011-scripting-games-all-links-on-one-page.aspx\" target=\"_blank\">Scripting Games<\/a>.<\/p>\n<p>Download <a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/03\/Get-IPData.txt\" target=\"_'blank'\">Get-IPData.ps1<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was doodling in PowerShell this morning and ended up with what I hope is a useful function to retrieve IP configuration information, sort of like IPCONFIG, but using WMI. The beauty is that I can connect to remote machines and the output is an object which leads to all sorts of possibilities. My function&#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":[4,8,19],"tags":[32,103,264,534,540,547],"class_list":["post-1209","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","category-wmi","tag-functions","tag-get-wmiobject","tag-networkadapter","tag-powershell","tag-scripting","tag-wmi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Get IP 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\/powershell\/1209\/get-ip-data\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get IP Data &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I was doodling in PowerShell this morning and ended up with what I hope is a useful function to retrieve IP configuration information, sort of like IPCONFIG, but using WMI. The beauty is that I can connect to remote machines and the output is an object which leads to all sorts of possibilities. My function...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/1209\/get-ip-data\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2011-03-10T15:02:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-06-28T12:36:26+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\\\/powershell\\\/1209\\\/get-ip-data\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1209\\\/get-ip-data\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Get IP Data\",\"datePublished\":\"2011-03-10T15:02:47+00:00\",\"dateModified\":\"2013-06-28T12:36:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1209\\\/get-ip-data\\\/\"},\"wordCount\":228,\"commentCount\":10,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"functions\",\"Get-WMIObject\",\"NetworkAdapter\",\"PowerShell\",\"Scripting\",\"WMI\"],\"articleSection\":[\"PowerShell\",\"Scripting\",\"WMI\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1209\\\/get-ip-data\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1209\\\/get-ip-data\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1209\\\/get-ip-data\\\/\",\"name\":\"Get IP Data &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2011-03-10T15:02:47+00:00\",\"dateModified\":\"2013-06-28T12:36:26+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1209\\\/get-ip-data\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1209\\\/get-ip-data\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/1209\\\/get-ip-data\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get IP 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 IP 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\/powershell\/1209\/get-ip-data\/","og_locale":"en_US","og_type":"article","og_title":"Get IP Data &#8226; The Lonely Administrator","og_description":"I was doodling in PowerShell this morning and ended up with what I hope is a useful function to retrieve IP configuration information, sort of like IPCONFIG, but using WMI. The beauty is that I can connect to remote machines and the output is an object which leads to all sorts of possibilities. My function...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1209\/get-ip-data\/","og_site_name":"The Lonely Administrator","article_published_time":"2011-03-10T15:02:47+00:00","article_modified_time":"2013-06-28T12:36:26+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\/powershell\/1209\/get-ip-data\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1209\/get-ip-data\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Get IP Data","datePublished":"2011-03-10T15:02:47+00:00","dateModified":"2013-06-28T12:36:26+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1209\/get-ip-data\/"},"wordCount":228,"commentCount":10,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["functions","Get-WMIObject","NetworkAdapter","PowerShell","Scripting","WMI"],"articleSection":["PowerShell","Scripting","WMI"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/1209\/get-ip-data\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1209\/get-ip-data\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1209\/get-ip-data\/","name":"Get IP Data &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2011-03-10T15:02:47+00:00","dateModified":"2013-06-28T12:36:26+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1209\/get-ip-data\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/1209\/get-ip-data\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1209\/get-ip-data\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Get IP 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":3036,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3036\/test-64-bit-operating-system\/","url_meta":{"origin":1209,"position":0},"title":"Test 64-Bit Operating System","author":"Jeffery Hicks","date":"May 16, 2013","format":false,"excerpt":"One of the great features of PowerShell is how much you can get from a relatively simple one line command. For example. you might want to test if a computer is running a 64-bit operating system. You can find out with a command as simple as this. PS C:\\> (get-wmiobject\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"osarchitecture-fail","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/osarchitecture-fail-1024x298.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/osarchitecture-fail-1024x298.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/05\/osarchitecture-fail-1024x298.png?resize=525%2C300 1.5x"},"classes":[]},{"id":1413,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1413\/get-registry-size-and-age\/","url_meta":{"origin":1209,"position":1},"title":"Get Registry Size and Age","author":"Jeffery Hicks","date":"May 4, 2011","format":false,"excerpt":"I'm not sure why the registry has been on my mind lately. I probably need a vacation to get out more. But I put together a relatively simple Windows PowerShell function to retrieve registry statistics that you might find useful. My Get-Registry function will return information about the size of\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/05\/registry.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1562,"url":"https:\/\/jdhitsolutions.com\/blog\/wmi\/1562\/get-shared-resource\/","url_meta":{"origin":1209,"position":2},"title":"Get Shared Resource","author":"Jeffery Hicks","date":"July 12, 2011","format":false,"excerpt":"I was poking around WMI the other day in PowerShell and was intrigued by the Win32_Share class. This is a great way to find out what items are shared on a server such as printers and folders, although it's not limited to those types of resources. I thought this would\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":1532,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1532\/get-local-administrators-with-wmi-and-powershell\/","url_meta":{"origin":1209,"position":3},"title":"Get Local Administrators with WMI and PowerShell","author":"Jeffery Hicks","date":"July 1, 2011","format":false,"excerpt":"Earlier this week I was helping someone out on a problem working with the local administrators group. There are a variety of ways to enumerate the members of a local group. The code he was using involved WMI. I hadn't really worked with the WMI approach in any great detail\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":654,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/654\/new-wmi-object\/","url_meta":{"origin":1209,"position":4},"title":"New WMI Object","author":"Jeffery Hicks","date":"May 17, 2010","format":false,"excerpt":"I have one more variation on my recent theme of working with WMI objects. I wanted to come up with something flexible and re-usable where you could specify a WMI class and some properties and get a custom object with all the classes combined. My solution is a function called\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":2182,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2182\/scripting-with-pscredential\/","url_meta":{"origin":1209,"position":5},"title":"Scripting with PSCredential","author":"Jeffery Hicks","date":"April 10, 2012","format":false,"excerpt":"I see this question often: how can I pass a parameter value for a PSCredential that might be a credential object or it might be a user name? In the past I've used code like this: begin { Write-Verbose -Message \"Starting $($myinvocation.mycommand)\" write-verbose -Message \"Using volume $($volume.toUpper())\" #convert credential to\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":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1209","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=1209"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1209\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}