<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en_GB"><generator uri="https://jekyllrb.com/" version="3.9.2">Jekyll</generator><link href="https://bertlandh.github.io/computer_life_support/feed.xml" rel="self" type="application/atom+xml" /><link href="https://bertlandh.github.io/computer_life_support/" rel="alternate" type="text/html" hreflang="en_GB" /><updated>2022-09-16T02:15:52+00:00</updated><id>https://bertlandh.github.io/computer_life_support/feed.xml</id><title type="html">Bertland Hope</title><subtitle>Professional website
</subtitle><author><name>{&quot;twitter&quot;=&gt;&quot;bertlandhope&quot;}</name></author><entry><title type="html">Clean old spooled documents.</title><link href="https://bertlandh.github.io/computer_life_support/2022/09/15/clean-old-spooled-documents/" rel="alternate" type="text/html" title="Clean old spooled documents." /><published>2022-09-15T16:30:00+00:00</published><updated>2022-09-15T16:30:00+00:00</updated><id>https://bertlandh.github.io/computer_life_support/2022/09/15/clean-old-spooled-documents</id><content type="html" xml:base="https://bertlandh.github.io/computer_life_support/2022/09/15/clean-old-spooled-documents/">&lt;h2 id=&quot;requirements&quot;&gt;Requirements:&lt;/h2&gt;
&lt;p&gt;Must run as administrator&lt;/p&gt;

&lt;h2 id=&quot;batch-file-execution&quot;&gt;Batch File Execution&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-dos&quot;&gt;echo Stopping print spooler.
echo.
net stop spooler
echo Deleting old print jobs...
echo.
FOR %%i IN (%systemroot%\system32\spool\printers\*.*) DO DEL %%i
echo Starting print spooler.
echo.
net start spooler
&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&quot;powershell-execution&quot;&gt;PowerShell Execution&lt;/h2&gt;
&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$Date&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Get-Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;AddHours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Stop-Service&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;spooler&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Sleep&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Get-ChildItem&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Path&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;C:\Windows\System32\spool\PRINTERS&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Where-Object&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;$_&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;LastWriteTime&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-lt&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$Date&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Remove-Item&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Verbose&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Start-Service&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;spooler&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Bertland Hope</name></author><summary type="html">Requirements: Must run as administrator</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bertlandh.github.io/computer_life_support/img/2022-09-15-clean-old-spooled-documents-475-1200x800.jpg" /><media:content medium="image" url="https://bertlandh.github.io/computer_life_support/img/2022-09-15-clean-old-spooled-documents-475-1200x800.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Active Directory One-Liners</title><link href="https://bertlandh.github.io/computer_life_support/2022/09/14/active-directory-one-liners/" rel="alternate" type="text/html" title="Active Directory One-Liners" /><published>2022-09-14T16:30:00+00:00</published><updated>2022-09-14T16:30:00+00:00</updated><id>https://bertlandh.github.io/computer_life_support/2022/09/14/active-directory-one-liners</id><content type="html" xml:base="https://bertlandh.github.io/computer_life_support/2022/09/14/active-directory-one-liners/">&lt;h2 id=&quot;fsmo-roles&quot;&gt;FSMO Roles&lt;/h2&gt;
&lt;p&gt;ntdsutilroles Connections “Connect to server %logonserver%” Quit “selectOperation Target” “List roles for conn server” Quit Quit Quit
[JDH: This is really a series of steps, not a single command
expression]&lt;/p&gt;

&lt;h2 id=&quot;domain-controllers&quot;&gt;Domain Controllers&lt;/h2&gt;
&lt;p&gt;Nltest /dclist:%userdnsdomain%&lt;/p&gt;

&lt;h2 id=&quot;domain-controller-ip-configuration&quot;&gt;Domain Controller IP Configuration&lt;/h2&gt;
&lt;p&gt;for /f %i in (‘dsquery server -domain %userdnsdomain% -o rdn’) do psexec \%i ipconfig /all&lt;/p&gt;

&lt;h2 id=&quot;stale-computer-accounts&quot;&gt;Stale computer accounts&lt;/h2&gt;
&lt;p&gt;dsquery computer domainroot -stalepwd 180 -limit 0&lt;/p&gt;

&lt;h2 id=&quot;stale-user-accounts&quot;&gt;Stale user accounts&lt;/h2&gt;
&lt;p&gt;dsquery user domainroot -stalepwd 180 -limit 0&lt;/p&gt;

&lt;h2 id=&quot;disabled-user-accounts&quot;&gt;Disabled user accounts&lt;/h2&gt;
&lt;p&gt;dsquery user domainroot -disabled -limit 0&lt;/p&gt;

&lt;h2 id=&quot;ad-database-disk-usage&quot;&gt;AD Database disk usage&lt;/h2&gt;
&lt;p&gt;for /f %i in (‘dsquery server -domain %userdnsdomain% -o rdn’) do dir \%i\admin$\ntds&lt;/p&gt;

&lt;h2 id=&quot;global-catalog-servers-from-dns&quot;&gt;Global Catalog Servers from DNS&lt;/h2&gt;
&lt;p&gt;dnscmd %logonserver% /enumrecords %userdnsdomain% _tcp | find /i “3268”&lt;/p&gt;

&lt;h2 id=&quot;global-catalog-servers-from-ad&quot;&gt;Global Catalog Servers from AD&lt;/h2&gt;
&lt;p&gt;dsquery * “CN=Configuration,DC=forestRootDomain” -filter “(&amp;amp;(objectCategory=nTDSDSA)(options:1.2.840.113556.1.4.803:=1))”&lt;/p&gt;

&lt;h2 id=&quot;users-with-no-logon-script&quot;&gt;Users with no logon script&lt;/h2&gt;
&lt;p&gt;dsquery * domainroot -filter”(&amp;amp;(objectCategory=Person)(objectClass=User)(!scriptPath=*))”-limit 0 -attr sAMAccountName sn givenName pwdLastSet distinguishedName&lt;/p&gt;

&lt;h2 id=&quot;user-accounts-with-no-pwd-required&quot;&gt;User accounts with no pwd required&lt;/h2&gt;
&lt;p&gt;dsquery * domainroot -filter “(&amp;amp;(objectCategory=Person)(objectClass=User)(userAccountControl:1.2.840.113556.1.4.803:=32))”&lt;/p&gt;

&lt;h2 id=&quot;user-accounts-with-no-pwd-expiry&quot;&gt;User accounts with no pwd expiry&lt;/h2&gt;
&lt;p&gt;dsquery * domainroot -filter”(&amp;amp;(objectCategory=Person)(objectClass=User)(userAccountControl:1.2.840.113556.1.4.803:=65536))”&lt;/p&gt;

&lt;h2 id=&quot;user-accounts-that-are-disabled&quot;&gt;User accounts that are disabled&lt;/h2&gt;
&lt;p&gt;dsquery * domainroot -filter “(&amp;amp;(objectCategory=Person)(objectClass=User)(userAccountControl:1.2.840.113556.1.4.803:=2))”&lt;/p&gt;

&lt;h2 id=&quot;dns-information&quot;&gt;DNS Information&lt;/h2&gt;
&lt;p&gt;for /f %i in (‘dsquery server -domain %userdnsdomain% -o rdn’) do dnscmd %i /info&lt;/p&gt;

&lt;h2 id=&quot;dns-zone-detailed-information&quot;&gt;DNS Zone Detailed information&lt;/h2&gt;
&lt;p&gt;dnscmd /zoneinfo %userdnsdomain%&lt;/p&gt;

&lt;h2 id=&quot;garbage-collection-and-tombstone&quot;&gt;Garbage Collection and tombstone&lt;/h2&gt;
&lt;p&gt;dsquery * “cn=Directory Service,cn=WindowsNT,cn=Services,cn=Configuration,DC=forestRootDomain” -attrgarbageCollPeriod tombstoneLifetime&lt;/p&gt;

&lt;h2 id=&quot;netsh-authorised-dhcp-servers&quot;&gt;Netsh authorised DHCP Servers&lt;/h2&gt;
&lt;p&gt;netsh dhcp show server&lt;/p&gt;

&lt;h2 id=&quot;dsquery-authorised-dhcp-servers&quot;&gt;DSQuery authorised DHCP Servers&lt;/h2&gt;
&lt;p&gt;Dsquery * “cn=NetServices,cn=Services,cn=Configuration, DC=forestRootDomain” -attr dhcpServers&lt;/p&gt;

&lt;h2 id=&quot;dhcp-server-information&quot;&gt;DHCP server information&lt;/h2&gt;
&lt;p&gt;netsh dhcp server \DHCP_SERVER show all&lt;/p&gt;

&lt;h2 id=&quot;dhcp-server-dump&quot;&gt;DHCP server dump&lt;/h2&gt;
&lt;p&gt;netsh dhcp server \DHCP_SERVER dump&lt;/p&gt;

&lt;h2 id=&quot;wins-serer-information&quot;&gt;WINS serer information&lt;/h2&gt;
&lt;p&gt;Netsh wins server \WINS_SERVER dump&lt;/p&gt;

&lt;h2 id=&quot;group-policy-verification-tool&quot;&gt;Group Policy Verification Tool&lt;/h2&gt;
&lt;p&gt;gpotool.exe /checkacl /verbose&lt;/p&gt;

&lt;h2 id=&quot;ad-ou-membership&quot;&gt;AD OU membership&lt;/h2&gt;
&lt;p&gt;dsquery computer -limit 0&lt;/p&gt;

&lt;h2 id=&quot;ad-ou-membership-1&quot;&gt;AD OU membership&lt;/h2&gt;
&lt;p&gt;dsquery user -limit 0&lt;/p&gt;

&lt;h2 id=&quot;list-service-principal-names&quot;&gt;List Service Principal Names&lt;/h2&gt;
&lt;p&gt;for /f %i in (‘dsquery server -domain %userdnsdomain% -o rdn’) do setspn -L %i&lt;/p&gt;

&lt;h2 id=&quot;compare-dc-replica-object-count&quot;&gt;Compare DC Replica Object Count&lt;/h2&gt;
&lt;p&gt;dsastat ?s:DC1;DC2;… ?b:Domain ?gcattrs:objectclass ?p:999&lt;/p&gt;

&lt;h2 id=&quot;check-ad-acls&quot;&gt;Check AD ACLs&lt;/h2&gt;
&lt;p&gt;acldiag dc=domainTree&lt;/p&gt;

&lt;h2 id=&quot;ntfrs-replica-sets&quot;&gt;NTFRS Replica Sets&lt;/h2&gt;
&lt;p&gt;for /f %i in (‘dsquery server -domain %userdnsdomain% -o rdn’) do ntfrsutl sets %i&lt;/p&gt;

&lt;h2 id=&quot;ntfrs-ds-view&quot;&gt;NTFRS DS View&lt;/h2&gt;
&lt;p&gt;for /f %i in (‘dsquery server -domain %userdnsdomain% -o rdn’) do ntfrsutl ds %i&lt;/p&gt;

&lt;h2 id=&quot;domain-controllers-per-site&quot;&gt;Domain Controllers per site&lt;/h2&gt;
&lt;p&gt;Dsquery * “CN=Sites,CN=Configuration,DC=forestRootDomain” -filter (objectCategory=Server)&lt;/p&gt;

&lt;h2 id=&quot;dns-zones-in-ad&quot;&gt;DNS Zones in AD&lt;/h2&gt;
&lt;p&gt;for /f %i in (‘dsquery server -o rdn’) do Dsquery * -s %i domainroot -filter (objectCategory=dnsZone)&lt;/p&gt;

&lt;h2 id=&quot;enumerate-dns-server-zones&quot;&gt;Enumerate DNS Server Zones&lt;/h2&gt;
&lt;p&gt;for /f %i in (‘dsquery server -o rdn’) do dnscmd %i /enumzones&lt;/p&gt;

&lt;h2 id=&quot;subnet-information&quot;&gt;Subnet information&lt;/h2&gt;
&lt;p&gt;Dsquery subnet ?limit 0&lt;/p&gt;

&lt;h2 id=&quot;list-organisational-units&quot;&gt;List Organisational Units&lt;/h2&gt;
&lt;p&gt;Dsquery OU&lt;/p&gt;

&lt;h2 id=&quot;acl-on-all-ous&quot;&gt;ACL on all OUs&lt;/h2&gt;
&lt;p&gt;For /f “delims=|” %i in (‘dsquery OU’) do acldiag %i&lt;/p&gt;

&lt;h2 id=&quot;domain-trusts&quot;&gt;Domain Trusts&lt;/h2&gt;
&lt;p&gt;nltest /domain_trusts /v&lt;/p&gt;

&lt;h2 id=&quot;print-dns-zones&quot;&gt;Print DNS Zones&lt;/h2&gt;
&lt;p&gt;dnscmd DNSServer /zoneprint DNSZone&lt;/p&gt;

&lt;h2 id=&quot;active-dhcp-leases&quot;&gt;Active DHCP leases&lt;/h2&gt;
&lt;p&gt;For /f %i in (DHCPServers.txt) do for /f “delims=- “ %j in (‘”netshdhcp server \%i show scope | find /i “active”“’) do netsh dhcp server\%i scope %j show clientsv5&lt;/p&gt;

&lt;h2 id=&quot;dhcp-server-active-scope-info&quot;&gt;DHCP Server Active Scope Info&lt;/h2&gt;
&lt;p&gt;For /f %i in (DHCPServers.txt) do netsh dhcp server \%i show scope | find /i “active”&lt;/p&gt;

&lt;h2 id=&quot;resolve-dhcp-clients-hostnames&quot;&gt;Resolve DHCP clients hostnames&lt;/h2&gt;
&lt;p&gt;for /f “tokens=1,2,3 delims=,” %i in (Output from ‘Find Subnets fromDHCP clients’) do @for /f “tokens=2 delims=: “ %m in (‘”nslookup %j |find /i “Name:”“’) do echo %m,%j,%k,%i&lt;/p&gt;

&lt;h2 id=&quot;find-two-online-pcs-per-subnet&quot;&gt;Find two online PCs per subnet&lt;/h2&gt;
&lt;p&gt;Echo. &amp;gt; TwoClientsPerSubnet.txt &amp;amp; for /f “tokens=1,2,3,4delims=, “ %i in (‘”find /i “pc” ‘Output from Resolve DHCP clientshostnames’”’) do for /f “tokens=3 skip=1 delims=: “ %m in (‘”Find /i /c”%l” TwoClientsPerSubnet.txt”’) do If %m LEQ 1 for /f %p in (‘”ping -n1 %i | find /i /c “(0% loss”“’) do If %p==1 Echo %i,%j,%k,%l&lt;/p&gt;

&lt;h2 id=&quot;ad-subnet-and-site-information&quot;&gt;AD Subnet and Site Information&lt;/h2&gt;
&lt;p&gt;dsquery * “CN=Subnets,CN=Sites,CN=Configuration,DC=forestRootDomain” -attr cn siteObject description location&lt;/p&gt;

&lt;h2 id=&quot;ad-site-information&quot;&gt;AD Site Information&lt;/h2&gt;
&lt;p&gt;dsquery * “CN=Sites,CN=Configuration,DC=forestRootDomain” -attr cn description location -filter (objectClass=site)&lt;/p&gt;

&lt;h2 id=&quot;printer-queue-objects-in-ad&quot;&gt;Printer Queue Objects in AD&lt;/h2&gt;
&lt;p&gt;dsquery * domainroot -filter “(objectCategory=printQueue)” -limit 0&lt;/p&gt;

&lt;h2 id=&quot;group-membership-with-user-details&quot;&gt;Group Membership with user details&lt;/h2&gt;
&lt;p&gt;dsget group “groupDN” -members | dsget user -samid -fn -mi -ln -display -empid -desc -office -tel -email -title -dept -mgr&lt;/p&gt;

&lt;h2 id=&quot;total-dhcp-scopes&quot;&gt;Total DHCP Scopes&lt;/h2&gt;
&lt;p&gt;find /i “subnet” “Output from DHCP server information” | find /i “subnet”&lt;/p&gt;

&lt;h2 id=&quot;site-links-and-cost&quot;&gt;Site Links and Cost&lt;/h2&gt;
&lt;p&gt;dsquery * “CN=Sites,CN=Configuration,DC=forestRootDomain” -attr cn costdescription replInterval siteList -filter (objectClass=siteLink)&lt;/p&gt;

&lt;h2 id=&quot;time-gpresult&quot;&gt;Time gpresult&lt;/h2&gt;
&lt;p&gt;timethis gpresult /v&lt;/p&gt;

&lt;h2 id=&quot;check-time-against-domain&quot;&gt;Check time against Domain&lt;/h2&gt;
&lt;p&gt;w32tm /monitor /computers:ForestRootPDC&lt;/p&gt;

&lt;h2 id=&quot;domain-controller-diagnostics&quot;&gt;Domain Controller Diagnostics&lt;/h2&gt;
&lt;p&gt;dcdiag /s:%logonserver% /v /e /c&lt;/p&gt;

&lt;h2 id=&quot;domain-replication-bridgeheads&quot;&gt;Domain Replication Bridgeheads&lt;/h2&gt;
&lt;p&gt;repadmin /bridgeheads&lt;/p&gt;

&lt;h2 id=&quot;replication-failures-from-kcc&quot;&gt;Replication Failures from KCC&lt;/h2&gt;
&lt;p&gt;repadmin /failcache&lt;/p&gt;

&lt;h2 id=&quot;inter-site-topology-servers-per-site&quot;&gt;Inter-site Topology servers per site&lt;/h2&gt;
&lt;p&gt;Repadmin /istg * /verbose&lt;/p&gt;

&lt;h2 id=&quot;replication-latency&quot;&gt;Replication latency&lt;/h2&gt;
&lt;p&gt;repadmin /latency /verbose&lt;/p&gt;

&lt;h2 id=&quot;queued-replication-requests&quot;&gt;Queued replication requests&lt;/h2&gt;
&lt;p&gt;repadmin /queue *&lt;/p&gt;

&lt;h2 id=&quot;show-connections-for-a-dc&quot;&gt;Show connections for a DC&lt;/h2&gt;
&lt;p&gt;repadmin /showconn *&lt;/p&gt;

&lt;h2 id=&quot;replication-summary&quot;&gt;Replication summary&lt;/h2&gt;
&lt;p&gt;Repadmin /replsummary&lt;/p&gt;

&lt;h2 id=&quot;show-replication-partners&quot;&gt;Show replication partners&lt;/h2&gt;
&lt;p&gt;repadmin /showrepl * /all&lt;/p&gt;

&lt;h2 id=&quot;all-dcs-in-the-forest&quot;&gt;All DCs in the forest&lt;/h2&gt;
&lt;p&gt;repadmin /viewlist *&lt;/p&gt;

&lt;h2 id=&quot;istg-from-ad-attributes&quot;&gt;ISTG from AD attributes&lt;/h2&gt;
&lt;p&gt;dsquery * “CN=NTDS Site Settings,CN=siteName,CN=Sites,CN=Configuration,DC=forestRootDomain” -attr interSiteTopologyGenerator&lt;/p&gt;

&lt;h2 id=&quot;return-the-object-if-kcc-intrainter-site-is-disabled-for-each-site&quot;&gt;Return the object if KCC Intra/Inter site is disabled for each site&lt;/h2&gt;
&lt;p&gt;Dsquery site | dsquery * -attr * -filter “(|(Options:1.2.840.113556.1.4.803:=1)(Options:1.2.840.113556.1.4.803:=16))”&lt;/p&gt;

&lt;h2 id=&quot;find-all-connection-objects&quot;&gt;Find all connection objects&lt;/h2&gt;
&lt;p&gt;dsquery * forestRoot -filter (objectCategory=nTDSConnection) ?attr distinguishedName fromServer whenCreated displayName&lt;/p&gt;

&lt;h2 id=&quot;find-all-connection-schedules&quot;&gt;Find all connection schedules&lt;/h2&gt;
&lt;p&gt;adfind -b “cn=Configuration,dc=qraps,dc=com,dc=au” -f “objectcategory=ntdsConnection” cn Schedule -csv&lt;/p&gt;

&lt;h2 id=&quot;software-information-for-each-server&quot;&gt;Software Information for each server&lt;/h2&gt;
&lt;p&gt;for /f %i in (Output from ‘Domain Controllers’) do psinfo \%i &amp;amp;filever \%i\admin$\explorer.exe \%i\admin$\system32\vbscript.dll\%i\admin$\system32\kernel32.dll \%i\admin$\system32\wbem\winmgmt.exe\%i\admin$\system32\oleaut32.dll&lt;/p&gt;

&lt;h2 id=&quot;check-terminal-services-delete-temp-on-exit-flag&quot;&gt;Check Terminal Services Delete Temp on Exit flag&lt;/h2&gt;
&lt;p&gt;For /f %i in (Output from ‘Domain Controllers’) do Reg query”\%i\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TerminalServer” /v DeleteTempDirsOnExit&lt;/p&gt;

&lt;h2 id=&quot;for-each-xp-workstation-query-the-current-site-and-what-group-policy-info&quot;&gt;For each XP workstation, query the current site and what Group Policy info&lt;/h2&gt;
&lt;p&gt;@dsquery * domainroot -filter”(&amp;amp;(objectCategory=Computer)(operatingSystem=Windows XPProfessional))” -limit 0 -attr cn &amp;gt; Workstations.txt &amp;amp; @For /f%i in (Workstations.txt) do @ping %i -n 1 &amp;gt;NUL &amp;amp; @if ErrorLevel0 If NOT ErrorLevel 1 @Echo %i &amp;amp; for /f “tokens=3” %k in (‘”regquery “\%i\hklm\software\microsoft\windows\currentversion\grouppolicy\history” /v DCName | Find /i “DCName”“’) do @for /f %m in(‘”nltest /server:%i /dsgetsite | find /i /v “completedsuccessfully”“’) do @echo %i,%k,%m&lt;/p&gt;

&lt;h2 id=&quot;information-on-existing-gpos&quot;&gt;Information on existing GPOs&lt;/h2&gt;
&lt;p&gt;dsquery * “CN=Policies,CN=System,domainRoot” -filter”(objectCategory=groupPolicyContainer)” -attr displayName cnwhenCreated gPCFileSysPath&lt;/p&gt;

&lt;h2 id=&quot;copy-all-group-policy-pol-files&quot;&gt;Copy all Group Policy .pol files&lt;/h2&gt;
&lt;p&gt;for /f “tokens=1-8 delims=&quot; %i in (‘dir /b /s\%userdnsdomain%\sysvol\%userdnsdomain%\policies*.pol’) do @echo copy\%i\%j\%k\%l\%m\%n\%o %m_%n.pol&lt;/p&gt;

&lt;h2 id=&quot;domain-controller-netlogon-entries&quot;&gt;Domain Controller Netlogon entries&lt;/h2&gt;
&lt;p&gt;for /f %i in (‘dsquery server /o rdn’) do echo %i &amp;amp; reg query\%i\hklm\system\currentcontrolset\services\netlogon\parameters&lt;/p&gt;

&lt;h2 id=&quot;wins-statistics&quot;&gt;WINS Statistics&lt;/h2&gt;
&lt;p&gt;for /f “tokens=1,2 delims=,” %i in (WINSServers.txt) do netsh wins server \%i show statistics&lt;/p&gt;

&lt;h2 id=&quot;wins-record-counts-per-server&quot;&gt;WINS Record counts per server&lt;/h2&gt;
&lt;p&gt;for /f “tokens=1,2 delims=,” %i in (WINSServers.txt) do netsh wins server \%i show reccount %i&lt;/p&gt;

&lt;h2 id=&quot;wins-server-information&quot;&gt;WINS Server Information&lt;/h2&gt;
&lt;p&gt;for /f “tokens=2 delims=,” %i in (WINSServers.txt) do netsh wins server \%i show info&lt;/p&gt;

&lt;h2 id=&quot;wins-server-dump&quot;&gt;WINS Server Dump&lt;/h2&gt;
&lt;p&gt;for /f “tokens=2 delims=,” %i in (WINSServers.txt) do netsh wins server \%i dump&lt;/p&gt;

&lt;h2 id=&quot;wins-static-records-per-server&quot;&gt;WINS Static Records per Server&lt;/h2&gt;
&lt;p&gt;netsh wins server \LocalWINSServer show database servers={} rectype=1&lt;/p&gt;

&lt;h2 id=&quot;find-policy-display-name-given-the-guid&quot;&gt;Find policy display name given the GUID&lt;/h2&gt;
&lt;p&gt;dsquery * “CN=Policies,CN=System,DC=domainRoot” -filter (objectCategory=groupPolicyContainer) -attr Name displayName&lt;/p&gt;

&lt;h2 id=&quot;find-empty-groups&quot;&gt;Find empty groups&lt;/h2&gt;
&lt;p&gt;dsquery * -filter “&amp;amp;(objectCategory=group)(!member=*)” -limit 0-attr whenCreated whenChanged groupType sAMAccountNamedistinguishedName memberOf&lt;/p&gt;

&lt;h2 id=&quot;find-remote-nic-bandwidth&quot;&gt;Find remote NIC bandwidth&lt;/h2&gt;
&lt;p&gt;wmic /node:%server% path Win32_PerfRawData_Tcpip_NetworkInterface GET Name,CurrentBandwidth&lt;/p&gt;

&lt;h2 id=&quot;find-remote-free-physical-memory&quot;&gt;Find remote free physical memory&lt;/h2&gt;
&lt;p&gt;wmic /node:%Computer% path Win32_OperatingSystem GET FreePhysicalMemory&lt;/p&gt;

&lt;h2 id=&quot;find-remote-system-information&quot;&gt;Find remote system information&lt;/h2&gt;
&lt;p&gt;SystemInfo /s %Computer%&lt;/p&gt;

&lt;h2 id=&quot;disk-statistics-including-the-number-of-files-on-the-filesystem&quot;&gt;Disk statistics, including the number of files on the filesystem&lt;/h2&gt;
&lt;p&gt;chkdsk /i /c&lt;/p&gt;

&lt;h2 id=&quot;query-iis-web-sites&quot;&gt;Query IIS web sites&lt;/h2&gt;
&lt;p&gt;iisweb /s %Server% /query “Default Web Site”&lt;/p&gt;

&lt;h2 id=&quot;check-port-state-and-connectivity&quot;&gt;Check port state and connectivity&lt;/h2&gt;
&lt;p&gt;portqry -n %server% -e %endpoint% -v&lt;/p&gt;

&lt;h2 id=&quot;forestdomain-functional-levels&quot;&gt;Forest/Domain Functional Levels&lt;/h2&gt;
&lt;p&gt;ldifde -d cn=partitions,cn=configuration,dc=%domain% -r”(|(systemFlags=3)(systemFlags=-2147483648))” -lmsds-behavior-version,dnsroot,ntmixeddomain,NetBIOSName -p subtree -fcon&lt;/p&gt;

&lt;h2 id=&quot;forestdomain-functional-levels-1&quot;&gt;Forest/Domain Functional Levels&lt;/h2&gt;
&lt;p&gt;dsquery * cn=partitions,cn=configuration,dc=%domain% -filter”(|(systemFlags=3)(systemFlags=-2147483648))” -attrmsDS-Behavior-Version
Name dnsroot ntmixeddomain NetBIOSName&lt;/p&gt;

&lt;h2 id=&quot;find-the-parent-of-a-process&quot;&gt;Find the parent of a process&lt;/h2&gt;
&lt;p&gt;wmic path Win32_Process WHERE Name=’notepad.exe’ GET Name,ParentProcessId&lt;/p&gt;

&lt;h2 id=&quot;lookup-srv-records-from-dns&quot;&gt;Lookup SRV records from DNS&lt;/h2&gt;
&lt;p&gt;nslookup -type=srv _ldap._tcp.dc._msdcs.{domainRoot}&lt;/p&gt;

&lt;h2 id=&quot;find-when-the-ad-was-installed&quot;&gt;Find when the AD was installed&lt;/h2&gt;
&lt;p&gt;dsquery * cn=configuration,DC=forestRootDomain -attr whencreated -scope base&lt;/p&gt;

&lt;h2 id=&quot;enumerate-the-trusts-from-the-specified-domain&quot;&gt;Enumerate the trusts from the specified domain&lt;/h2&gt;
&lt;p&gt;dsquery * “CN=System,DC=domainRoot” -filter “(objectClass=trustedDomain)” -attr trustPartner flatName&lt;/p&gt;

&lt;h2 id=&quot;find-a-dc-for-each-trusted-domain&quot;&gt;Find a DC for each trusted domain&lt;/h2&gt;
&lt;p&gt;for /f “skip=1” %i in (‘”dsquery * CN=System,DC=domainRoot -filter(objectClass=trustedDomain) -attr trustPartner”’) do nltest /dsgetdc:%i&lt;/p&gt;

&lt;h2 id=&quot;check-the-notification-packages-installed-on-all-dcs&quot;&gt;Check the notification packages installed on all DCs&lt;/h2&gt;
&lt;p&gt;for /f %i in (‘dsquery server /o rdn’) do @for /f “tokens=4” %m in(‘”reg query\%i\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa /v”Notification Packages” | find /i “Notification”“’) do @echo %i,%m&lt;/p&gt;

&lt;h2 id=&quot;list-acls-in-sddl-format&quot;&gt;List ACLs in SDDL format&lt;/h2&gt;
&lt;p&gt;setacl -on %filepath% -ot file -actn list -lst f:sddl&lt;/p&gt;

&lt;h2 id=&quot;find-out-if-a-user-account-is-currently-enabled-or-disabled&quot;&gt;Find out if a user account is currently enabled or disabled&lt;/h2&gt;
&lt;p&gt;dsquery user DC=%userdnsdomain:.=,DC=% -name %username% | dsget user -disabled -dn&lt;/p&gt;

&lt;h2 id=&quot;find-servers-in-the-domain&quot;&gt;Find servers in the domain&lt;/h2&gt;
&lt;p&gt;dsquery * domainroot -filter “(&amp;amp;(objectCategory=Computer)(objectClass=Computer)(operatingSystem=&lt;em&gt;Server&lt;/em&gt;))” -limit 0&lt;/p&gt;

&lt;h2 id=&quot;open-ds-query-window&quot;&gt;Open DS query window&lt;/h2&gt;
&lt;p&gt;rundll32 dsquery,OpenQueryWindow&lt;/p&gt;</content><author><name>Bertland Hope</name></author><summary type="html">FSMO Roles ntdsutilroles Connections “Connect to server %logonserver%” Quit “selectOperation Target” “List roles for conn server” Quit Quit Quit [JDH: This is really a series of steps, not a single command expression]</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bertlandh.github.io/computer_life_support/img/2022-09-14-active-directory-one-liners-188-1200x800.jpg" /><media:content medium="image" url="https://bertlandh.github.io/computer_life_support/img/2022-09-14-active-directory-one-liners-188-1200x800.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Deploy Office 365 (for IT Pros)</title><link href="https://bertlandh.github.io/computer_life_support/2022/09/13/Deploy-Office-365-for-IT-Pros/" rel="alternate" type="text/html" title="Deploy Office 365 (for IT Pros)" /><published>2022-09-13T16:30:00+00:00</published><updated>2022-09-13T16:30:00+00:00</updated><id>https://bertlandh.github.io/computer_life_support/2022/09/13/Deploy-Office-365-for-IT-Pros</id><content type="html" xml:base="https://bertlandh.github.io/computer_life_support/2022/09/13/Deploy-Office-365-for-IT-Pros/">&lt;h2 id=&quot;to-download-32bit-office&quot;&gt;To download 32bit office&lt;/h2&gt;

&lt;p&gt;networkSharePath\office\Office365&amp;gt; .\setup.exe /download Configuration-32.xml&lt;/p&gt;

&lt;p&gt;create a file save it as add the content below download Configuration-32.xml&lt;/p&gt;

&lt;p&gt;&amp;lt;Configuration&amp;gt;&lt;br /&gt;
  &amp;lt;Add OfficeClientEdition=”32” Channel=”Current” SourcePath=”networkSharePath\office\Office365\86” AllowCdnFallback=”FALSE”&amp;gt;&lt;br /&gt;
    &amp;lt;Product ID=”O365BusinessRetail”&amp;gt;&lt;br /&gt;
      &amp;lt;Language ID=”en-us” /&amp;gt;&lt;br /&gt;
    &amp;lt;/Product&amp;gt;&lt;br /&gt;
  &amp;lt;/Add&amp;gt;&lt;br /&gt;
  &amp;lt;Property Name=”SharedComputerLicensing” Value=”0” /&amp;gt;&lt;br /&gt;
  &amp;lt;Property Name=”SCLCacheOverride” Value=”0” /&amp;gt;&lt;br /&gt;
  &amp;lt;Property Name=”AUTOACTIVATE” Value=”0” /&amp;gt;&lt;br /&gt;
  &amp;lt;Property Name=”FORCEAPPSHUTDOWN” Value=”FALSE” /&amp;gt;&lt;br /&gt;
  &amp;lt;Property Name=”DeviceBasedLicensing” Value=”0” /&amp;gt;&lt;br /&gt;
  &amp;lt;Updates Enabled=”TRUE” /&amp;gt;&lt;br /&gt;
  &amp;lt;RemoveMSI /&amp;gt;&lt;br /&gt;
  &amp;lt;Display Level=”None” AcceptEULA=”TRUE” /&amp;gt;&lt;br /&gt;
&amp;lt;/Configuration&amp;gt;&lt;/p&gt;

&lt;h2 id=&quot;to-remove-32bit-office&quot;&gt;To Remove 32bit Office&lt;/h2&gt;
&lt;p&gt;networkSharePath\office\Office365&amp;gt; .\setup.exe /configure uninstall-Office365ProPlus-32.xml&lt;/p&gt;

&lt;p&gt;create a file save it as add the content below download uninstall-Office365ProPlus-32.xml&lt;br /&gt;
&amp;lt;Configuration&amp;gt;&lt;br /&gt;
&amp;lt;Remove OfficeClientEdition=”86”&amp;gt;&lt;br /&gt;
&amp;lt;Product ID=”O365BusinessRetail”&amp;gt;&lt;br /&gt;
&amp;lt;Language ID=”en-us”/&amp;gt;&lt;br /&gt;
&amp;lt;/Product&amp;gt;&lt;br /&gt;
&amp;lt;/Remove&amp;gt;&lt;br /&gt;
&amp;lt;Display Level=”None” AcceptEULA=”TRUE”/&amp;gt;&lt;br /&gt;
&amp;lt;/Configuration&amp;gt;&lt;/p&gt;

&lt;h2 id=&quot;to-install-32bit&quot;&gt;To install 32bit&lt;/h2&gt;
&lt;p&gt;networkSharePath\office\Office365&amp;gt; .\setup.exe /configure Configuration-32.xml&lt;/p&gt;

&lt;p&gt;&amp;lt;Configuration&amp;gt;&lt;br /&gt;
  &amp;lt;Add OfficeClientEdition=”32” Channel=”Current” SourcePath=”networkSharePath\office\Office365\86” AllowCdnFallback=”FALSE”&amp;gt;&lt;br /&gt;
    &amp;lt;Product ID=”O365BusinessRetail”&amp;gt;&lt;br /&gt;
      &amp;lt;Language ID=”en-us” /&amp;gt;&lt;br /&gt;
    &amp;lt;/Product&amp;gt;&lt;br /&gt;
  &amp;lt;/Add&amp;gt;&lt;br /&gt;
  &amp;lt;Property Name=”SharedComputerLicensing” Value=”0” /&amp;gt;&lt;br /&gt;
  &amp;lt;Property Name=”SCLCacheOverride” Value=”0” /&amp;gt;&lt;br /&gt;
  &amp;lt;Property Name=”AUTOACTIVATE” Value=”0” /&amp;gt;&lt;br /&gt;
  &amp;lt;Property Name=”FORCEAPPSHUTDOWN” Value=”FALSE” /&amp;gt;&lt;br /&gt;
  &amp;lt;Property Name=”DeviceBasedLicensing” Value=”0” /&amp;gt;&lt;br /&gt;
  &amp;lt;Updates Enabled=”TRUE” /&amp;gt;&lt;br /&gt;
  &amp;lt;RemoveMSI /&amp;gt;&lt;br /&gt;
  &amp;lt;Display Level=”None” AcceptEULA=”TRUE” /&amp;gt;&lt;br /&gt;
&amp;lt;/Configuration&amp;gt;&lt;/p&gt;</content><author><name>Bertland Hope</name></author><summary type="html">To download 32bit office networkSharePath\office\Office365&amp;gt; .\setup.exe /download Configuration-32.xml create a file save it as add the content below download Configuration-32.xml &amp;lt;Configuration&amp;gt; &amp;lt;Add OfficeClientEdition=”32” Channel=”Current” SourcePath=”networkSharePath\office\Office365\86” AllowCdnFallback=”FALSE”&amp;gt; &amp;lt;Product ID=”O365BusinessRetail”&amp;gt; &amp;lt;Language ID=”en-us” /&amp;gt; &amp;lt;/Product&amp;gt; &amp;lt;/Add&amp;gt; &amp;lt;Property Name=”SharedComputerLicensing” Value=”0” /&amp;gt; &amp;lt;Property Name=”SCLCacheOverride” Value=”0” /&amp;gt; &amp;lt;Property Name=”AUTOACTIVATE” Value=”0” /&amp;gt; &amp;lt;Property Name=”FORCEAPPSHUTDOWN” Value=”FALSE” /&amp;gt; &amp;lt;Property Name=”DeviceBasedLicensing” Value=”0” /&amp;gt; &amp;lt;Updates Enabled=”TRUE” /&amp;gt; &amp;lt;RemoveMSI /&amp;gt; &amp;lt;Display Level=”None” AcceptEULA=”TRUE” /&amp;gt; &amp;lt;/Configuration&amp;gt; To Remove 32bit Office networkSharePath\office\Office365&amp;gt; .\setup.exe /configure uninstall-Office365ProPlus-32.xml create a file save it as add the content below download uninstall-Office365ProPlus-32.xml &amp;lt;Configuration&amp;gt; &amp;lt;Remove OfficeClientEdition=”86”&amp;gt; &amp;lt;Product ID=”O365BusinessRetail”&amp;gt; &amp;lt;Language ID=”en-us”/&amp;gt; &amp;lt;/Product&amp;gt; &amp;lt;/Remove&amp;gt; &amp;lt;Display Level=”None” AcceptEULA=”TRUE”/&amp;gt; &amp;lt;/Configuration&amp;gt; To install 32bit networkSharePath\office\Office365&amp;gt; .\setup.exe /configure Configuration-32.xml &amp;lt;Configuration&amp;gt; &amp;lt;Add OfficeClientEdition=”32” Channel=”Current” SourcePath=”networkSharePath\office\Office365\86” AllowCdnFallback=”FALSE”&amp;gt; &amp;lt;Product ID=”O365BusinessRetail”&amp;gt; &amp;lt;Language ID=”en-us” /&amp;gt; &amp;lt;/Product&amp;gt; &amp;lt;/Add&amp;gt; &amp;lt;Property Name=”SharedComputerLicensing” Value=”0” /&amp;gt; &amp;lt;Property Name=”SCLCacheOverride” Value=”0” /&amp;gt; &amp;lt;Property Name=”AUTOACTIVATE” Value=”0” /&amp;gt; &amp;lt;Property Name=”FORCEAPPSHUTDOWN” Value=”FALSE” /&amp;gt; &amp;lt;Property Name=”DeviceBasedLicensing” Value=”0” /&amp;gt; &amp;lt;Updates Enabled=”TRUE” /&amp;gt; &amp;lt;RemoveMSI /&amp;gt; &amp;lt;Display Level=”None” AcceptEULA=”TRUE” /&amp;gt; &amp;lt;/Configuration&amp;gt;</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://upload.wikimedia.org/wikipedia/commons/3/3d/Kon-Boot_with_Automatic_Powershell_Script_Execution_feature.png" /><media:content medium="image" url="https://upload.wikimedia.org/wikipedia/commons/3/3d/Kon-Boot_with_Automatic_Powershell_Script_Execution_feature.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Powershell Windows Updates</title><link href="https://bertlandh.github.io/computer_life_support/2022/09/12/powershell-windows-updates/" rel="alternate" type="text/html" title="Powershell Windows Updates" /><published>2022-09-12T16:45:00+00:00</published><updated>2022-09-12T16:45:00+00:00</updated><id>https://bertlandh.github.io/computer_life_support/2022/09/12/powershell-windows-updates</id><content type="html" xml:base="https://bertlandh.github.io/computer_life_support/2022/09/12/powershell-windows-updates/">&lt;h2 id=&quot;1st-we-need-to-install-the-pswindowsupdate-module&quot;&gt;1st: We need to install the PSWindowsUpdate module,&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;step2-job-that-silently-installs-c-2015-2019-runtime&quot;&gt;Step2: Job that silently installs C++ 2015-2019 runtime&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Your code goes here!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;step3-powershell&quot;&gt;Step3: Powershell&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Module PSWindowsUpdate -Force

import-module PSWindowsUpdate -force
get-wulist -microsoftupdate

$GWU = Get-WuList -MicrosoftUpdate
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;step4-install-all-available-updates-no-reboot&quot;&gt;Step4: Install ALL available updates [no reboot]&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import-module PSWindowsUpdate -force
get-wulist -microsoftupdate -acceptall -install -ignorereboot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Bertland Hope</name></author><summary type="html">1st: We need to install the PSWindowsUpdate module, [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://upload.wikimedia.org/wikipedia/commons/3/3d/Kon-Boot_with_Automatic_Powershell_Script_Execution_feature.png" /><media:content medium="image" url="https://upload.wikimedia.org/wikipedia/commons/3/3d/Kon-Boot_with_Automatic_Powershell_Script_Execution_feature.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Batch Commands</title><link href="https://bertlandh.github.io/computer_life_support/2022/09/11/batch-commands/" rel="alternate" type="text/html" title="Batch Commands" /><published>2022-09-11T17:30:00+00:00</published><updated>2022-09-11T17:30:00+00:00</updated><id>https://bertlandh.github.io/computer_life_support/2022/09/11/batch-commands</id><content type="html" xml:base="https://bertlandh.github.io/computer_life_support/2022/09/11/batch-commands/">&lt;h2 id=&quot;batch-get-the-date-into-iso-8601-standard-date-format-yyyy-mm-dd-and-store-it-in-the-cur_date-variable&quot;&gt;BATCH: Get the date into ISO 8601 standard date format (yyyy-mm-dd) and store it in the “CUR_DATE” variable&lt;/h2&gt;
&lt;p&gt;FOR /f %%a in (‘WMIC OS GET LocalDateTime ^| find “.”’) DO set DTS=%%a
set CUR_DATE=%DTS:~0,4%-%DTS:~4,2%-%DTS:~6,2%&lt;/p&gt;

&lt;h2 id=&quot;batch-identify-windows-operating-system-version-and-store-it-in-the-win_ver-variable&quot;&gt;BATCH: Identify Windows operating system version and store it in the “WIN_VER” variable&lt;/h2&gt;
&lt;h2 id=&quot;thanks-to-ujstech-for-this--httpcommunityspiceworkscomtopicpost2898378-&quot;&gt;Thanks to UJSTech for this ( http://community.spiceworks.com/topic/post/2898378 )&lt;/h2&gt;
&lt;p&gt;for /f “tokens=3*” %%i IN (‘reg query “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion” /v ProductName ^| Find “ProductName”’) DO set WIN_VER=%%i %%j&lt;/p&gt;

&lt;h2 id=&quot;example-windows-version-of-above-command--returned-string&quot;&gt;Example Windows version of above command &amp;amp; returned string:&lt;/h2&gt;
&lt;p&gt;Windows XP Professional SP3:     Microsoft Windows XP
   Windows Server 2003 Enterprise:  Microsoft Windows Server 2003
   Windows Vista Home Premium:      Windows Vista (TM) Home Premium
   Windows Vista Ultimate:          Windows Vista (TM) Ultimate
   Windows 7 Home Premium:          Windows 7 Home Premium
   Windows 7 Professional:          Windows 7 Professional
   Windows 7 Enterprise:            Windows 7 Enterprise
   Windows 7 Starter:               Windows 7 Starter
   Windows 8.1 Professional:        Windows 8.1 Pro
   Windows Server 2008 R2 Standard: Windows Server 2008 R2 Standard
   Windows Server 2012 R2 Standard: Windows Server 2012 R2 Standard
   Windows 10 Professional:         Windows 10 Pro&lt;/p&gt;

&lt;h2 id=&quot;batch-check-smart-status-of-all-disks-with-title-index-caption-and-status&quot;&gt;BATCH: Check SMART status of all disks with title, index, caption and status&lt;/h2&gt;
&lt;p&gt;wmic diskdrive get Availability,Index,Caption,Status&lt;/p&gt;

&lt;h2 id=&quot;batch-install-global-shared-printer-system-wide&quot;&gt;BATCH: Install global shared printer (system-wide)&lt;/h2&gt;
&lt;p&gt;rundll32 printui.dll,PrintUIEntry /ga /n “\SERVER\PRINTER”&lt;/p&gt;

&lt;h2 id=&quot;batch-show-ipconfig-output-for-only-a-single-adapter-long-version-first-short-version-second&quot;&gt;BATCH: Show IPCONFIG output for only a single adapter (long version first, short version second)&lt;/h2&gt;
&lt;p&gt;netsh interface ip show addresses eth0
netsh int ip sh ad eth0&lt;/p&gt;

&lt;h2 id=&quot;batch-add-static-route-to-the-host-192168183-via-the-gateway-of-1721611-on-interface-11-and-persist-across-reboots--p&quot;&gt;BATCH: Add static route to the host 192.168.1.83 via the gateway of 172.16.1.1, on interface #11, and persist across reboots (-p)&lt;/h2&gt;
&lt;p&gt;route add 192.168.1.83 mask 255.255.255.255 172.16.1.1 metric 31 if 11 -p&lt;/p&gt;

&lt;h2 id=&quot;batch-add-static-route-to-the-1921681024-subnet-via-the-gateway-of-1721611-on-interface-11-and-persist-across-reboots--p&quot;&gt;BATCH: Add static route to the 192.168.1.0/24 subnet via the gateway of 172.16.1.1, on interface #11, and persist across reboots (-p)&lt;/h2&gt;
&lt;p&gt;route add 192.168.1.0 mask 255.255.255.0 172.16.1.1 metric 31 if 11 -p&lt;/p&gt;

&lt;h2 id=&quot;batch-flush-all-static-routes-active-takes-effect-immediately&quot;&gt;BATCH: Flush all static routes; active, takes effect immediately:&lt;/h2&gt;
&lt;p&gt;route -f&lt;/p&gt;
&lt;h2 id=&quot;batch-flush-all-static-routes-persistent-routes-only-takes-effect-at-reboot&quot;&gt;BATCH: Flush all static routes; persistent routes only, takes effect at reboot:&lt;/h2&gt;
&lt;p&gt;reg delete HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes /va /f&lt;/p&gt;

&lt;h2 id=&quot;batch-kill-all-browsers&quot;&gt;BATCH: Kill all browsers&lt;/h2&gt;
&lt;p&gt;taskkill /f /im iexplore.exe /im firefox.exe /im chrome.exe /im palemoon.exe /im opera.exe&lt;/p&gt;

&lt;h2 id=&quot;batch-kill-firefox&quot;&gt;BATCH: Kill Firefox&lt;/h2&gt;
&lt;p&gt;wmic process where name=”firefox.exe” call terminate&lt;/p&gt;

&lt;h2 id=&quot;batch-get-list-of-all-installed-products&quot;&gt;BATCH: Get list of ALL installed products&lt;/h2&gt;
&lt;p&gt;wmic product get identifyingnumber,name,version /all
wmic product get name, vendor, version /all&lt;/p&gt;

&lt;h2 id=&quot;batch-find-out-if-net-35-is-installed&quot;&gt;BATCH: Find out if .NET 3.5 is installed&lt;/h2&gt;
&lt;p&gt;reg query “HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5”| findstr Install&lt;/p&gt;

&lt;h2 id=&quot;batch-remotely-get-installed-version-of-firefox-on-all-domain-computers&quot;&gt;BATCH: Remotely get installed version of Firefox on all domain computers&lt;/h2&gt;
&lt;p&gt;psexec \* cmd /c (cd “C:\Program Files (x86)\Mozilla Firefox&quot; ^&amp;amp; firefox -v ^| more)&lt;/p&gt;

&lt;h2 id=&quot;batch-uninstall-programs-various-examples&quot;&gt;BATCH: Uninstall programs, various examples&lt;/h2&gt;
&lt;h2 id=&quot;batch-nointeractive-doesnt-prompt-user-to-remove-the-program&quot;&gt;BATCH: /nointeractive doesn’t prompt user to remove the program&lt;/h2&gt;
&lt;p&gt;wmic product where description=”Symantec” uninstall
wmic product where name=”Symantec” uninstall
wmic product where version=’65.39.83’ uninstall&lt;/p&gt;

&lt;h2 id=&quot;batch-uninstall-programs-using-wildcards&quot;&gt;BATCH: Uninstall programs using wildcards&lt;/h2&gt;
&lt;p&gt;wmic product where “name like ‘java%%Runtime%%’” uninstall /nointeractive
wmic product where “name like ‘java%%platform%%’” uninstall /nointeractive
wmic product where “name like ‘java%%tm%%’” uninstall /nointeractive&lt;/p&gt;

&lt;h2 id=&quot;batch-remove-all-microsoft-visual-c-redistributable-runtimes&quot;&gt;BATCH: Remove ALL “Microsoft Visual C++ Redistributable” runtimes.&lt;/h2&gt;
&lt;p&gt;wmic product where “name like ‘Microsoft Visual C%%’” call uninstall /nointeractive&lt;/p&gt;

&lt;h2 id=&quot;batch-remotely-determine-logged-in-user&quot;&gt;BATCH: Remotely determine logged in user&lt;/h2&gt;
&lt;p&gt;wmic /node:remotecomputer computersystem get username&lt;/p&gt;

&lt;h2 id=&quot;batch-list-running-processes&quot;&gt;BATCH: List running processes&lt;/h2&gt;
&lt;p&gt;wmic process list brief&lt;/p&gt;

&lt;h2 id=&quot;batch-kill-a-process&quot;&gt;BATCH: Kill a process&lt;/h2&gt;
&lt;p&gt;wmic process where name=”cmd.exe” delete&lt;/p&gt;

&lt;h2 id=&quot;batch-determine-open-shares&quot;&gt;BATCH: Determine open shares&lt;/h2&gt;
&lt;p&gt;net share
wmic share list brief&lt;/p&gt;

&lt;h2 id=&quot;batch-display-remote-machines-mac-address&quot;&gt;BATCH: Display remote machines MAC address&lt;/h2&gt;
&lt;p&gt;wmic /node:machinename nic get macaddress&lt;/p&gt;

&lt;h2 id=&quot;batch-list-remote-systems-running-processes-every-second&quot;&gt;BATCH: List remote systems running processes every second&lt;/h2&gt;
&lt;p&gt;wmic /node:machinename process list brief /every:1&lt;/p&gt;

&lt;h2 id=&quot;batch-display-remote-systems-system-info&quot;&gt;BATCH: Display remote systems System Info&lt;/h2&gt;
&lt;p&gt;wmic /node:machinename computersystem list full&lt;/p&gt;

&lt;h2 id=&quot;batch-disk-drive-information&quot;&gt;BATCH: Disk drive information&lt;/h2&gt;
&lt;p&gt;wmic diskdrive list full
wmic partition list full&lt;/p&gt;

&lt;h2 id=&quot;batch-bios-info&quot;&gt;BATCH: BIOS info&lt;/h2&gt;
&lt;p&gt;wmic bios list full&lt;/p&gt;

&lt;h2 id=&quot;batch-get-system-model-number&quot;&gt;BATCH: Get system model number&lt;/h2&gt;
&lt;p&gt;wmic csproduct get name&lt;/p&gt;

&lt;h2 id=&quot;batch-get-system-serial-number&quot;&gt;BATCH: Get system serial number&lt;/h2&gt;
&lt;p&gt;wmic product get serialnumber&lt;/p&gt;

&lt;h2 id=&quot;batch-get-hard-drive-physical-serial-numbers-first-option-gives-serial-number-printed-on-the-hard-drive-case-last-one-gets-it-from-a-remote-system&quot;&gt;BATCH: Get hard drive physical serial numbers (first option gives serial number printed on the hard drive case). Last one gets it from a remote system&lt;/h2&gt;
&lt;p&gt;wmic path win32_physicalmedia get SerialNumber
wmic diskdrive get serialnumber,name,description
wmic /node:REMOTE-COMPUTER-NAME bios get serialnumber&lt;/p&gt;

&lt;h2 id=&quot;batch-create-a-single-folder-for-every-day-in-the-year&quot;&gt;BATCH: Create a single folder for every day in the year&lt;/h2&gt;
&lt;p&gt;for %%m in (01,02,03,04,05,06,07,08,09,10,11,12) do for %%d in (01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31) do mkdir “2018-%%m-%%d”
for %%m in (04,06,09,11) do rmdir /s /q “2018-%%m-31”
for %%d in (29,30,31) do rmdir /s /q “2018-02-%%d”&lt;/p&gt;

&lt;h2 id=&quot;batch-list-all-installed-microsoft-hotfixespatches&quot;&gt;BATCH: List all installed Microsoft hotfixes/patches&lt;/h2&gt;
&lt;p&gt;wmic qfe&lt;/p&gt;

&lt;h2 id=&quot;batch-look-for-a-particular-patch&quot;&gt;BATCH: Look for a particular patch&lt;/h2&gt;
&lt;p&gt;wmic qfe where hotfixid=”KB958644” list full&lt;/p&gt;

&lt;h2 id=&quot;batch-remotely-list-local-enabled-accounts-and-disabled-domain-accounts&quot;&gt;BATCH: Remotely List Local Enabled Accounts and Disabled domain accounts&lt;/h2&gt;
&lt;p&gt;wmic /node:&lt;remote computer=&quot;&quot; name=&quot;&quot;&gt; USERACCOUNT WHERE &quot;Disabled=0 AND LocalAccount=1&quot; GET Name
wmic /node:&lt;remote computer=&quot;&quot; name=&quot;&quot;&gt; USERACCOUNT WHERE &quot;Disabled=1 AND LocalAccount=0&quot; GET Name&lt;/remote&gt;&lt;/remote&gt;&lt;/p&gt;

&lt;h2 id=&quot;batch-start-a-service-remotely&quot;&gt;BATCH: Start a service remotely&lt;/h2&gt;
&lt;p&gt;wmic /node:machinename 4 service lanmanserver CALL Startservice
sc \machinename start lanmanserver&lt;/p&gt;

&lt;h2 id=&quot;batch-list-services&quot;&gt;BATCH: List services&lt;/h2&gt;
&lt;p&gt;wmic service list brief
sc \machinename query&lt;/p&gt;

&lt;h2 id=&quot;batch-disable-startup-service&quot;&gt;BATCH: Disable startup service&lt;/h2&gt;
&lt;p&gt;sc config example disabled&lt;/p&gt;

&lt;h2 id=&quot;batch-list-user-accounts&quot;&gt;BATCH: List user accounts&lt;/h2&gt;
&lt;p&gt;wmic useraccount list brief&lt;/p&gt;

&lt;h2 id=&quot;batch-enable-rdp-remotely&quot;&gt;BATCH: Enable RDP remotely&lt;/h2&gt;
&lt;p&gt;wmic /node:”machinename 4” path Win32_TerminalServiceSetting where AllowTSConnections=0” call SetAllowTSConnections 1”&lt;/p&gt;

&lt;h2 id=&quot;batch-list-number-of-times-a-user-logged-on&quot;&gt;BATCH: List number of times a user logged on&lt;/h2&gt;
&lt;p&gt;wmic netlogin where (name like “%%Admin%%”) get numberoflogons&lt;/p&gt;

&lt;h2 id=&quot;batch-query-active-rdp-sessions&quot;&gt;BATCH: Query active RDP sessions&lt;/h2&gt;
&lt;p&gt;qwinsta /server:192.168.1.1&lt;/p&gt;

&lt;h2 id=&quot;batch-remove-active-rdp-session-id-2&quot;&gt;BATCH: Remove active RDP session ID 2&lt;/h2&gt;
&lt;p&gt;rwinsta /server:192.168.1.1 2&lt;/p&gt;

&lt;h2 id=&quot;batch-remotely-query-registry-for-last-logged-in-user&quot;&gt;BATCH: Remotely query registry for last logged in user&lt;/h2&gt;
&lt;p&gt;reg query “\computername\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon” /v DefaultUserName&lt;/p&gt;

&lt;h2 id=&quot;batch-list-all-computers-in-domain-blah-limited-to-first-6000-results-dump-the-output-in-outputtxt&quot;&gt;BATCH: List all computers in domain “blah” (limited to first 6000 results); dump the output in “output.txt”&lt;/h2&gt;
&lt;p&gt;dsquery computer “OU=example,DC=blah” -o rdn -limit 6000 &amp;gt; output.txt&lt;/p&gt;

&lt;h2 id=&quot;batch-reboot-immediately&quot;&gt;BATCH: Reboot immediately&lt;/h2&gt;
&lt;p&gt;shutdown /r /t 0&lt;/p&gt;

&lt;h2 id=&quot;batch-shutdown&quot;&gt;BATCH: Shutdown&lt;/h2&gt;
&lt;p&gt;shutdown /s /t 0&lt;/p&gt;

&lt;h2 id=&quot;batch-remotely-reboot-machine&quot;&gt;BATCH: Remotely reboot machine&lt;/h2&gt;
&lt;p&gt;shutdown /m \192.168.1.1 /r /t 0 /f&lt;/p&gt;

&lt;h2 id=&quot;batch-copy-entire-folder-and-its-contents-from-a-remote-source-to-local-machine&quot;&gt;BATCH: Copy entire folder and its contents from a remote source to local machine&lt;/h2&gt;
&lt;p&gt;xcopy /s \remotecomputer\directory c:\local&lt;/p&gt;

&lt;h2 id=&quot;batch-find-location-of-file-with-string-blah-in-file-name&quot;&gt;BATCH: Find location of file with string “blah” in file name&lt;/h2&gt;
&lt;p&gt;dir c:\ /s /b | find “blah”&lt;/p&gt;

&lt;h2 id=&quot;batch-determine-name-of-a-machine-with-known-ip&quot;&gt;BATCH: Determine name of a machine with known IP&lt;/h2&gt;
&lt;p&gt;nbtstat -A 192.168.1.1&lt;/p&gt;

&lt;h2 id=&quot;batch-find-directory-named-blah&quot;&gt;BATCH: Find directory named blah&lt;/h2&gt;
&lt;p&gt;dir c:\ /s /b /ad | find “blah”&lt;/p&gt;

&lt;h2 id=&quot;batch-command-line-history&quot;&gt;BATCH: Command line history&lt;/h2&gt;
&lt;p&gt;F7&lt;/p&gt;

&lt;h2 id=&quot;batch-determine-the-current-user-aka-whoami-linux-equivalent&quot;&gt;BATCH: Determine the current user (aka whoami Linux equivalent)&lt;/h2&gt;
&lt;p&gt;echo %USERNAME%&lt;/p&gt;

&lt;h2 id=&quot;batch-determine-who-is-apart-of-the-administrators-group&quot;&gt;BATCH: Determine who is apart of the administrators group&lt;/h2&gt;
&lt;p&gt;net localgroup administrators&lt;/p&gt;

&lt;h2 id=&quot;batch-add-a-user-where-travis-is-the-username-and-password-is-blah&quot;&gt;BATCH: Add a user where travis is the username and password is blah&lt;/h2&gt;
&lt;p&gt;net user travis blah /add&lt;/p&gt;

&lt;h2 id=&quot;batch-add-user-travis-to-administrators-group&quot;&gt;BATCH: Add user travis to administrators group&lt;/h2&gt;
&lt;p&gt;net localgroup administrators travis /add&lt;/p&gt;

&lt;h2 id=&quot;batch-list-user-accounts-1&quot;&gt;BATCH: List user accounts&lt;/h2&gt;
&lt;p&gt;net user&lt;/p&gt;

&lt;h2 id=&quot;batch-map-a-network-share-with-a-given-drive-letter-of-t&quot;&gt;BATCH: Map a network share with a given drive letter of T:&lt;/h2&gt;
&lt;p&gt;net use T: \serverNameOrIP\shareName&lt;/p&gt;

&lt;h2 id=&quot;batch-list-network-connections-and-the-programs-that-are-making-those-connections&quot;&gt;BATCH: List network connections and the programs that are making those connections&lt;/h2&gt;
&lt;p&gt;netstat -nba&lt;/p&gt;

&lt;h2 id=&quot;batch-display-contents-of-file-texttxt&quot;&gt;BATCH: Display contents of file text.txt&lt;/h2&gt;
&lt;p&gt;type text.txt&lt;/p&gt;

&lt;h2 id=&quot;batch-determine-pc-name&quot;&gt;BATCH: Determine PC name&lt;/h2&gt;
&lt;p&gt;hostname&lt;/p&gt;

&lt;h2 id=&quot;batch-run-cmdexe-as-administrator-user&quot;&gt;BATCH: Run cmd.exe as administrator user&lt;/h2&gt;
&lt;p&gt;runas /user:administrator cmd&lt;/p&gt;

&lt;h2 id=&quot;batch-determine-whether-a-system-is-32-or-64-bit&quot;&gt;BATCH: Determine whether a system is 32 or 64 bit&lt;/h2&gt;
&lt;p&gt;wmic cpu get DataWidth /format:list&lt;/p&gt;

&lt;h2 id=&quot;batch-information-about-os-version-and-other-useful-system-information&quot;&gt;BATCH: Information about OS version and other useful system information&lt;/h2&gt;
&lt;p&gt;systeminformation&lt;/p&gt;

&lt;h2 id=&quot;batch-startup-applications&quot;&gt;BATCH: Startup applications&lt;/h2&gt;
&lt;p&gt;wmic startup get caption,command&lt;/p&gt;

&lt;h2 id=&quot;batch-recursively-unzip-all-zip-folders-youll-need-unzipexe-for-this&quot;&gt;BATCH: Recursively unzip all zip folders, you’ll need unzip.exe for this&lt;/h2&gt;
&lt;p&gt;FOR /R %a (*.zip) do unzip -d unzipDir “%a”&lt;/p&gt;

&lt;h2 id=&quot;batch-variable-extraction&quot;&gt;BATCH: Variable extraction&lt;/h2&gt;
&lt;p&gt;Syntax
      %variable:~num_chars_to_skip%
      %variable:~num_chars_to_skip,num_chars_to_keep%&lt;/p&gt;

&lt;p&gt;This can include negative numbers:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  %variable:~num_chars_to_skip,-num_chars_to_keep%
  %variable:~-num_chars_to_skip,num_chars_to_keep%
  %variable:~-num_chars_to_skip,-num_chars_to_keep%
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;batch-start-at-the-first-character-of-a-variable-reading-left-to-right-position-0-aka-the-left-most-character-and-echo-5-characters-starting-from-there-this-command-will-output-abcde&quot;&gt;BATCH: Start at the first character of a variable (reading left-to-right, position 0, AKA the left-most character) and echo 5 characters starting from there. This command will output ‘abcde’&lt;/h2&gt;
&lt;p&gt;set ALPHABET=abcdefghijklmnopqrstuvwxyz
echo %ALPHABET:~0,5%
abcde&lt;/p&gt;

&lt;h2 id=&quot;batch-start-at-the-fifth-character-of-a-variable-reading-left-to-right-and-echo-3-characters-starting-from-there-this-command-will-output-fgh&quot;&gt;BATCH: Start at the fifth character of a variable (reading left-to-right) and echo 3 characters starting from there. This command will output ‘fgh’&lt;/h2&gt;
&lt;p&gt;set ALPHABET=abcdefghijklmnopqrstuvwxyz
echo %ALPHABET:~5,3%
fgh&lt;/p&gt;

&lt;h2 id=&quot;batch-start-at-the-first-character-of-a-variable-reading-left-to-right-position-0-aka-the-left-most-character-and-echo-all-characters-except-omit-the-last-2-characters-this-command-will-output-abcdefghijklmnopqrstuvwxyz&quot;&gt;BATCH: Start at the first character of a variable (reading left-to-right, position 0, AKA the left-most character) and echo all characters EXCEPT omit the last 2 characters. This command will output ‘abcdefghijklmnopqrstuvwxyz’&lt;/h2&gt;
&lt;p&gt;set ALPHABET=abcdefghijklmnopqrstuvwxyz
echo %ALPHABET:~0,-2%
abcdefghijklmnopqrstuvwxyz&lt;/p&gt;

&lt;h2 id=&quot;batch-find-all-files-bigger-than-100mb-starting-at-c&quot;&gt;BATCH: Find all files bigger than 100MB starting at C:\&lt;/h2&gt;
&lt;p&gt;forfiles /P C:\ /S /M * /C “cmd /c if @fsize GEQ 104857600 echo @path”&lt;/p&gt;

&lt;h2 id=&quot;batch-find-all-files-bigger-than-1gb-starting-at-c&quot;&gt;BATCH: Find all files bigger than 1GB starting at C:\&lt;/h2&gt;
&lt;p&gt;forfiles /P C:\ /S /M * /C “cmd /c if @fsize GEQ 1073741824 echo @path”&lt;/p&gt;

&lt;h2 id=&quot;batch-find-all-files-greater-than-200mb-and-modified-since-01172016&quot;&gt;BATCH: Find all files greater than 200MB and modified since 01/17/2016&lt;/h2&gt;
&lt;p&gt;forfiles /P D:\ /M &lt;em&gt;.&lt;/em&gt; /S /D +”01/17/2016” /C “cmd /c if @fsize gtr 209715200 echo @path @fsize @fdate @ftime”&lt;/p&gt;</content><author><name>Bertland Hope</name></author><summary type="html">BATCH: Get the date into ISO 8601 standard date format (yyyy-mm-dd) and store it in the “CUR_DATE” variable FOR /f %%a in (‘WMIC OS GET LocalDateTime ^| find “.”’) DO set DTS=%%a set CUR_DATE=%DTS:~0,4%-%DTS:~4,2%-%DTS:~6,2%</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://upload.wikimedia.org/wikipedia/commons/2/29/Linux_command-line._Bash._GNOME_Terminal._screenshot.png" /><media:content medium="image" url="https://upload.wikimedia.org/wikipedia/commons/2/29/Linux_command-line._Bash._GNOME_Terminal._screenshot.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">User Profile Size</title><link href="https://bertlandh.github.io/computer_life_support/2022/09/11/User-Profile-Size/" rel="alternate" type="text/html" title="User Profile Size" /><published>2022-09-11T17:00:00+00:00</published><updated>2022-09-11T17:00:00+00:00</updated><id>https://bertlandh.github.io/computer_life_support/2022/09/11/User-Profile-Size</id><content type="html" xml:base="https://bertlandh.github.io/computer_life_support/2022/09/11/User-Profile-Size/">&lt;p&gt;Recursively scans every folder in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\Users&lt;/code&gt;, then adds up the size of every file to get an approximate size for every user’s profile.&lt;/p&gt;

&lt;p&gt;This scanner may take a while to run!&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ErrorActionPreference = &quot;SilentlyContinue&quot;

$UserFolders = Get-ChildItem -Path &quot;C:\Users&quot; -Force -Directory

ForEach ( $Folder in $UserFolders ) {

	[UInt64]$FolderSize = ( Get-Childitem -Path $Folder.FullName -Force -Recurse | Measure-Object -Property &quot;Length&quot; -Sum ).Sum
	
	[PSCustomObject]@{
		FolderName    = $Folder.BaseName
		FolderPath    = $Folder.FullName
		Size          = $FolderSize
	}

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Bertland Hope</name></author><summary type="html">Recursively scans every folder in C:\Users, then adds up the size of every file to get an approximate size for every user’s profile.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://upload.wikimedia.org/wikipedia/commons/a/af/User_profile_personal_details.png" /><media:content medium="image" url="https://upload.wikimedia.org/wikipedia/commons/a/af/User_profile_personal_details.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">User Sessions</title><link href="https://bertlandh.github.io/computer_life_support/2022/09/11/User-Sessions/" rel="alternate" type="text/html" title="User Sessions" /><published>2022-09-11T14:00:00+00:00</published><updated>2022-09-11T14:00:00+00:00</updated><id>https://bertlandh.github.io/computer_life_support/2022/09/11/User-Sessions</id><content type="html" xml:base="https://bertlandh.github.io/computer_life_support/2022/09/11/User-Sessions/">&lt;p&gt;Calculates how long users were logged in based on audit events.&lt;/p&gt;

&lt;h1 id=&quot;requirements&quot;&gt;Requirements&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;Enable “Audit logon events” in Group Policy.
    &lt;ul&gt;
      &lt;li&gt;Windows Settings\Security Settings\Local Policies\Audit Policy&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Configure your retention policy to keep the amount of history you want.
    &lt;ul&gt;
      &lt;li&gt;Administrative Templates\Windows Components\Event Log Service\Security&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;parameters&quot;&gt;Parameters&lt;/h1&gt;

&lt;h2 id=&quot;lowercase&quot;&gt;Lowercase&lt;/h2&gt;

&lt;p&gt;Transforms the Username field to lowercase so it groups properly in Inventory. If you don’t want this behavior, remove &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-Lowercase&lt;/code&gt; from the Parameters field.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[CmdletBinding()]
param (
	[Switch]$Lowercase
)

$Logons = @{}
$LogonTypes = @{
	2  = 'Local'
	10 = 'Remote'
}
$IndexTable = @{
	4624 = @{
		'AccountName' = 5
		'LogonId'     = 7
	}
	4647 = @{
		'AccountName' = 1
		'LogonId'     = 3
	}
}
$Params = @{
	'LogName'     = 'Security'
	'InstanceId'  = [Array]$IndexTable.Keys
	'ErrorAction' = 'SilentlyContinue'
}

# Query all logon and logoff events.
Get-EventLog @Params | ForEach-Object {

	$EventMessage = $_
	$TimeGenerated = $EventMessage.TimeGenerated
	# InstanceId is Int64, but hashtable keys have to be Int32.
	$InstanceId = [Int32]$EventMessage.InstanceId
	$IndexData = $IndexTable.$InstanceId
	$AccountName = $EventMessage.ReplacementStrings[$IndexData.AccountName]
	$LogonId = $EventMessage.ReplacementStrings[$IndexData.LogonId]

	# Skip Windows service accounts.
	if ( $AccountName -match '^(DWM|UMFD)-\d' ) {

		Return

	}

	# Make usernames lowercase so they group properly in Inventory.
	if ( $Lowercase ) {

		$AccountName = $AccountName.ToLower()

	}

	switch ( $InstanceId ) {

		# Logoff.
		4647 {

			# Temporarily store the time and Id in a hashtable so it can be matched to its logon event.
			$Logons.$AccountName = @{
				'Time' = $TimeGenerated
				'Id'   = $LogonId
			}

		}

		# Logon.
		4624 {

			# Skip this logon event if there's no logoff event with a matching username.
			if ( -not $Logons.$AccountName ) {

				Return

			}

			$SessionData = $Logons.$AccountName

			# Skip logon events that don't match the logoff event's Logon ID.
			if ( $SessionData.Id -ne $LogonId ) {

				Return

			}

			$LogonType = [Int32]$EventMessage.ReplacementStrings[8]

			# Skip logon events that don't match the list of logon types.
			if ( $LogonType -notin $LogonTypes.Keys ) {

				Write-Verbose &quot;Skipping ID $LogonId because it is Logon Type $LogonType&quot;
				Return

			}
			
			$SessionLength = $SessionData.Time - $TimeGenerated
			$Logons.Remove($AccountName)

			[PSCustomObject]@{
				'Username'       = $AccountName
				'Logon Time'     = $TimeGenerated
				'Logoff Time'    = $SessionData.Time
				'Session Length' = $SessionLength
				'Logon Type'     = $LogonTypes.$LogonType
				'Logon ID'       = $LogonId
			} 

		}

	} 

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Bertland Hope</name></author><summary type="html">Calculates how long users were logged in based on audit events.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5b/HTTP_logo.svg/1024px-HTTP_logo.svg.png" /><media:content medium="image" url="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5b/HTTP_logo.svg/1024px-HTTP_logo.svg.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Windows Package Manager Client</title><link href="https://bertlandh.github.io/computer_life_support/2022/09/07/winget/" rel="alternate" type="text/html" title="Windows Package Manager Client" /><published>2022-09-07T14:00:00+00:00</published><updated>2022-09-07T14:00:00+00:00</updated><id>https://bertlandh.github.io/computer_life_support/2022/09/07/winget</id><content type="html" xml:base="https://bertlandh.github.io/computer_life_support/2022/09/07/winget/">&lt;p&gt;This repository contains the source code for the Windows Package Manager Client.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;.github/images/WingetInstall.gif&quot; alt=&quot;winget install wingetcreate&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If you are new to the Windows Package Manager, you might want to &lt;a href=&quot;https://docs.microsoft.com/learn/modules/explore-windows-package-manager-tool/?WT.mc_id=AZ-MVP-5004737&quot;&gt;Explore the Windows Package Manager tool&lt;/a&gt;. The packages available to the client are in the &lt;a href=&quot;https://github.com/microsoft/winget-pkgs&quot;&gt;Windows Package Manager Community Repository&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;installing-the-client&quot;&gt;Installing The Client&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;The client requires Windows 10 1809 (build 17763) or later at this time. Windows Server 2019 is not supported as the Microsoft Store is not available nor are updated dependencies. It may be possible to install on Windows Server 2022, this should be considered experimental (not supported), and requires dependencies to be manually installed as well.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;microsoft-store-recommended&quot;&gt;Microsoft Store [Recommended]&lt;/h3&gt;

&lt;p&gt;The client is distributed within the &lt;a href=&quot;https://www.microsoft.com/p/app-installer/9nblggh4nns1&quot;&gt;App Installer&lt;/a&gt; package.&lt;/p&gt;

&lt;h3 id=&quot;development-releases&quot;&gt;Development Releases&lt;/h3&gt;

&lt;p&gt;There are two methods to get development releases:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Install a &lt;a href=&quot;https://insider.windows.com/&quot;&gt;Windows 10 or Windows 11 Insider&lt;/a&gt; build.&lt;/li&gt;
  &lt;li&gt;Join the Windows Package Manager Insider program by &lt;a href=&quot;http://aka.ms/winget-InsiderProgram&quot;&gt;signing up&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: it may take a few days to get the updated App Installer after you receive e-mail confirmation from joining the Windows Package Manager Insider program. If you decide to install the latest release from GitHub, and you have successfully joined the insider program, you will receive updates when the next development release has been published in the Microsoft Store.&lt;/p&gt;

&lt;p&gt;Once you have received the updated App Installer from the Microsoft Store you should be able to execute &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;winget features&lt;/code&gt; to see experimental features. Some users have reported &lt;a href=&quot;https://github.com/microsoft/winget-cli/issues/210&quot;&gt;issues&lt;/a&gt; with the client not being on their PATH.&lt;/p&gt;

&lt;h3 id=&quot;manually-update&quot;&gt;Manually Update&lt;/h3&gt;

&lt;p&gt;The same Microsoft Store package will be made available via our &lt;a href=&quot;https://github.com/microsoft/winget-cli/releases&quot;&gt;Releases&lt;/a&gt;. Note that installing this package will give you the WinGet client, but it will not enable automatic updates from the Microsoft Store if you have not joined the Windows Package Manager Insider program.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;You may need to install the &lt;a href=&quot;https://docs.microsoft.com/troubleshoot/cpp/c-runtime-packages-desktop-bridge#how-to-install-and-update-desktop-framework-packages&quot;&gt;VC++ v14 Desktop Framework Package&lt;/a&gt;.
This should only be necessary on older builds of Windows 10 and only if you get an error about missing framework packages.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;troubleshooting&quot;&gt;Troubleshooting&lt;/h3&gt;

&lt;p&gt;Please read our &lt;a href=&quot;/doc/troubleshooting/README.md&quot;&gt;troubleshooting guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;administrator-considerations&quot;&gt;Administrator Considerations&lt;/h2&gt;

&lt;p&gt;Installer behavior can be different depending on whether you are running &lt;strong&gt;winget&lt;/strong&gt; with administrator privileges.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;When running &lt;strong&gt;winget&lt;/strong&gt; without administrator privileges, some applications may &lt;a href=&quot;https://docs.microsoft.com/windows/security/identity-protection/user-account-control/how-user-account-control-works&quot;&gt;require elevation&lt;/a&gt; to install. When the installer runs, Windows will prompt you to &lt;a href=&quot;https://docs.microsoft.com/windows/security/identity-protection/user-account-control/how-user-account-control-works#the-uac-user-experience&quot;&gt;elevate&lt;/a&gt;. If you choose not to elevate, the application will fail to install.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;When running &lt;strong&gt;winget&lt;/strong&gt; in an Administrator Command Prompt, you will not see &lt;a href=&quot;https://docs.microsoft.com/windows/security/identity-protection/user-account-control/how-user-account-control-works#the-uac-user-experience&quot;&gt;elevation prompts&lt;/a&gt; if the application requires it. Always use caution when running your command prompt as an administrator, and only install applications you trust.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;build-your-own&quot;&gt;Build your own&lt;/h3&gt;

&lt;p&gt;You can also &lt;a href=&quot;#building-the-client&quot;&gt;build the client yourself&lt;/a&gt;. While the client should be perfectly functional, we are not ready to provide full support for clients running outside of the official distribution mechanisms yet. Feel free to file an Issue, but know that it may get lower prioritization.&lt;/p&gt;

&lt;h2 id=&quot;build-status&quot;&gt;Build Status&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://dev.azure.com/ms/winget-cli/_build/latest?definitionId=344&amp;amp;branchName=master&quot;&gt;&lt;img src=&quot;https://dev.azure.com/ms/winget-cli/_apis/build/status/microsoft.winget-cli?branchName=master&quot; alt=&quot;Build Status&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;windows-package-manager-release-roadmap&quot;&gt;Windows Package Manager Release Roadmap&lt;/h2&gt;
&lt;p&gt;The plan for delivering next Windows Package Manager releases is described included in our &lt;a href=&quot;https://github.com/microsoft/winget-cli/discussions/2063&quot;&gt;discussions&lt;/a&gt;, and will be updated as the project proceeds.&lt;/p&gt;

&lt;h2 id=&quot;overview-of-the--windows-package-manager&quot;&gt;Overview of the  Windows Package Manager&lt;/h2&gt;
&lt;p&gt;The &lt;strong&gt;Windows Package Manager&lt;/strong&gt; is a tool designed to help you quickly and easily discover and install those packages that make your PC environment special.  By using the &lt;strong&gt;Windows Package Manager&lt;/strong&gt;, from one command, you can install your favorite packages:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;winget install &amp;lt;package&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;

&lt;h3 id=&quot;client-repository&quot;&gt;Client Repository&lt;/h3&gt;
&lt;p&gt;This winget-cli repository includes the source code designed to build the client.  You are encouraged to participate in the development of this client. We have plenty of backlog features in our &lt;a href=&quot;https://github.com/microsoft/winget-cli/issues&quot;&gt;Issues&lt;/a&gt;. You can upvote the ones you want, add more, or even &lt;a href=&quot;https://github.com/microsoft/winget-cli/projects/1&quot;&gt;get started on one.&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;sources&quot;&gt;Sources&lt;/h3&gt;
&lt;p&gt;The client is built around the concept of sources; a set of packages effectively. Sources provide the ability to discover and retrieve the metadata about the packages, so that the client can act on it.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The default “winget” source includes packages in the &lt;a href=&quot;https://github.com/microsoft/winget-pkgs&quot;&gt;Windows Package Manager Community Repository&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;The default “msstore” source includes packages in the Microsoft Store.&lt;/li&gt;
  &lt;li&gt;It is also possible to host your own private &lt;a href=&quot;https://github.com/microsoft/winget-cli-restsource&quot;&gt;REST based&lt;/a&gt; source.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;building-the-client&quot;&gt;Building the client&lt;/h2&gt;

&lt;h3 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Windows 10 1809 (17763) or later&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/windows/uwp/get-started/enable-your-device-for-development&quot;&gt;Developer Mode enabled&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://visualstudio.microsoft.com/downloads/&quot;&gt;Visual Studio 2022&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;Or use winget to install it ;) (although you may need to adjust the workloads via Tools-&amp;gt;Get Tools and Features…)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;The following workloads:
    &lt;ul&gt;
      &lt;li&gt;.NET Desktop Development&lt;/li&gt;
      &lt;li&gt;Desktop Development with C++&lt;/li&gt;
      &lt;li&gt;Universal Windows Platform Development&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;The following extensions:
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=VisualStudioClient.MicrosoftVisualStudio2022InstallerProjects&quot;&gt;Microsoft Visual Studio Installer Projects&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;building&quot;&gt;Building&lt;/h3&gt;

&lt;p&gt;We currently only build using the solution; command line methods of building a VS solution should work as well.&lt;/p&gt;

&lt;h2 id=&quot;credit&quot;&gt;Credit&lt;/h2&gt;

&lt;p&gt;We would like to thank &lt;a href=&quot;https://github.com/kayone&quot;&gt;Keivan Beigi (@kayone)&lt;/a&gt; for his work on AppGet which helped us on the initial project direction for Windows Package Manager.&lt;/p&gt;

&lt;h2 id=&quot;contributing&quot;&gt;Contributing&lt;/h2&gt;

&lt;p&gt;This project welcomes contributions and suggestions.  Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. More 
information is available in our &lt;a href=&quot;/CONTRIBUTING.md&quot;&gt;CONTRIBUTING.md&lt;/a&gt; file.&lt;/p&gt;

&lt;p&gt;When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.&lt;/p&gt;

&lt;p&gt;This project has adopted the &lt;a href=&quot;https://opensource.microsoft.com/codeofconduct/&quot;&gt;Microsoft Open Source Code of Conduct&lt;/a&gt;.
For more information, please refer to the &lt;a href=&quot;https://opensource.microsoft.com/codeofconduct/faq/&quot;&gt;Code of Conduct FAQ&lt;/a&gt; or
contact &lt;a href=&quot;mailto:opencode@microsoft.com&quot;&gt;opencode@microsoft.com&lt;/a&gt; with any additional questions or comments.&lt;/p&gt;

&lt;h2 id=&quot;datatelemetry&quot;&gt;Data/Telemetry&lt;/h2&gt;

&lt;p&gt;The winget.exe client is instrumented to collect usage and diagnostic (error) data and sends it to Microsoft to help improve the product.&lt;/p&gt;

&lt;p&gt;If you build the client yourself the instrumentation will not be enabled and no data will be sent to Microsoft.&lt;/p&gt;

&lt;p&gt;The winget.exe client respects machine wide privacy settings and users can opt-out on their device, as documented in the Microsoft Windows privacy statement &lt;a href=&quot;https://support.microsoft.com/help/4468236/diagnostics-feedback-and-privacy-in-windows-10-microsoft-privacy&quot;&gt;here&lt;/a&gt;. In addition, you may also explicitly block telemetry using &lt;a href=&quot;https://docs.microsoft.com/windows/package-manager/winget/settings&quot;&gt;settings&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In short to opt-out, go to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Start&lt;/code&gt;, then select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Settings&lt;/code&gt; &amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Privacy&lt;/code&gt; &amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Diagnostics &amp;amp; feedback&lt;/code&gt;, and select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Basic&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;See the &lt;a href=&quot;privacy.md&quot;&gt;privacy statement&lt;/a&gt; for more details.&lt;/p&gt;</content><author><name>Bertland Hope</name></author><summary type="html">This repository contains the source code for the Windows Package Manager Client.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bertlandh.github.io/computer_life_support/img/statue-1979.1014.png" /><media:content medium="image" url="https://bertlandh.github.io/computer_life_support/img/statue-1979.1014.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Chocolatey CLI (choco)</title><link href="https://bertlandh.github.io/computer_life_support/2022/06/11/choco/" rel="alternate" type="text/html" title="Chocolatey CLI (choco)" /><published>2022-06-11T12:30:00+00:00</published><updated>2022-06-11T12:30:00+00:00</updated><id>https://bertlandh.github.io/computer_life_support/2022/06/11/choco</id><content type="html" xml:base="https://bertlandh.github.io/computer_life_support/2022/06/11/choco/">&lt;p&gt;Chocolatey installs in seconds. You are just a few steps from running choco right now!&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;First, ensure that you are using an administrative shell - you can also install as a non-admin, check out Non-Administrative Installation.&lt;/li&gt;
  &lt;li&gt;Copy the text specific to your command shell - cmd.exe or powershell.exe.&lt;/li&gt;
  &lt;li&gt;Paste the copied text into your shell and press Enter.&lt;/li&gt;
  &lt;li&gt;Wait a few seconds for the command to complete.&lt;/li&gt;
  &lt;li&gt;If you don’t see any errors, you are ready to use Chocolatey! Type choco or choco -? now, or see Getting Started for usage instructions.&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;requirements&quot;&gt;Requirements&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;Windows 7+ / Windows Server 2003+&lt;/li&gt;
  &lt;li&gt;PowerShell v2+ (Not PowerShell Core yet though)(minimum is v3 for install from this website due to TLS 1.2 requirement)&lt;/li&gt;
  &lt;li&gt;.NET Framework 4+ (the installation will attempt to install .NET 4.0 if you do not have it installed)(minimum is 4.5 for install from this website due to TLS 1.2 requirement)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s it! All you need is choco.exe (that you get from the installation scripts) and you are good to go! No Visual Studio required.&lt;/p&gt;

&lt;h2 id=&quot;install-with-cmdexe&quot;&gt;Install with cmd.exe&lt;/h2&gt;

&lt;p&gt;Run the following command:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@&quot;%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe&quot; -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command &quot;[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))&quot; &amp;amp;&amp;amp; SET &quot;PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin&quot;&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;install-with-powershellexe&quot;&gt;Install with PowerShell.exe&lt;/h2&gt;

&lt;p&gt;With PowerShell, there is an additional step. You must ensure Get-ExecutionPolicy is not Restricted. We suggest using Bypass to bypass the policy to get things installed or AllSigned for quite a bit more security.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Get-ExecutionPolicy&lt;/code&gt;. If it returns &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Restricted&lt;/code&gt;, then run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Set-ExecutionPolicy AllSigned&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Set-ExecutionPolicy Bypass -Scope Process&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Now run the following command
:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))&lt;/code&gt;&lt;/p&gt;</content><author><name>Bertland Hope</name></author><summary type="html">Chocolatey installs in seconds. You are just a few steps from running choco right now!</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bertlandh.github.io/computer_life_support/img/Welding_sparkles.jpg" /><media:content medium="image" url="https://bertlandh.github.io/computer_life_support/img/Welding_sparkles.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">User Last Logged On</title><link href="https://bertlandh.github.io/computer_life_support/2022/02/17/User-Last-Logged-On/" rel="alternate" type="text/html" title="User Last Logged On" /><published>2022-02-17T18:00:00+00:00</published><updated>2022-02-17T18:00:00+00:00</updated><id>https://bertlandh.github.io/computer_life_support/2022/02/17/User-Last-Logged-On</id><content type="html" xml:base="https://bertlandh.github.io/computer_life_support/2022/02/17/User-Last-Logged-On/">&lt;p&gt;Queries the Security Event Log to determine the last time each user logged on to the target machine.&lt;/p&gt;

&lt;h1 id=&quot;requirements&quot;&gt;Requirements&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;Enable “Audit logon events” in Group Policy
    &lt;ul&gt;
      &lt;li&gt;Windows Settings\Security Settings\Local Policies\Audit Policy&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Configure your retention policy to keep the amount of history you want
    &lt;ul&gt;
      &lt;li&gt;Administrative Templates\Windows Components\Event Log Service\Security&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;parameters&quot;&gt;Parameters&lt;/h1&gt;

&lt;h2 id=&quot;lowercase&quot;&gt;Lowercase&lt;/h2&gt;

&lt;p&gt;Transforms the Username field to lowercase so it groups properly in Inventory. If you don’t want this behavior, remove &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-Lowercase&lt;/code&gt; from the Parameters field.&lt;/p&gt;

&lt;h1 id=&quot;this-script-requires-that-audit-logon-events-are-enabled-in-group-policy-and-those-events-are-kept-for-the-amount-of-history-preferred&quot;&gt;This script requires that Audit Logon events are enabled in Group Policy and those events are kept for the amount of history preferred&lt;/h1&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[CmdletBinding()]
param (
	[Switch]$Lowercase
)

$UserArray = New-Object System.Collections.ArrayList
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;query-all-logon-events-with-id-4624&quot;&gt;Query all logon events with id 4624&lt;/h1&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Get-EventLog -LogName &quot;Security&quot; -InstanceId 4624 -ErrorAction &quot;SilentlyContinue&quot; | ForEach-Object {

	$EventMessage = $_
	$AccountName = $EventMessage.ReplacementStrings[5]
	$LogonType = $EventMessage.ReplacementStrings[8]

	if ( $Lowercase ) {

		# Make all usernames lowercase so they group properly in Inventory
		$AccountName = $AccountName.ToLower()

	}

	# Look for events that contain local or remote logon events, while ignoring Windows service accounts
	if ( ( $LogonType -in &quot;2&quot;, &quot;10&quot; ) -and ( $AccountName -notmatch &quot;^(DWM|UMFD)-\d&quot; ) ) {
	
		# Skip duplicate names
		if ( $UserArray -notcontains $AccountName ) {

			$null = $UserArray.Add($AccountName)
			
			# Translate the Logon Type
			if ( $LogonType -eq &quot;2&quot; ) {

				$LogonTypeName = &quot;Local&quot;

			} elseif ( $LogonType -eq &quot;10&quot; ) {

				$LogonTypeName = &quot;Remote&quot;

			}

			# Build an object containing the Username, Logon Type, and Last Logon time
			[PSCustomObject]@{
				Username  = $AccountName
				LogonType = $LogonTypeName
				LastLogon = [DateTime]$EventMessage.TimeGenerated.ToString(&quot;yyyy-MM-dd HH:mm:ss&quot;)
			}  

		}

	}

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Bertland Hope</name></author><summary type="html">Queries the Security Event Log to determine the last time each user logged on to the target machine.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://bertlandh.github.io/computer_life_support/img/qt_py_rp2040.jpg" /><media:content medium="image" url="https://bertlandh.github.io/computer_life_support/img/qt_py_rp2040.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>