{"id":108,"date":"2007-04-11T11:00:00","date_gmt":"2007-04-11T19:00:00","guid":{"rendered":"http:\/\/testblog.sapien.com\/index.php\/2007\/04\/11\/i-can-name-that-os-in-one-note\/"},"modified":"2007-04-11T11:00:00","modified_gmt":"2007-04-11T19:00:00","slug":"i-can-name-that-os-in-one-note","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2007\/04\/11\/i-can-name-that-os-in-one-note\/","title":{"rendered":"I can name that OS in one note"},"content":{"rendered":"<p>At the recent <a class=\"offsite-link-inline\" href=\"http:\/\/techmentorevents.com\/\" target=\"_blank\">Techmentor <\/a>conference in Orlando, I did a few (popular) sessions on using automating with batch files and using the command line. One tool I talked about was WMIC, or the WMI command line interface. This is available on Windows XP and later.&nbsp; With this tool you can use WMI without having to know scripting or much about WMI. In fact, I can give you some WMIC commands to run that might be very helpful in your batch files.<\/p>\n<p>First, if you&#8217;ve never used WMIC, open a command prompt and type: WMIC<\/p>\n<p>You should get a&nbsp; brief installation message followed by a WMIC prompt.&nbsp; You can type exit to return to the command prompt. WMIC has an interactive mode like NSLOOKUP or you can access it directly from the command line.<\/p>\n<p>Today I&#8217;ll give you an expression to return the current operating system and service pack on a given computer.<\/p>\n<p>First, run this command to see your local system:<\/p>\n<p><font style=\"color: #0000ff\" face=\"Lucida Console\" color=\"#0000ff\" size=\"2\">C:\\&gt; wmic os get caption,csdversion | find \/i \/v &#8220;Caption&#8221;<\/font><\/p>\n<p>This will return something like:<\/p>\n<p>Microsoft Windows XP Professional Service Pack 2<\/p>\n<p>To check a remote system use a command like this:<\/p>\n<p><font style=\"color: #0000ff\" face=\"Lucida Console\" color=\"#0000ff\" size=\"2\">C:\\&gt; wmic \/node:&#8221;JDH-DC01&#8221; os get caption,csdversion | find \/i \/v &#8220;Caption&#8221;<\/font><\/p>\n<p>If the computer name has a dash in the name, enclose it in &#8220;&#8221; as I did here. Since we&#8217;re talking about WMI, what about alternate credentials:<\/p>\n<p><font style=\"color: #0000ff\" face=\"Lucida Console\" color=\"#0000ff\" size=\"2\">C:\\&gt; wmic \/node:&#8221;JDH-DC01&#8221; \/user:domain\\admin \/password:MyP@$$ os get caption,csdversion | find \/i \/v &#8220;Caption&#8221;<\/font><\/p>\n<p>If the password has any special characters be sure to enclose it in quotes.<\/p>\n<p>Finally, if you want to check several machines, you can either specify the computer names like this:<\/p>\n<p><font style=\"color: #0000ff\" face=\"Lucida Console\" color=\"#0000ff\" size=\"2\">C:\\&gt; wmic \/node:&#8221;jdh-dc01&#8221;,godot,dogtoy os get csname,caption,csdversion | find \/i \/v &#8220;Caption&#8221;<\/font><\/p>\n<p>Or tell WMIC to use a text file of computernames:<\/p>\n<p><font style=\"color: #0000ff\" face=\"Lucida Console\" color=\"#0000ff\" size=\"2\">C:\\&gt; wmic \/node:@servers.txt os get csname,caption,csdversion | find \/i \/v &#8220;Caption&#8221;<\/font><\/p>\n<p>I&#8217;ve added the CSNAME property so you get the computername as well. Otherwise, you might not be able to tell what OS goes with which computer.<\/p>\n<p>That&#8217;s all for now.&nbsp; I&#8217;ve just scratched the surface here. What do you think? Can you incorporate any of this into your batch files?&nbsp; What would like to be able to do with this?<\/p>\n<div class=\"wlWriterSmartContent\" id=\"0767317B-992E-4b12-91E0-4F059A8CECA8:1db77079-53ff-4590-a11e-08b6a0cea3ba\" style=\"padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px\"><span class=\"sizeLess20\">Technorati tags: <\/span><a href=\"http:\/\/technorati.com\/tags\/WMI\" rel=\"tag\"><span class=\"sizeLess20\">WMI<\/span><\/a><span class=\"sizeLess20\">, <\/span><a href=\"http:\/\/technorati.com\/tags\/WMIC\" rel=\"tag\"><span class=\"sizeLess20\">WMIC<\/span><\/a><span class=\"sizeLess20\">, <\/span><a href=\"http:\/\/technorati.com\/tags\/Scripting\" rel=\"tag\"><span class=\"sizeLess20\">Scripting<\/span><\/a><span class=\"sizeLess20\">, <\/span><a href=\"http:\/\/technorati.com\/tags\/Commandline\" rel=\"tag\"><span class=\"sizeLess20\">Commandline<\/span><\/a><span class=\"sizeLess20\">, <\/span><a href=\"http:\/\/technorati.com\/tags\/Windows\" rel=\"tag\"><span class=\"sizeLess20\">Windows<\/span><\/a><span class=\"sizeLess20\">, <\/span><a href=\"http:\/\/technorati.com\/tags\/CLI\" rel=\"tag\"><span class=\"sizeLess20\">CLI<\/span><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>At the recent Techmentor conference in Orlando, I did a few (popular) sessions on using automating with batch files and using the command line. One tool I talked about was WMIC, or the WMI command line interface. This is available on Windows XP and later.  With this tool you can use WMI without having to know scripting or much about WMI. In fact, I can give you some WMIC commands to run that might be very helpful in your batch files.<\/p>\n","protected":false},"author":3,"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,"footnotes":""},"categories":[18],"tags":[],"class_list":["post-108","post","type-post","status-publish","format-standard","hentry","category-batchcmd"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":0,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/108\/revisions"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}