{"id":2760,"date":"2013-01-29T09:38:24","date_gmt":"2013-01-29T14:38:24","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=2760"},"modified":"2013-01-29T09:38:24","modified_gmt":"2013-01-29T14:38:24","slug":"find-files-with-wmi-and-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/","title":{"rendered":"Find Files with WMI and PowerShell"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/magnifying-glass-text-label-search.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/magnifying-glass-text-label-search-150x150.jpg\" alt=\"magnifying-glass-text-label-search\" width=\"150\" height=\"150\" class=\"alignleft size-thumbnail wp-image-2761\" \/><\/a>Finding files is one of those necessary evils for IT Pros. Sometimes we're searching for a needle in a haystack. And it gets even more complicated when the haystacks are on 10 or 100 or 1000 remote computers. You might think using Get-ChildItem is your only option. Certainly it works, but if you are searching an entire hard drive it is pretty resource intensive. <\/p>\n<p>Another option is to use WMI and CIM_Datafile class. Don't let the name fool you. You can use Get-WmiObject in PowerShell 2.0 or 3.0. Every file, as far as I know, is also registered with WMI so all you need to do is query for all instances of the CIM_Datafile class. However, you must be clever. Just like searching an entire drive, searching via WMI can be time consuming. So you need to make your WMI query as specific as possible. To do that you need to know the properties. Here's what a CIM_Datafile object looks like.<\/p>\n<p><code><\/p>\n<p>Status                : OK<br \/>\nName                  : c:\\program files (x86)\\windows defender\\mpclient.dll<br \/>\n__GENUS               : 2<br \/>\n__CLASS               : CIM_DataFile<br \/>\n__SUPERCLASS          : CIM_LogicalFile<br \/>\n__DYNASTY             : CIM_ManagedSystemElement<br \/>\n__RELPATH             : CIM_DataFile.Name=\"c:\\\\program files (x86)\\\\windows defender\\\\mpclient.dll\"<br \/>\n__PROPERTY_COUNT      : 33<br \/>\n__DERIVATION          : {CIM_LogicalFile, CIM_LogicalElement, CIM_ManagedSystemElement}<br \/>\n__SERVER              : SERENITY<br \/>\n__NAMESPACE           : root\\cimv2<br \/>\n__PATH                : \\\\SERENITY\\root\\cimv2:CIM_DataFile.Name=\"c:\\\\program files (x86)\\\\windows d<br \/>\n                        efender\\\\mpclient.dll\"<br \/>\nAccessMask            : 17957033<br \/>\nArchive               : True<br \/>\nCaption               : c:\\program files (x86)\\windows defender\\mpclient.dll<br \/>\nCompressed            : False<br \/>\nCompressionMethod     :<br \/>\nCreationClassName     : CIM_LogicalFile<br \/>\nCreationDate          : 20120725214205.814611-240<br \/>\nCSCreationClassName   : Win32_ComputerSystem<br \/>\nCSName                : SERENITY<br \/>\nDescription           : c:\\program files (x86)\\windows defender\\mpclient.dll<br \/>\nDrive                 : c:<br \/>\nEightDotThreeFileName : c:\\program files (x86)\\windows defender\\mpclient.dll<br \/>\nEncrypted             : False<br \/>\nEncryptionMethod      :<br \/>\nExtension             : dll<br \/>\nFileName              : mpclient<br \/>\nFileSize              : 662016<br \/>\nFileType              : Application Extension<br \/>\nFSCreationClassName   : Win32_FileSystem<br \/>\nFSName                : NTFS<br \/>\nHidden                : False<br \/>\nInstallDate           : 20120725214205.814611-240<br \/>\nInUseCount            :<br \/>\nLastAccessed          : 20120725214205.814611-240<br \/>\nLastModified          : 20120725231905.556000-240<br \/>\nManufacturer          : Microsoft Corporation<br \/>\nPath                  : \\program files (x86)\\windows defender\\<br \/>\nReadable              : True<br \/>\nSystem                : False<br \/>\nVersion               : 4.0.9200.16384<br \/>\nWriteable             : True<br \/>\nScope                 : System.Management.ManagementScope<br \/>\nOptions               : System.Management.ObjectGetOptions<br \/>\nClassPath             : \\\\SERENITY\\root\\cimv2:CIM_DataFile<br \/>\nProperties            : {AccessMask, Archive, Caption, Compressed...}<br \/>\nSystemProperties      : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY...}<br \/>\nQualifiers            : {dynamic, Locale, provider, UUID}<br \/>\nSite                  :<br \/>\nContainer             :<br \/>\n<\/code><\/p>\n<p>At a minimum you should limit your query to the drive. Otherwise the WMI query will search ALL drives. If you are searching by path, description or caption, don't forget that the \\ character needs to be escaped, e.g. \\\\program files (x86)\\\\windows defender\\\\. Of course if you know that much already you might as well use Get-Childitem.  <\/p>\n<p>For me, the real benefit in using WMI is when I know the file name but don't know for sure where it might be on a given drive. So I put together an advanced function called Get-CIMFile.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\nFunction Get-CIMFile {<br \/>\n#comment based help is here<\/p>\n<p>[cmdletbinding()]<br \/>\nParam(<br \/>\n[Parameter(Position=0,Mandatory=$True,HelpMessage=\"What is the name of the file?\")]<br \/>\n[ValidateNotNullorEmpty()]<br \/>\n[alias(\"file\")]<br \/>\n[string]$Name,<br \/>\n[ValidateNotNullorEmpty()]<br \/>\n[string]$Drive=\"C:\",<br \/>\n[ValidateNotNullorEmpty()]<br \/>\n[string[]]$Computername=$env:computername,<br \/>\n[switch]$AsJob<br \/>\n)<\/p>\n<p><#\n strip off any trailing characters to drive parameter \n that might have been passed.\n#><br \/>\nIf ($Drive.Length -gt 2) {<br \/>\n    $Drive=$Drive.Substring(0,2)<br \/>\n}<\/p>\n<p>Write-Verbose \"Searching for $Name on Drive $Drive on computer $Computername.\"<\/p>\n<p><#\nNormally you might think to simply split the name on the . character. But\nyou might have a filename like myfile.v2.dll so that won't work. In a case \nlike this the extension would be everything after the last . and the filename\neverything before.\n\nSo instead I'll use the substring method to \"split\" the filename string.\n#><\/p>\n<p>#get the index of the last .<br \/>\n$index = $name.LastIndexOf(\".\")<br \/>\n#get the first part of the name<br \/>\n$filename=$Name.Substring(0,$index)<br \/>\n#get the last part of the name<br \/>\n$extension=$name.Substring($index+1)<\/p>\n<p>$filter = \"Filename='$filename' AND extension='$extension' AND Drive='$drive'\"<br \/>\nWrite-Verbose $filter<\/p>\n<p>#get all instances of the file and write the WMI object to the pipeline<br \/>\nGet-WmiObject -Class CIM_Datafile -Filter $filter -ComputerName $Computername -Asjob:$AsJob<\/p>\n<p>} #end Get-CIMFile<br \/>\n<\/code><\/p>\n<p>The code is documented to explain what is going on so I won't repeat it here. The function will work anywhere you have WMI access. This version doesn't handle alternate credentials or other features of Get-WmiObject, which you could add if you want. But with this I can check files on multiple computers. Suppose I'm concerned about a vulnerability like the recent Java problem. Or I need to see if any computers are out of date on a given file. I can run a command like this.<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS Scripts:\\> $files = get-cimfile mpclient.dll -comp serenity,novo8<br \/>\nPS Scripts:\\> $files | Sort name,CSName | Select Name,Version,CSName<\/p>\n<p>Name                              Version                          CSName<br \/>\n----                              -------                          ------<br \/>\nc:\\program files (x86)\\windows... 4.0.9200.16384                   SERENITY<br \/>\nc:\\program files\\windows defen... 4.0.9200.16384                   NOVO8<br \/>\nc:\\program files\\windows defen... 4.0.9200.16384                   SERENITY<br \/>\nc:\\windows\\winsxs\\amd64_window... 4.0.9200.16384                   SERENITY<br \/>\nc:\\windows\\winsxs\\wow64_window... 4.0.9200.16384                   SERENITY<br \/>\nc:\\windows\\winsxs\\x86_windows-... 4.0.9200.16384                   NOVO8<br \/>\n<\/code><\/p>\n<p>The command writes the full WMI object to the pipeline so I could filter or format $files however I need.<\/p>\n<p>Download <a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/Get-CIMFile.txt\" target=\"_blank\">Get-CIMFile<\/a> and let me know what you think.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Finding files is one of those necessary evils for IT Pros. Sometimes we&#8217;re searching for a needle in a haystack. And it gets even more complicated when the haystacks are on 10 or 100 or 1000 remote computers. You might think using Get-ChildItem is your only option. Certainly it works, but if you are searching&#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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[8,62,19],"tags":[324,224,103,534,540,547],"class_list":["post-2760","post","type-post","status-publish","format-standard","hentry","category-scripting","category-security","category-wmi","tag-cim_datafile","tag-function","tag-get-wmiobject","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>Find Files with WMI and PowerShell &#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\/2760\/find-files-with-wmi-and-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Find Files with WMI and PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Finding files is one of those necessary evils for IT Pros. Sometimes we&#039;re searching for a needle in a haystack. And it gets even more complicated when the haystacks are on 10 or 100 or 1000 remote computers. You might think using Get-ChildItem is your only option. Certainly it works, but if you are searching...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2013-01-29T14:38:24+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/magnifying-glass-text-label-search-150x150.jpg\" \/>\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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2760\\\/find-files-with-wmi-and-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2760\\\/find-files-with-wmi-and-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Find Files with WMI and PowerShell\",\"datePublished\":\"2013-01-29T14:38:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2760\\\/find-files-with-wmi-and-powershell\\\/\"},\"wordCount\":384,\"commentCount\":12,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2760\\\/find-files-with-wmi-and-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/01\\\/magnifying-glass-text-label-search-150x150.jpg\",\"keywords\":[\"CIM_DATAFILE\",\"Function\",\"Get-WMIObject\",\"PowerShell\",\"Scripting\",\"WMI\"],\"articleSection\":[\"Scripting\",\"security\",\"WMI\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2760\\\/find-files-with-wmi-and-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2760\\\/find-files-with-wmi-and-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2760\\\/find-files-with-wmi-and-powershell\\\/\",\"name\":\"Find Files with WMI and PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2760\\\/find-files-with-wmi-and-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2760\\\/find-files-with-wmi-and-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/01\\\/magnifying-glass-text-label-search-150x150.jpg\",\"datePublished\":\"2013-01-29T14:38:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2760\\\/find-files-with-wmi-and-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2760\\\/find-files-with-wmi-and-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2760\\\/find-files-with-wmi-and-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/01\\\/magnifying-glass-text-label-search.jpg\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/01\\\/magnifying-glass-text-label-search.jpg\",\"width\":480,\"height\":407},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2760\\\/find-files-with-wmi-and-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Scripting\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/scripting\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Find Files with WMI and PowerShell\"}]},{\"@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":"Find Files with WMI and PowerShell &#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\/2760\/find-files-with-wmi-and-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Find Files with WMI and PowerShell &#8226; The Lonely Administrator","og_description":"Finding files is one of those necessary evils for IT Pros. Sometimes we're searching for a needle in a haystack. And it gets even more complicated when the haystacks are on 10 or 100 or 1000 remote computers. You might think using Get-ChildItem is your only option. Certainly it works, but if you are searching...","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2013-01-29T14:38:24+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/magnifying-glass-text-label-search-150x150.jpg","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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Find Files with WMI and PowerShell","datePublished":"2013-01-29T14:38:24+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/"},"wordCount":384,"commentCount":12,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/magnifying-glass-text-label-search-150x150.jpg","keywords":["CIM_DATAFILE","Function","Get-WMIObject","PowerShell","Scripting","WMI"],"articleSection":["Scripting","security","WMI"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/","name":"Find Files with WMI and PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/magnifying-glass-text-label-search-150x150.jpg","datePublished":"2013-01-29T14:38:24+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/magnifying-glass-text-label-search.jpg","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/magnifying-glass-text-label-search.jpg","width":480,"height":407},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2760\/find-files-with-wmi-and-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Scripting","item":"https:\/\/jdhitsolutions.com\/blog\/category\/scripting\/"},{"@type":"ListItem","position":2,"name":"Find Files with WMI and PowerShell"}]},{"@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":2773,"url":"https:\/\/jdhitsolutions.com\/blog\/wmi\/2773\/find-files-with-wmi-and-powershell-revisited\/","url_meta":{"origin":2760,"position":0},"title":"Find Files with WMI and PowerShell Revisited","author":"Jeffery Hicks","date":"February 4, 2013","format":false,"excerpt":"Last week I posted a PowerShell function to find files using WMI. One of the comments I got was about finding files with wildcards. In WMI, we've been able to search via wildcards and the LIKE operator since the days of XP. In a WMI query we use the %\u2026","rel":"","context":"In &quot;WMI&quot;","block_context":{"text":"WMI","link":"https:\/\/jdhitsolutions.com\/blog\/category\/wmi\/"},"img":{"alt_text":"computereye","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/computereye-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3555,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3555\/get-powershell-version-with-wmi\/","url_meta":{"origin":2760,"position":1},"title":"Get PowerShell Version with WMI","author":"Jeffery Hicks","date":"November 13, 2013","format":false,"excerpt":"With the release of PowerShell 4.0, it is possible you might end up with a mix of systems in your environment. I know I do because I do a lot of writing, testing and development that requires multiple versions in my test network. Recently I was doing some Group Policy\u2026","rel":"","context":"In &quot;Group Policy&quot;","block_context":{"text":"Group Policy","link":"https:\/\/jdhitsolutions.com\/blog\/category\/group-policy\/"},"img":{"alt_text":"get-wmipshell","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/get-wmipshell-1024x244.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/get-wmipshell-1024x244.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/11\/get-wmipshell-1024x244.png?resize=525%2C300 1.5x"},"classes":[]},{"id":1667,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1667\/compress-files-by-extension\/","url_meta":{"origin":2760,"position":2},"title":"Compress Files By Extension","author":"Jeffery Hicks","date":"October 3, 2011","format":false,"excerpt":"I never seem to build my test virtual machines with enough disk space. Which means at some point I start dealing with space issues and resort to all sorts of hacks to buy myself a little time. One thing I do is look for files that I can compact using\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\/10\/compress-filetype-300x212.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":530,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/530\/putting-the-squeeze-on-files-with-powershell\/","url_meta":{"origin":2760,"position":3},"title":"Putting the Squeeze on Files with PowerShell","author":"Jeffery Hicks","date":"December 9, 2009","format":false,"excerpt":"My December Mr. Roboto column is now online This month\u2019s tool is a PowerShell WinForm script that uses WMI to compress files. I used PrimalForms 2009 to build the graphical interface. The interface is essentially a wizard that lets you build a WMI query to find files and compress them.\u00a0\u2026","rel":"","context":"In &quot;Mr. Roboto&quot;","block_context":{"text":"Mr. Roboto","link":"https:\/\/jdhitsolutions.com\/blog\/category\/mr-roboto\/"},"img":{"alt_text":"captured_Image.png","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/12\/captured_Image.png_thumb.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2781,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2781\/find-files-with-powershell-3-0\/","url_meta":{"origin":2760,"position":4},"title":"Find Files with PowerShell 3.0","author":"Jeffery Hicks","date":"February 7, 2013","format":false,"excerpt":"My last few articles have looked at using WMI and CIM_DATAFILE class to find files, primarily using Get-WmiObject in PowerShell. But now that we have PowerShell 3.0 at our disposal, we can use the new CIM cmdlets. So I took my most recent version of Get-CIMFile and revised it specifically\u2026","rel":"","context":"In &quot;Powershell 3.0&quot;","block_context":{"text":"Powershell 3.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-3-0\/"},"img":{"alt_text":"get-cimfile3","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/02\/get-cimfile3-1024x703.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/02\/get-cimfile3-1024x703.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/02\/get-cimfile3-1024x703.png?resize=525%2C300 1.5x"},"classes":[]},{"id":7992,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7992\/answering-the-cim-directory-challenge\/","url_meta":{"origin":2760,"position":5},"title":"Answering the CIM Directory Challenge","author":"Jeffery Hicks","date":"January 8, 2021","format":false,"excerpt":"The last Iron Scripter challenge of 2020 was a big one. If you didn't get a chance to work on it, see what you can come up with then come back to see my approach. As with many of the challenges, the goal isn't to produce a production-ready PowerShell tool,\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\/2021\/01\/win32_directory.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/win32_directory.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/win32_directory.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/win32_directory.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/win32_directory.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/win32_directory.png?resize=1400%2C800&ssl=1 4x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2760","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=2760"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2760\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}