{"id":64,"date":"2006-11-13T13:30:00","date_gmt":"2006-11-13T17:30:00","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/2006\/11\/13\/more-one-liners\/"},"modified":"2013-07-02T08:11:36","modified_gmt":"2013-07-02T12:11:36","slug":"more-one-liners","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/64\/more-one-liners\/","title":{"rendered":"More One Liners"},"content":{"rendered":"<p>I recently did a <a href=\"http:\/\/www.mcpmag.com\/columns\/article.asp?EditorialsID=1535\">TipSheet column<\/a> listing some of my favorite quick, one line commands. Reader Wayne was kind enough to share with me his list of oft-used one-liners which he graciously offered to share.  I have not tested many of these personally, but you always test things in a non-production environment anyway, right? The command entry should all be on one line. I've wrapped lines just to get everything displayed in the post.<br \/><span style=\"color: rgb(51, 51, 255);\">FSMO Roles          <\/span><br \/>ntdsutil roles Connections \"Connect to server %logonserver%\" Quit \"select Operation Target\" \"List roles for conn server\" Quit Quit Quit<br \/>[JDH: This is really a series of steps, not a single command<br \/>expression]<br \/><span style=\"color: rgb(0, 0, 153);\">Domain Controllers        <\/span><br \/>Nltest \/dclist:%userdnsdomain%<br \/><span style=\"color: rgb(0, 0, 153);\">Domain Controller IP Configuration       <\/span><br \/>for \/f %i in ('dsquery server -domain %userdnsdomain% -o rdn') do psexec \\\\%i ipconfig \/all<br \/><span style=\"color: rgb(0, 0, 153);\">Stale computer accounts        <\/span><br \/>dsquery computer domainroot -stalepwd 180 -limit 0<br \/><span style=\"color: rgb(0, 0, 153);\">Stale user accounts        <\/span><br \/> dsquery user domainroot -stalepwd 180 -limit 0<br \/><span style=\"color: rgb(0, 0, 153);\">Disabled user accounts        <\/span><br \/> dsquery user domainroot -disabled -limit 0<br \/><span style=\"color: rgb(0, 0, 153);\">AD Database disk usage        <\/span><br \/> for \/f %i in ('dsquery server -domain %userdnsdomain% -o rdn') do dir \\\\%i\\admin$\\ntds<br \/><span style=\"color: rgb(0, 0, 153);\">Global Catalog Servers from DNS       <\/span><br \/> dnscmd %logonserver% \/enumrecords %userdnsdomain% _tcp | find \/i \"3268\"<br \/><span style=\"color: rgb(0, 0, 153);\">Global Catalog Servers from AD       <\/span><br \/> dsquery * \"CN=Configuration,DC=forestRootDomain\" -filter <span style=\"color: rgb(0, 0, 153);\">\"(&(objectCategory=nTDSDSA)(options:1.2.840.113556.1.4.803:=1))\"<\/span><br \/><span style=\"color: rgb(0, 0, 153);\">Users with no logon script       <\/span><br \/> dsquery * domainroot -filter \"(&(objectCategory=Person)(objectClass=User)(!scriptPath=*))\" -limit 0 -attr sAMAccountName sn givenName pwdLastSet distinguishedName<br \/><span style=\"color: rgb(0, 0, 153);\">User accounts with no pwd required      <\/span><br \/> dsquery * domainroot -filter \"(&(objectCategory=Person)(objectClass=User)(userAccountControl:1.2.840.113556.1.4.803:=32))\"<br \/><span style=\"color: rgb(0, 0, 153);\">User accounts with no pwd expiry      <\/span><br \/> dsquery * domainroot -filter \"(&(objectCategory=Person)(objectClass=User)(userAccountControl:1.2.840.113556.1.4.803:=65536))\"<br \/><span style=\"color: rgb(0, 0, 153);\">User accounts that are disabled       <\/span><br \/> dsquery * domainroot -filter \"(&(objectCategory=Person)(objectClass=User)(userAccountControl:1.2.840.113556.1.4.803:=2))\"<br \/><span style=\"color: rgb(0, 0, 153);\">DNS Information         <\/span><br \/> for \/f %i in ('dsquery server -domain %userdnsdomain% -o rdn') do dnscmd %i \/info<br \/><span style=\"color: rgb(0, 0, 153);\">DNS Zone Detailed information       <\/span><br \/> dnscmd \/zoneinfo %userdnsdomain%<br \/><span style=\"color: rgb(0, 0, 153);\">Garbage Collection and tombstone      <\/span><br \/> dsquery * \"cn=Directory Service,cn=Windows NT,cn=Services,cn=Configuration,DC=forestRootDomain\" -attr garbageCollPeriod tombstoneLifetime<br \/><span style=\"color: rgb(0, 0, 153);\">Netsh authorised DHCP Servers        <\/span><br \/> netsh dhcp show server<br \/><span style=\"color: rgb(0, 0, 153);\">DSQuery authorised DHCP Servers       <\/span><br \/> Dsquery * \"cn=NetServices,cn=Services,cn=Configuration, DC=forestRootDomain\" -attr dhcpServers<br \/><span style=\"color: rgb(0, 0, 153);\">DHCP server information        <\/span><br \/> netsh dhcp server \\\\DHCP_SERVER show all<br \/><span style=\"color: rgb(0, 0, 153);\">DHCP server dump        <\/span><br \/> netsh dhcp server \\\\DHCP_SERVER dump<br \/><span style=\"color: rgb(0, 0, 153);\">WINS serer information        <\/span><br \/> Netsh wins server \\\\WINS_SERVER dump<br \/><span style=\"color: rgb(0, 0, 153);\">Group Policy Verification Tool        <\/span><br \/> gpotool.exe \/checkacl \/verbose<br \/><span style=\"color: rgb(0, 0, 153);\">AD OU membership        <\/span><br \/> dsquery computer -limit 0<br \/><span style=\"color: rgb(0, 0, 153);\">AD OU membership        <\/span><br \/> dsquery user -limit 0<br \/><span style=\"color: rgb(0, 0, 153);\">List Service Principal Names       <\/span><br \/> for \/f %i in ('dsquery server -domain %userdnsdomain% -o rdn') do setspn -L %i<br \/><span style=\"color: rgb(0, 0, 153);\">Compare DC Replica Object Count       <\/span><br \/> dsastat \u2013s:DC1;DC2;... \u2013b:Domain \u2013gcattrs:objectclass \u2013p:999<br \/><span style=\"color: rgb(0, 0, 153);\">Check AD ACLs         <\/span><br \/> acldiag dc=domainTree<br \/><span style=\"color: rgb(0, 0, 153);\">NTFRS Replica Sets        <\/span><br \/> for \/f %i in ('dsquery server -domain %userdnsdomain% -o rdn') do  ntfrsutl sets %i<br \/><span style=\"color: rgb(0, 0, 153);\">NTFRS DS View         <\/span><br \/> for \/f %i in ('dsquery server -domain %userdnsdomain% -o rdn') do  ntfrsutl ds %i<br \/><span style=\"color: rgb(0, 0, 153);\">Domain Controllers per site       <\/span><br \/> Dsquery * \"CN=Sites,CN=Configuration,DC=forestRootDomain\" -filter (objectCategory=Server)<br \/><span style=\"color: rgb(0, 0, 153);\">DNS Zones in AD         <\/span><br \/> for \/f %i in ('dsquery server -o rdn') do Dsquery * -s %i domainroot -filter (objectCategory=dnsZone)<br \/><span style=\"color: rgb(0, 0, 153);\">Enumerate DNS Server Zones       <\/span><br \/> for \/f %i in ('dsquery server -o rdn') do dnscmd %i \/enumzones<br \/><span style=\"color: rgb(0, 0, 153);\">Subnet information        <\/span><br \/> Dsquery subnet \u2013limit 0<br \/><span style=\"color: rgb(0, 0, 153);\">List Organisational Units       <\/span><br \/> Dsquery OU<br \/><span style=\"color: rgb(0, 0, 153);\">ACL on all OUs         <\/span><br \/> For \/f \"delims=|\" %i in ('dsquery OU') do acldiag %i<br \/><span style=\"color: rgb(0, 0, 153);\">Domain Trusts         <\/span><br \/> nltest \/domain_trusts \/v<br \/><span style=\"color: rgb(0, 0, 153);\">Print DNS Zones         <\/span><br \/> dnscmd DNSServer \/zoneprint DNSZone<br \/><span style=\"color: rgb(0, 0, 153);\">Active DHCP leases        <\/span><br \/> For \/f %i in (DHCPServers.txt) do for \/f \"delims=- \" %j in ('\"netsh dhcp server \\\\%i show scope | find \/i \"active\"\"') do netsh dhcp server \\\\%i scope %j show clientsv5<br \/><span style=\"color: rgb(0, 0, 153);\">DHCP Server Active Scope  Info       <\/span><br \/> For \/f %i in (DHCPServers.txt) do netsh dhcp server \\\\%i show scope | find \/i \"active\"<br \/><span style=\"color: rgb(0, 0, 153);\">Resolve DHCP clients hostnames        <\/span><br \/> for \/f \"tokens=1,2,3 delims=,\" %i in (Output from 'Find Subnets from DHCP clients') do @for \/f \"tokens=2 delims=: \" %m in ('\"nslookup %j | find \/i \"Name:\"\"') do echo %m,%j,%k,%i<br \/><span style=\"color: rgb(0, 0, 153);\">Find two online PCs per subnet       <\/span><br \/> Echo. > TwoClientsPerSubnet.txt & for \/f \"tokens=1,2,3,4 delims=, \" %i in ('\"find \/i \"pc\" 'Output from Resolve DHCP clients hostnames'\"') 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 -n 1 %i | find \/i \/c \"(0% loss\"\"') do If %p==1 Echo %i,%j,%k,%l<br \/><span style=\"color: rgb(0, 0, 153);\">AD Subnet and Site Information       <\/span><br \/> dsquery * \"CN=Subnets,CN=Sites,CN=Configuration,DC=forestRootDomain\" -attr cn siteObject description location<br \/><span style=\"color: rgb(0, 0, 153);\">AD Site Information        <\/span><br \/> dsquery * \"CN=Sites,CN=Configuration,DC=forestRootDomain\" -attr cn description location -filter (objectClass=site) <br \/><span style=\"color: rgb(0, 0, 153);\">Printer Queue Objects in AD       <\/span><br \/> dsquery * domainroot -filter \"(objectCategory=printQueue)\" -limit 0<br \/><span style=\"color: rgb(0, 0, 153);\">Group Membership with user details      <\/span><br \/> dsget group \"groupDN\" -members | dsget user -samid -fn -mi -ln -display -empid -desc -office -tel -email -title -dept -mgr<br \/><span style=\"color: rgb(0, 0, 153);\">Total DHCP Scopes        <\/span><br \/> find \/i \"subnet\" \"Output from DHCP server information\" | find \/i \"subnet\"  <br \/><span style=\"color: rgb(0, 0, 153);\">Site Links and Cost        <\/span><br \/> dsquery * \"CN=Sites,CN=Configuration,DC=forestRootDomain\" -attr cn cost description replInterval siteList -filter (objectClass=siteLink)<br \/><span style=\"color: rgb(0, 0, 153);\">Time gpresult         <\/span><br \/> timethis gpresult \/v<br \/><span style=\"color: rgb(0, 0, 153);\">Check time against Domain       <\/span><br \/> w32tm \/monitor \/computers:ForestRootPDC<br \/><span style=\"color: rgb(0, 0, 153);\">Domain Controller Diagnostics       <\/span><br \/> dcdiag \/s:%logonserver% \/v \/e \/c<br \/><span style=\"color: rgb(0, 0, 153);\">Domain Replication Bridgeheads       <\/span><br \/> repadmin \/bridgeheads<br \/><span style=\"color: rgb(0, 0, 153);\">Replication Failures from KCC       <\/span><br \/> repadmin \/failcache<br \/><span style=\"color: rgb(0, 0, 153);\">Inter-site Topology servers per site      <\/span><br \/> Repadmin \/istg * \/verbose<br \/><span style=\"color: rgb(0, 0, 153);\">Replication latency<\/span>        <br \/> repadmin \/latency \/verbose<br \/><span style=\"color: rgb(0, 0, 153);\">Queued replication requests       <\/span><br \/> repadmin \/queue *<br \/><span style=\"color: rgb(0, 0, 153);\">Show connections for a DC       <\/span><br \/> repadmin \/showconn *<br \/><span style=\"color: rgb(0, 0, 153);\">Replication summary        <\/span><br \/> Repadmin \/replsummary<br \/><span style=\"color: rgb(0, 0, 153);\">Show replication partners       <\/span><br \/> repadmin \/showrepl * \/all<br \/><span style=\"color: rgb(0, 0, 153);\">All DCs in the forest        <\/span><br \/> repadmin \/viewlist *<br \/><span style=\"color: rgb(0, 0, 153);\">ISTG from AD attributes        <\/span><br \/> dsquery * \"CN=NTDS Site Settings,CN=siteName,CN=Sites,CN=Configuration,DC=forestRootDomain\" -attr interSiteTopologyGenerator <br \/><span style=\"color: rgb(0, 0, 153);\">Return the object if KCC Intra\/Inter site is disabled for each site  <\/span><br \/> Dsquery site | dsquery * -attr * -filter \"(|(Options:1.2.840.113556.1.4.803:=1)(Options:1.2.840.113556.1.4.803:=16))\"<br \/><span style=\"color: rgb(0, 0, 153);\">Find all connection objects       <\/span><br \/> dsquery * forestRoot -filter (objectCategory=nTDSConnection) \u2013attr distinguishedName fromServer whenCreated displayName<br \/><span style=\"color: rgb(0, 0, 153);\">Find all connection schedules        <\/span><br \/> adfind -b \"cn=Configuration,dc=qraps,dc=com,dc=au\" -f \"objectcategory=ntdsConnection\" cn Schedule -csv<br \/><span style=\"color: rgb(0, 0, 153);\">Software Information for each serve<\/span>r      <br \/> for \/f %i in (Output from 'Domain Controllers') do psinfo \\\\%i & 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<br \/>Check Terminal Services Delete Temp on Exit flag    <br \/> For \/f %i in (Output from 'Domain Controllers') do Reg query \"\\\\%i\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server\" \/v DeleteTempDirsOnExit<br \/><span style=\"color: rgb(0, 0, 153);\">For each XP workstation, query the current site and what Group Policy info <\/span><br \/> @dsquery * domainroot -filter \"(&(objectCategory=Computer)(operatingSystem=Windows XP Professional))\" -limit 0 -attr cn > Workstations.txt &amp; @For \/f %i in (Workstations.txt) do @ping %i -n 1 >NUL & @if ErrorLevel 0 If NOT ErrorLevel 1 @Echo %i &amp; for \/f \"tokens=3\" %k in ('\"reg query \"\\\\%i\\hklm\\software\\microsoft\\windows\\currentversion\\group policy\\history\" \/v DCName | Find \/i \"DCName\"\"') do @for \/f %m in ('\"nltest \/server:%i \/dsgetsite | find \/i \/v \"completed successfully\"\"') do @echo %i,%k,%m<br \/><span style=\"color: rgb(0, 0, 153);\">Information on existing GPOs       <\/span><br \/> dsquery * \"CN=Policies,CN=System,domainRoot\" -filter \"(objectCategory=groupPolicyContainer)\" -attr displayName cn whenCreated gPCFileSysPath<br \/><span style=\"color: rgb(0, 0, 153);\">Copy all Group Policy .pol files      <\/span><br \/> for \/f \"tokens=1-8 delims=\\\" %i in ('dir \/b \/s \\\\%userdnsdomain%\\sysvol\\%userdnsdomain%\\policies\\*.pol') do @echo copy \\\\%i\\%j\\%k\\%l\\%m\\%n\\%o %m_%n.pol<br \/><span style=\"color: rgb(0, 0, 153);\">Domain Controller Netlogon entries      <\/span><br \/> for \/f %i in ('dsquery server \/o rdn') do echo %i & reg query \\\\%i\\hklm\\system\\currentcontrolset\\services\\netlogon\\parameters<br \/><span style=\"color: rgb(0, 0, 153);\">WINS Statistics         <\/span><br \/> for \/f \"tokens=1,2 delims=,\" %i in (WINSServers.txt) do netsh wins server \\\\%i show statistics<br \/><span style=\"color: rgb(0, 0, 153);\">WINS Record counts per server       <\/span><br \/> for \/f \"tokens=1,2 delims=,\" %i in (WINSServers.txt) do netsh wins server \\\\%i show reccount <span style=\"color: rgb(0, 0, 153);\">%i<\/span><br \/><span style=\"color: rgb(0, 0, 153);\">WINS Server Information        <\/span><br \/> for \/f \"tokens=2 delims=,\" %i in (WINSServers.txt) do netsh wins server \\\\%i show info<br \/><span style=\"color: rgb(0, 0, 153);\">WINS Server Dump        <\/span><br \/> for \/f \"tokens=2 delims=,\" %i in (WINSServers.txt) do netsh wins server \\\\%i dump<br \/><span style=\"color: rgb(0, 0, 153);\">WINS Static Records per Server       <\/span><br \/> netsh wins server \\\\LocalWINSServer show database servers={} rectype=1<br \/><span style=\"color: rgb(0, 0, 153);\">Find policy display name given the GUID      <\/span><br \/> dsquery * \"CN=Policies,CN=System,DC=domainRoot\" -filter (objectCategory=groupPolicyContainer) -attr Name displayName<br \/><span style=\"color: rgb(0, 0, 153);\">Find empty groups        <\/span><br \/> dsquery * -filter \"&(objectCategory=group)(!member=*)\" -limit 0 -attr whenCreated whenChanged groupType sAMAccountName distinguishedName memberOf<br \/><span style=\"color: rgb(0, 0, 153);\">Find remote NIC bandwidth        <\/span><br \/> wmic \/node:%server% path Win32_PerfRawData_Tcpip_NetworkInterface GET Name,CurrentBandwidth<br \/><span style=\"color: rgb(0, 0, 153);\">Find remote free physical memory       <\/span><br \/> wmic \/node:%Computer% path Win32_OperatingSystem GET FreePhysicalMemory<br \/><span style=\"color: rgb(0, 0, 153);\">Find remote system information       <\/span><br \/> SystemInfo \/s %Computer%<br \/><span style=\"color: rgb(0, 0, 153);\">Disk statistics, including the number of files on the filesystem  <\/span><br \/> chkdsk \/i \/c<br \/><span style=\"color: rgb(0, 0, 153);\">Query IIS web sites        <\/span><br \/> iisweb \/s %Server% \/query \"Default Web Site\"<br \/><span style=\"color: rgb(0, 0, 153);\">Check port state and connectivity      <\/span><br \/> portqry -n %server% -e %endpoint% -v<br \/><span style=\"color: rgb(51, 51, 255);\">Forest\/Domain Functional Levels       <\/span><br \/> ldifde -d cn=partitions,cn=configuration,dc=%domain% -r \"(|(systemFlags=3)(systemFlags=-2147483648))\" -l msds-behavior-version,dnsroot,ntmixeddomain,NetBIOSName -p subtree -f con<br \/><span style=\"color: rgb(0, 0, 153);\">Forest\/Domain Functional Levels       <\/span><br \/> dsquery * cn=partitions,cn=configuration,dc=%domain% -filter \"(|(systemFlags=3)(systemFlags=-2147483648))\" -attr msDS-Behavior-Version Name dnsroot ntmixeddomain NetBIOSName<br \/><span style=\"color: rgb(0, 0, 153);\">Find the parent of a process       <\/span><br \/> wmic path Win32_Process WHERE Name='notepad.exe' GET Name,ParentProcessId<br \/><span style=\"color: rgb(0, 0, 153);\">Lookup SRV records from DNS       <\/span><br \/> nslookup -type=srv _ldap._tcp.dc._msdcs.{domainRoot}<br \/><span style=\"color: rgb(0, 0, 153);\">Find when the AD was installed       <\/span><br \/> dsquery * cn=configuration,DC=forestRootDomain -attr whencreated -scope base<br \/><span style=\"color: rgb(0, 0, 153);\">Enumerate the trusts from the specified domain     <\/span><br \/> dsquery * \"CN=System,DC=domainRoot\" -filter \"(objectClass=trustedDomain)\" -attr trustPartner flatName<br \/><span style=\"color: rgb(0, 0, 153);\">Find a DC for each trusted domain      <\/span><br \/> for \/f \"skip=1\" %i in ('\"dsquery * CN=System,DC=domainRoot -filter (objectClass=trustedDomain) -attr trustPartner\"') do nltest \/dsgetdc:%i<br \/><span style=\"color: rgb(0, 0, 153);\">Check the notification packages installed on all DCs    <\/span><br \/> 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<br \/><span style=\"color: rgb(0, 0, 153);\">List ACLs in SDDL format       <\/span><br \/> setacl -on %filepath% -ot file -actn list -lst f:sddl<br \/><span style=\"color: rgb(0, 0, 153);\">Find out if a user account is currently enabled or disabled   <\/span><br \/> dsquery user DC=%userdnsdomain:.=,DC=% -name %username% | dsget user -disabled -dn<br \/><span style=\"color: rgb(0, 0, 153);\">Find servers in the domain       <\/span><br \/> dsquery * domainroot -filter \"(&(objectCategory=Computer)(objectClass=Computer)(operatingSystem=*Server*))\" -limit 0<br \/><span style=\"color: rgb(0, 0, 153);\">Open DS query window        <\/span><br \/> rundll32 dsquery,OpenQueryWindow<\/p>\n<p>Technorati Tags:<br \/><span style=\"font-size:85%;\">commandshell   <a href=\"http:\/\/www.technoratic.com\/tags\/scripting\" rel=\"tag\">Scripting<\/a> <a href=\"http:\/\/www.technoratic.com\/tags\/dsquery\" rel=\"tag\">DSquery<\/a> <a href=\"http:\/\/www.technoratic.com\/tags\/netsh\" rel=\"tag\">netsh<\/a> <a href=\"http:\/\/www.technoratic.com\/tags\/gpotool\" rel=\"tage\">gpotool<\/a> <a href=\"http:\/\/www.technoratic.com\/tags\/ntdsutil\" rel=\"tag\">ntdsutil<\/a> <a href=\"http:\/\/www.technoratic.com\/tags\/dnscmd\" rel=\"tag\">dnscmd  <\/a><a href=\"http:\/\/www.technoratic.com\/tags\/repadmin\" rel=\"tag\">repadmin<\/a><br \/><a href=\"http:\/\/www.technoratic.com\/tags\/wmic\" rel=\"tag\">wmic<\/a><br \/><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently did a TipSheet column listing some of my favorite quick, one line commands. Reader Wayne was kind enough to share with me his list of oft-used one-liners which he graciously offered to share. I have not tested many of these personally, but you always test things in a non-production environment anyway, right? The&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[539,20,25],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-active-directory","tag-cli","tag-tipsheet"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>More One Liners &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/64\/more-one-liners\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"More One Liners &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I recently did a TipSheet column listing some of my favorite quick, one line commands. Reader Wayne was kind enough to share with me his list of oft-used one-liners which he graciously offered to share. I have not tested many of these personally, but you always test things in a non-production environment anyway, right? The...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/64\/more-one-liners\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2006-11-13T17:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-07-02T12:11:36+00:00\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/64\\\/more-one-liners\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/64\\\/more-one-liners\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"More One Liners\",\"datePublished\":\"2006-11-13T17:30:00+00:00\",\"dateModified\":\"2013-07-02T12:11:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/64\\\/more-one-liners\\\/\"},\"wordCount\":1616,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"Active Directory\",\"CLI\",\"TipSheet\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/64\\\/more-one-liners\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/64\\\/more-one-liners\\\/\",\"name\":\"More One Liners &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2006-11-13T17:30:00+00:00\",\"dateModified\":\"2013-07-02T12:11:36+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/64\\\/more-one-liners\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/64\\\/more-one-liners\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/64\\\/more-one-liners\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"More One Liners\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"More One Liners &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/64\/more-one-liners\/","og_locale":"en_US","og_type":"article","og_title":"More One Liners &#8226; The Lonely Administrator","og_description":"I recently did a TipSheet column listing some of my favorite quick, one line commands. Reader Wayne was kind enough to share with me his list of oft-used one-liners which he graciously offered to share. I have not tested many of these personally, but you always test things in a non-production environment anyway, right? The...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/64\/more-one-liners\/","og_site_name":"The Lonely Administrator","article_published_time":"2006-11-13T17:30:00+00:00","article_modified_time":"2013-07-02T12:11:36+00:00","author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/64\/more-one-liners\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/64\/more-one-liners\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"More One Liners","datePublished":"2006-11-13T17:30:00+00:00","dateModified":"2013-07-02T12:11:36+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/64\/more-one-liners\/"},"wordCount":1616,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["Active Directory","CLI","TipSheet"],"articleSection":["PowerShell"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/64\/more-one-liners\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/64\/more-one-liners\/","name":"More One Liners &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2006-11-13T17:30:00+00:00","dateModified":"2013-07-02T12:11:36+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/64\/more-one-liners\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/64\/more-one-liners\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/64\/more-one-liners\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"More One Liners"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1366,"url":"https:\/\/jdhitsolutions.com\/blog\/windows-7\/1366\/managing-wsus-from-a-non-domain-member\/","url_meta":{"origin":64,"position":0},"title":"Managing WSUS from a Non-Domain Member","author":"Jeffery Hicks","date":"April 25, 2011","format":false,"excerpt":"I run a lot of test machines in my home office network and rely on WSUS. However, my primary desktop is a stand alone system, that is not a domain member. This has always meant that I needed a remote desktop connection to the WSUS server to approve updates. The\u2026","rel":"","context":"In &quot;Windows 7&quot;","block_context":{"text":"Windows 7","link":"https:\/\/jdhitsolutions.com\/blog\/category\/windows-7\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3418,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3418\/mini-hyper-v-operating-system\/","url_meta":{"origin":64,"position":1},"title":"Mini Hyper-V: Operating System","author":"Jeffery Hicks","date":"September 9, 2013","format":false,"excerpt":"When we left my project, the new mini server had booted up using Windows Hyper-V Server 2012 R2. This is a server core installation intended to only run Hyper-V, which is perfect for my needs. The server booted up with a temporary name and a DHCP assigned IP address. The\u2026","rel":"","context":"In &quot;Hyper-V&quot;","block_context":{"text":"Hyper-V","link":"https:\/\/jdhitsolutions.com\/blog\/category\/hyper-v\/"},"img":{"alt_text":"Set-CompConfigWorkflow","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/09\/Set-CompConfigWorkflow-300x225.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":37,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/37\/get-active-directory-user-information-in-powershell\/","url_meta":{"origin":64,"position":2},"title":"Get Active Directory User Information in PowerShell","author":"Jeffery Hicks","date":"July 5, 2006","format":false,"excerpt":"One feature that PowerShell will likely be missing when it first ships is solid support for ADSI and working with Active Directory. You can use .NET DirectoryEntry objects but it feels more like programming and less like scripting. Another option for working with Active Directory in PowerShell is to use\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":519,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/","url_meta":{"origin":64,"position":3},"title":"Get Disk Quota","author":"Jeffery Hicks","date":"November 23, 2009","format":false,"excerpt":"During a recent class I was teaching, a student asked about a way to get disk quota reports from Windows file servers.\u00a0 I knew there was a WMI class, Win32_DiskQuota, and had some old VBScript files. However, they were pretty basic and not as robust as I would have liked.\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"captured_Image.png","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/11\/captured_Image1.png_thumb1.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":8041,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/","url_meta":{"origin":64,"position":4},"title":"Get Group Policy Links with PowerShell","author":"Jeffery Hicks","date":"January 18, 2021","format":false,"excerpt":"I was chatting with my friend Gladys Kravitz about Group Policy reporting stuff recently,. and the discussion led me to dust off some old code I had for getting Group Policy links using PowerShell. The GroupPolicy module has a Set-GPLink command, but nothing that easily shows you what GPOs are\u2026","rel":"","context":"In &quot;Active Directory&quot;","block_context":{"text":"Active Directory","link":"https:\/\/jdhitsolutions.com\/blog\/category\/active-directory\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":77,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/77\/files-on-a-diet\/","url_meta":{"origin":64,"position":5},"title":"Files on a diet","author":"Jeffery Hicks","date":"December 20, 2006","format":false,"excerpt":"I did a MCPMag.com TipSheet column recently on compacting files to save space. I thought I'd take a moment to respond to some of the comments. First, today's hard drives are enormous and drives are cheap. However, there are still plenty of 3 and 5 year old servers that need\u2026","rel":"","context":"In &quot;Scripting&quot;","block_context":{"text":"Scripting","link":"https:\/\/jdhitsolutions.com\/blog\/category\/scripting\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}