{"id":26,"date":"2006-03-21T11:44:00","date_gmt":"2006-03-21T15:44:00","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/2006\/03\/21\/techmentor-for-examples\/"},"modified":"2009-08-05T13:03:49","modified_gmt":"2009-08-05T17:03:49","slug":"techmentor-for-examples","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/26\/techmentor-for-examples\/","title":{"rendered":"Techmentor: FOR examples"},"content":{"rendered":"<p>The FOR command is one of the most important commands you can use as a Windows administrator.  I have a short article on the command you can download at <a href=\"http:\/\/www.jdhitsolutions.com\/tutorials.htm\">http:\/\/www.jdhitsolutions.com\/tutorials.htm<\/a> (grab the FOR Essentials link) . <\/p>\n<p>Here are few of the examples I used in the Commandline Script session. (By the way, if you'd like to see more Command line stuff at future Techmentor shows or other scripting topics, be sure to let me or Don know.)<\/p>\n<p>Assuming a text list of computer names, servers.txt and you want to do something to each computer, like ping it, you could run:<\/p>\n<p><span style=\"font-family: courier new;\">for \/f %i in (servers.txt) do @ping %i<\/span><\/p>\n<p>If you wanted to run cacls on a set of local directories you might try something like this:<\/p>\n<p><span style=\"font-family: courier new;\">for \/f \"tokens=*\" %i in ('dir \/b \/ad') do @cacls %i<\/span><\/p>\n<p>I use tokens to handle any directory names with spaces.  If you wanted to send the results to a text file, use simple redirection.  But use >> otherwise you'll only get the results from the last directory.<\/p>\n<p><span style=\"font-family: courier new;\">for \/f \"tokens=*\" %i in ('dir \/b \/ad') do @cacls %i >>results.txt<\/span><\/p>\n<p>One trick I use to do this for remote machines is to map a network drive to a file share then run cacls on the mapped drive.<\/p>\n<p><font face=\"tahoma\" size=1>Technorati Tags:<br \/><a href=\"http:\/\/www.technorati.com\/tags\/commandline\" rel=\"tag\">commandline<\/a><br \/><a href=\"http:\/\/www.technoratic.com\/tags\/scripting\" rel=\"tag\">Scripting<\/a><br \/><\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The FOR command is one of the most important commands you can use as a Windows administrator. I have a short article on the command you can download at http:\/\/www.jdhitsolutions.com\/tutorials.htm (grab the FOR Essentials link) . Here are few of the examples I used in the Commandline Script session. (By the way, if you&#8217;d like&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","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":[8,9],"tags":[20],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-scripting","category-training","tag-cli"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Techmentor: FOR examples &#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\/26\/techmentor-for-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Techmentor: FOR examples &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"The FOR command is one of the most important commands you can use as a Windows administrator. I have a short article on the command you can download at http:\/\/www.jdhitsolutions.com\/tutorials.htm (grab the FOR Essentials link) . Here are few of the examples I used in the Commandline Script session. (By the way, if you&#039;d like...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/26\/techmentor-for-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2006-03-21T15:44:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2009-08-05T17:03:49+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=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/26\\\/techmentor-for-examples\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/26\\\/techmentor-for-examples\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Techmentor: FOR examples\",\"datePublished\":\"2006-03-21T15:44:00+00:00\",\"dateModified\":\"2009-08-05T17:03:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/26\\\/techmentor-for-examples\\\/\"},\"wordCount\":228,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"CLI\"],\"articleSection\":[\"Scripting\",\"Training\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/26\\\/techmentor-for-examples\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/26\\\/techmentor-for-examples\\\/\",\"name\":\"Techmentor: FOR examples &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2006-03-21T15:44:00+00:00\",\"dateModified\":\"2009-08-05T17:03:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/26\\\/techmentor-for-examples\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/26\\\/techmentor-for-examples\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/26\\\/techmentor-for-examples\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Scripting\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/scripting\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Techmentor: FOR examples\"}]},{\"@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":"Techmentor: FOR examples &#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\/26\/techmentor-for-examples\/","og_locale":"en_US","og_type":"article","og_title":"Techmentor: FOR examples &#8226; The Lonely Administrator","og_description":"The FOR command is one of the most important commands you can use as a Windows administrator. I have a short article on the command you can download at http:\/\/www.jdhitsolutions.com\/tutorials.htm (grab the FOR Essentials link) . Here are few of the examples I used in the Commandline Script session. (By the way, if you'd like...","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/26\/techmentor-for-examples\/","og_site_name":"The Lonely Administrator","article_published_time":"2006-03-21T15:44:00+00:00","article_modified_time":"2009-08-05T17:03:49+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":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/26\/techmentor-for-examples\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/26\/techmentor-for-examples\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Techmentor: FOR examples","datePublished":"2006-03-21T15:44:00+00:00","dateModified":"2009-08-05T17:03:49+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/26\/techmentor-for-examples\/"},"wordCount":228,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["CLI"],"articleSection":["Scripting","Training"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/26\/techmentor-for-examples\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/26\/techmentor-for-examples\/","name":"Techmentor: FOR examples &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2006-03-21T15:44:00+00:00","dateModified":"2009-08-05T17:03:49+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/26\/techmentor-for-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/26\/techmentor-for-examples\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/26\/techmentor-for-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Scripting","item":"https:\/\/jdhitsolutions.com\/blog\/category\/scripting\/"},{"@type":"ListItem","position":2,"name":"Techmentor: FOR examples"}]},{"@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":20,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/20\/cli-101-for\/","url_meta":{"origin":26,"position":0},"title":"CLI 101 &#8211; FOR","author":"Jeffery Hicks","date":"February 10, 2006","format":false,"excerpt":"I've long maintained that the FOR command is one of most basic commands every administrator should know. I have a short tutorial you can download at http:\/\/www.jdhitsolutions.com\/tutorials.htmHere are some other examples on using the FOR command. Let's say you have some command line utility that will take a computer name\u2026","rel":"","context":"In &quot;Scripting&quot;","block_context":{"text":"Scripting","link":"https:\/\/jdhitsolutions.com\/blog\/category\/scripting\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/27\/techmentor-wmic-examples\/","url_meta":{"origin":26,"position":1},"title":"Techmentor: WMIC Examples","author":"Jeffery Hicks","date":"March 21, 2006","format":false,"excerpt":"I didn't get a chance to run through the WMIC examples. The Advanced VBScript book covers this topic in a little more detail. I also have a short PDF intro on WMIC you can download at http:\/\/www.jdhitsolutions.com\/tutorials.htmBefore you run any examples, you need to \"install\" WMIC. This basically means at\u2026","rel":"","context":"In &quot;Scripting&quot;","block_context":{"text":"Scripting","link":"https:\/\/jdhitsolutions.com\/blog\/category\/scripting\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":25,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/25\/techmentor-dsquery-and-dsmod-examples\/","url_meta":{"origin":26,"position":2},"title":"Techmentor: DSQuery and DSMod examples","author":"Jeffery Hicks","date":"March 21, 2006","format":false,"excerpt":"During the command line scripting session, I demonstrated how to use the directory service command line tools like dsmod, dsquery and dsget. You can get syntax help by running 'dsquery \/?' (or dsmod,dsadd,dsget). There's a lot of help information so you'll probably want to pipe the results using More (dsquery\u2026","rel":"","context":"In &quot;Scripting&quot;","block_context":{"text":"Scripting","link":"https:\/\/jdhitsolutions.com\/blog\/category\/scripting\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":12,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/12\/techmentor-2006-orlando\/","url_meta":{"origin":26,"position":3},"title":"Techmentor 2006 Orlando","author":"Jeffery Hicks","date":"January 2, 2006","format":false,"excerpt":"I will be co-teaching the Scripting track at the Orlando Techmentor conference with Don Jones (March 20-24,2006). The courses will cover topics such as command line scripting, Exchange 2003 scripting, web scripting, ADSI, WMI Virtual Server 2005 and more. If you can make it down, I hope you'll stop by\u2026","rel":"","context":"In &quot;Scripting&quot;","block_context":{"text":"Scripting","link":"https:\/\/jdhitsolutions.com\/blog\/category\/scripting\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":587,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/587\/techmentor-orlando-2010-decks-and-demos\/","url_meta":{"origin":26,"position":4},"title":"TechMentor Orlando 2010 Decks and Demos","author":"Jeffery Hicks","date":"March 15, 2010","format":false,"excerpt":"I had a great time in Orlando at the TechMentor conference. The crowd was enthusiastic and asked good questions. As promised, here are my slide decks and demos. My sessions tend to be heavy on demonstration so I can't promise you'll get a ton of value from the decks alone.\u00a0\u2026","rel":"","context":"In &quot;CommandLine&quot;","block_context":{"text":"CommandLine","link":"https:\/\/jdhitsolutions.com\/blog\/category\/commandline\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":580,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/580\/techmentor-orlando-2010\/","url_meta":{"origin":26,"position":5},"title":"TechMentor Orlando 2010","author":"Jeffery Hicks","date":"March 3, 2010","format":false,"excerpt":"I'm busy polishing my presentations and demos for next week's Techmentor conference in sunny Orlando, Fl. I've been presenting at Techmentor for a number of years now and it is a great show for administrators searching for answers to the problems and challenges they face today. You get intimate sessions\u2026","rel":"","context":"In &quot;Books&quot;","block_context":{"text":"Books","link":"https:\/\/jdhitsolutions.com\/blog\/category\/books\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/26","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=26"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}