{"id":17848,"date":"2008-12-02T11:22:39","date_gmt":"2008-12-02T19:22:39","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/powershell\/?p=17848"},"modified":"2019-06-07T11:29:22","modified_gmt":"2019-06-07T19:29:22","slug":"get-everyone","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/get-everyone\/","title":{"rendered":"Get-Everyone"},"content":{"rendered":"<p><P>Jeffery Snover just posted a <A href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/2008\/12\/02\/get-me-ps1.aspx\" mce_href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/2008\/12\/02\/get-me-ps1.aspx\">Get-Me script<\/A>.&nbsp; The Get-Me script finds out the principal of the user running PowerShell.&nbsp; In case you ever wanted to know how to get all of the users on a machine (or from a domain), here&#8217;s a quick function that queries WMI for users.<\/P><I>\n<BLOCKQUOTE><PRE class=CmdletDefinition>function Get-Everyone([switch]$fromDomain) {\n    #.Synopsis\n    #   Gets all users\n    #.Description\n    #   Queries WMI to get all users.  To save time, queries\n    #   are local unless the -fromDomain switch is used\n    #.Parameter fromDomain\n    #   If set, gets domain users as well as local accounts\n    #.Example\n    #   # Get All Local Accounts\n    #   Get-Everyone\n    #.Example\n    #   # Get All Local &amp; Domain Accounts\n    #   Get-Everyone -fromDomain\n    $query = &#8220;Win32_UserAccount&#8221;\n    if (-not $fromDomain) {\n        $query+= &#8221; WHERE LocalAccount=&#8217;True'&#8221;\n    }\n    Get-WmiObject $query\n}<\/PRE><\/BLOCKQUOTE><\/I>\n<P>All of the comments are an example of comment-based help, which is feature of PowerShell that is available in CTP3 and Window 7 Betas (when they are out).<\/P>\n<P>This means that I can embed examples within a function, as I did above.<\/P><PRE># Get All Local Accounts\nGet-Everyone<\/p>\n<p># Get All Local &amp; Domain Accounts\nGet-Everyone -fromDomain<\/PRE>\n<P>Hope this helps,<\/P>\n<P>James Brundage [MSFT]<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Jeffery Snover just posted a Get-Me script.&nbsp; The Get-Me script finds out the principal of the user running PowerShell.&nbsp; In case you ever wanted to know how to get all of the users on a machine (or from a domain), here&#8217;s a quick function that queries WMI for users. function Get-Everyone([switch]$fromDomain) { #.Synopsis # Gets [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[172],"class_list":["post-17848","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-get-everyone"],"acf":[],"blog_post_summary":"<p>Jeffery Snover just posted a Get-Me script.&nbsp; The Get-Me script finds out the principal of the user running PowerShell.&nbsp; In case you ever wanted to know how to get all of the users on a machine (or from a domain), here&#8217;s a quick function that queries WMI for users. function Get-Everyone([switch]$fromDomain) { #.Synopsis # Gets [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=17848"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17848\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=17848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=17848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=17848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}