{"id":2684,"date":"2013-10-23T00:01:00","date_gmt":"2013-10-23T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/10\/23\/use-powershell-to-explore-windows-defender-preferences\/"},"modified":"2013-10-23T00:01:00","modified_gmt":"2013-10-23T00:01:00","slug":"use-powershell-to-explore-windows-defender-preferences","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-powershell-to-explore-windows-defender-preferences\/","title":{"rendered":"Use PowerShell to Explore Windows Defender Preferences"},"content":{"rendered":"<p><strong>Summary<\/strong>: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell&nbsp;4.0 in Windows&nbsp;8.1 to explore Windows Defender preferences.<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. Well things are certainly shaping up to be exciting. Last weekend, I upgraded my Surface Pro to Windows&nbsp;8.1 via the store. It took about 30 minutes, and it was absolutely painless. The long part was downloading the 3&nbsp;GB file. Then it started the installation, and I had to agree with the license statement. Finally, it wanted to know how to personalize the device. Besides that, it was gravy.<\/p>\n<p>The Scripting Wife and I are getting ready to go to Atlanta this weekend for the <a href=\"http:\/\/powershellsaturday.com\/005\/\" target=\"_blank\">PowerShell Saturday 005 event<\/a>. I am making two presentations, and there are several other awesome speakers who will be there. There are still some tickets available for this event, so it is not too late to sign up. I know there are some people who are driving to the event from as far away as Texas, so it will be a great time to see some of your favorite Windows PowerShell people. Check it out, you will be glad you did.<\/p>\n<p>Because Windows&nbsp;8.1 is now in general availability, I thought I would take some time to write about one of the cool new modules. I am running Windows PowerShell&nbsp;4.0 on Windows&nbsp;8.1.<\/p>\n<p style=\"padding-left: 30px\"><strong>Note&nbsp;&nbsp;<\/strong>This is the second post in a three-part series about the Windows Defender module in Windows&nbsp;8.1. For basic information about the Windows Defender module, please see <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/10\/22\/exploring-the-windows-defender-catalog.aspx\" target=\"_blank\">Exploring the Windows Defender Catalog<\/a>.<\/p>\n<p>One of the cool things about Windows PowerShell is that it always (at least nearly always) works the same. This means that I can use the <strong>Get-Help<\/strong> cmdlet to find out how to use a cmdlet or CIM function. I can use the <strong>Help<\/strong> function, to see Help information one page at a time. It does not matter what the module, or what the cmdlet.<\/p>\n<p>But with most of the <strong>Get*<\/strong> type of cmdlets and functions, I do not even need to use Help. I can simply type the cmdlet (or function) name, and voila, it spews forth data&mdash;at least that is the way that well designed cmdlets generally behave. I should not have to look at Help to find out how to get information.<\/p>\n<p style=\"padding-left: 30px\"><strong>Note<\/strong>&nbsp;&nbsp;The Windows Defender commands are technically functions. They are CIM wrapped, based on a new WMI namespace that is added to Windows&nbsp;8.1. I will refer to them as functions, or occasionally as a command. But I will not call them cmdlets (unless I slip up and make a mistake) because they are not technically cmdlets. Using <strong>Get-Member<\/strong> or <strong>Get-Command<\/strong> easily reveals this information.<\/p>\n<p>I can use the <strong>Get-MpPreference<\/strong> cmdlet to obtain information about my Windows Defender preference settings. The command and the output associated with the command are shown here.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0777.HSG-10-23-13-01.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0777.HSG-10-23-13-01.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>The bad thing is that some of the output does not make sense. For example, the value of the <strong>ScanScheduleDay<\/strong> is 0. What does that mean? Is it Sunday, or Monday, or whatever? I know that &ldquo;computer numbers&rdquo; often begin with 0 instead of 1, so I guess that maybe it means scan on the first day of the week. So I use the <strong>Get-Culture<\/strong> cmdlet and I look at the <strong>DateTimeFormat<\/strong><em> <\/em>property to see what the first day of the week is. The command and output are shown here.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4188.HSG-10-23-13-02.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4188.HSG-10-23-13-02.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>I can see that the value of the <strong>FirstDayOfWeek<\/strong> property from the <strong>DateTimeFormat<\/strong> object is Sunday. So, I guess that my <strong>ScanScheduleDay<\/strong> value of 0 is Sunday. But that is just a guess. I would like to make sure. So I check the value of <strong>Get-Help<\/strong> to see if there is any Help here.<\/p>\n<p>I use the command <strong>Get-Help Get-MpPreference &ndash;full<\/strong>, and I obtain the following output:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2514.HSG-10-23-13-03.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2514.HSG-10-23-13-03.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>I can tell you that in this case, the Help is no help. Then it dawns on me. Wait! In reality, this is WMI. Hey, it is a CIM function, which means that under the covers, there is bound to be a WMI class. Groovy. On MSDN, most WMI classes are well documented.<\/p>\n<p>However, searching for &ldquo;Windows PowerShell Help&rdquo; in this case does not help. This is because, as I found, all it does is document the way Windows PowerShell works&mdash;and well, duh, I know HOW Windows PowerShell works. I need to know what the output means.<\/p>\n<p>So I need to look up WMI. I type a Bing query for &ldquo;PowerShell Defender ScanScheduleDay&rdquo; and I get back nothing worthwhile. I do the same search on MSDN. Again, I get no hits. Hmmm&hellip;time to go &ldquo;old school&rdquo; on this issue.<\/p>\n<p>So I pipe the results from the <strong>Get-MpPreference<\/strong> function to <strong>Get-Member<\/strong>, and I look at the object that returns. Ahhhhh&hellip;now I can see some sense. The command and output are shown in the image that follows.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3632.HSG-10-23-13-04.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3632.HSG-10-23-13-04.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>So I now search for &ldquo;MSFT_MpPreference&rdquo; directly on MSDN, and I discover that <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dn439477(v=vs.85).aspx\" target=\"_blank\">Windows Defender WMIv2 APIs<\/a> is documented. The page on MSDN lists all of the WMI classes. Sweet!<\/p>\n<p>As it turns out, it was a good thing I looked up the answer because 0 is not Sunday. Sunday, as it turns out, is 1. The MSDN portion is shown here.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7875.HSG-10-23-13-05.png\"><img decoding=\"async\" title=\"Image of webpage\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7875.HSG-10-23-13-05.png\" alt=\"Image of webpage\" \/><\/a><\/p>\n<p>So, that is it. I am able to discover the information I need to bring clarity the output.<\/p>\n<p>That is all there is to using the Windows Defender module. Join me tomorrow when I will talk about using the Windows Defender functions to initiate scans and to update the files.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><strong>Ed Wilson, Microsoft Scripting Guy<\/strong>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell&nbsp;4.0 in Windows&nbsp;8.1 to explore Windows Defender preferences. Microsoft Scripting Guy, Ed Wilson, is here. Well things are certainly shaping up to be exciting. Last weekend, I upgraded my Surface Pro to Windows&nbsp;8.1 via the store. It took about 30 minutes, and it was absolutely [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[459,462,3,63,461,45],"class_list":["post-2684","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-defender","tag-powershell-4-0","tag-scripting-guy","tag-security","tag-windows-8-1","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell&nbsp;4.0 in Windows&nbsp;8.1 to explore Windows Defender preferences. Microsoft Scripting Guy, Ed Wilson, is here. Well things are certainly shaping up to be exciting. Last weekend, I upgraded my Surface Pro to Windows&nbsp;8.1 via the store. It took about 30 minutes, and it was absolutely [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2684","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=2684"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2684\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=2684"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2684"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}