{"id":377485,"date":"2024-10-30T11:18:21","date_gmt":"2024-10-30T11:18:21","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=377485"},"modified":"2024-10-30T11:18:21","modified_gmt":"2024-10-30T11:18:21","slug":"benachrichtigungen-ueber-inaktive-benutzerkonten-unter-linux","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/de\/script-hub\/benachrichtigungen-ueber-inaktive-benutzerkonten-unter-linux\/","title":{"rendered":"Wie man Benachrichtigungen \u00fcber inaktive Benutzerkonten unter Linux erhalten kann: Ein umfassender Skript-Guide"},"content":{"rendered":"<p>Die effektive Verwaltung von Benutzerkonten ist ein Eckpfeiler der IT-Sicherheit. Unter den verschiedenen Ma\u00dfnahmen zur Aufrechterhaltung einer sicheren Umgebung ist die \u00dcberwachung inaktiver oder ungenutzter Konten entscheidend. Inaktive Konten k\u00f6nnen potenzielle Einstiegspunkte f\u00fcr b\u00f6sartige Aktivit\u00e4ten sein, wenn sie nicht kontrolliert werden. Um dieses Problem zu l\u00f6sen, sprechen wir in diesem Blogbeitrag dar\u00fcber, wie man automatisierte Benachrichtigungen \u00fcber inaktive Benutzerkonten unter Linux erhalten kann. Wir werden uns mit einem robusten Bash-Skript befassen, das Administratoren benachrichtigt, wenn Benutzerkonten f\u00fcr eine bestimmte Anzahl von Tagen inaktiv bleiben.<\/p>\n<h2>Kontext<\/h2>\n<p>Inaktive Benutzerkonten stellen in jeder IT-Infrastruktur ein erhebliches Risiko dar. Sie k\u00f6nnen f\u00fcr unbefugten Zugriff ausgenutzt werden, was zu potenziellen Datenschutzverletzungen f\u00fchrt. <a href=\"https:\/\/www.ninjaone.com\/de\/was-ist-ein-msp\" target=\"_blank\" rel=\"noopener\">Managed Service Provider (MSPs)<\/a> und IT-Experten ben\u00f6tigen effiziente Tools, um solche Konten zu verfolgen und zu verwalten. Dieses Skript ist eine leistungsstarke L\u00f6sung, die automatische Warnmeldungen f\u00fcr inaktive Konten auf <a href=\"https:\/\/www.ninjaone.com\/blog\/linux-filesystems\/\" target=\"_blank\" rel=\"noopener\">Linux-Systemen<\/a> bietet und so die allgemeine Sicherheitslage verbessert.<\/p>\n<h2>Das Skript:<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">#!\/usr\/bin\/env bash\r\n#\r\n# Description: Alerts when there is an inactive\/unused account that has not logged in for the specified number of days.\r\n#\r\n# Preset Parameter: --daysInactive \"90\"\r\n#   Alert if account has been inactive for x days.\r\n#\r\n# Preset Parameter: --showDisabled\r\n#   Includes disabled accounts in alert and report.\r\n#\r\n# Preset Parameter: --multilineField \"ReplaceMeWithNameOfYourMultilineField\"\r\n#   Name of an optional multiline custom field to save the results to.\r\n#\r\n# Preset Parameter: --wysiwygField \"ReplaceMeWithNameOfYourWYSIWYGField\"\r\n#   Name of an optional WYSIWYG custom field to save the results to.\r\n#\r\n# Preset Parameter: --help\r\n#   Displays some help text.\r\n#\r\n# Release Notes: Initial Release\r\n# By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n# Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n# Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n# Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n# Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n# Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n# Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n# EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n#\r\n\r\n# These are all our preset parameter defaults. You can set these = to something if you would prefer the script defaults to a certain parameter value.\r\n_arg_daysInactive=\r\n_arg_showDisabled=\"off\"\r\n_arg_multilineField=\r\n_arg_wysiwygField=\r\n\r\n# Help text function for when invalid input is encountered\r\nprint_help() {\r\n  printf '\\n\\n%s\\n\\n' 'Usage: --daysInactive|-d &lt;arg&gt; [--multilineField|-m &lt;arg&gt;] [--wysiwygField|-w &lt;arg&gt;] [--showDisabled] [--help|-h]'\r\n  printf '%s\\n' 'Preset Parameter: --daysInactive \"90\"'\r\n  printf '\\t%s\\n' \"Alert if account has been inactive for x days.\"\r\n  printf '%s\\n' 'Preset Parameter: --showDisabled'\r\n  printf '\\t%s\\n' \"Includes disabled accounts in alert and report.\"\r\n  printf '%s\\n' 'Preset Parameter: --multilineField \"ReplaceMeWithNameOfYourMultilineField\"'\r\n  printf '\\t%s\\n' \"Name of an optional multiline custom field to save the results to.\"\r\n  printf '%s\\n' 'Preset Parameter: --wysiwygField \"ReplaceMeWithNameOfYourWYSIWYGField\"'\r\n  printf '\\t%s\\n' \"Name of an optional WYSIWYG custom field to save the results to.\"\r\n  printf '\\n%s\\n' 'Preset Parameter: --help'\r\n  printf '\\t%s\\n' \"Displays this help menu.\"\r\n}\r\n\r\n# Determines whether or not help text is necessary and routes the output to stderr\r\ndie() {\r\n  local _ret=\"${2:-1}\"\r\n  echo \"$1\" &gt;&amp;2\r\n  test \"${_PRINT_HELP:-no}\" = yes &amp;&amp; print_help &gt;&amp;2\r\n  exit \"${_ret}\"\r\n}\r\n\r\n# Converts a string input into an HTML table format.\r\nconvertToHTMLTable() {\r\n  local _arg_delimiter=\" \"\r\n  local _arg_inputObject\r\n\r\n  # Process command-line arguments for the function.\r\n  while test $# -gt 0; do\r\n    _key=\"$1\"\r\n    case \"$_key\" in\r\n    --delimiter | -d)\r\n      test $# -lt 2 &amp;&amp; echo \"[Error] Missing value for the required argument\" &gt;&amp;2 &amp;&amp; return 1\r\n      _arg_delimiter=$2\r\n      shift\r\n      ;;\r\n    --*)\r\n      echo \"[Error] Got an unexpected argument\" &gt;&amp;2\r\n      return 1\r\n      ;;\r\n    *)\r\n      _arg_inputObject=$1\r\n      ;;\r\n    esac\r\n    shift\r\n  done\r\n\r\n  # Handles missing input by checking stdin or returning an error.\r\n  if [[ -z $_arg_inputObject ]]; then\r\n    if [ -p \/dev\/stdin ]; then\r\n      _arg_inputObject=$(cat)\r\n    else\r\n      echo \"[Error] Missing input object to convert to table\" &gt;&amp;2\r\n      return 1\r\n    fi\r\n  fi\r\n\r\n  local htmlTable=\"&lt;table&gt;\\n\"\r\n  htmlTable+=$(printf '%b' \"$_arg_inputObject\" | head -n1 | awk -F \"$_arg_delimiter\" '{\r\n    printf \"&lt;tr&gt;\"\r\n    for (i=1; i&lt;=NF; i+=1)\r\n      { printf \"&lt;th&gt;\"$i\"&lt;\/th&gt;\" }\r\n    printf \"&lt;\/tr&gt;\"\r\n    }')\r\n  htmlTable+=\"\\n\"\r\n  htmlTable+=$(printf '%b' \"$_arg_inputObject\" | tail -n +2 | awk -F \"$_arg_delimiter\" '{\r\n    printf \"&lt;tr&gt;\"\r\n    for (i=1; i&lt;=NF; i+=1)\r\n      { printf \"&lt;td&gt;\"$i\"&lt;\/td&gt;\" }\r\n    print \"&lt;\/tr&gt;\"\r\n    }')\r\n  htmlTable+=\"\\n&lt;\/table&gt;\"\r\n\r\n  printf '%b' \"$htmlTable\" '\\n'\r\n}\r\n\r\n# Parses command-line arguments and sets script variables accordingly.\r\nparse_commandline() {\r\n  while test $# -gt 0; do\r\n    _key=\"$1\"\r\n    case \"$_key\" in\r\n    --daysInactive | --daysinactive | --days | -d)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n      _arg_daysInactive=$2\r\n      shift\r\n      ;;\r\n    --daysInactive=*)\r\n      _arg_daysInactive=\"${_key##--daysInactive=}\"\r\n      ;;\r\n    --multilineField | --multilinefield | --multiline | -m)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n      _arg_multilineField=$2\r\n      shift\r\n      ;;\r\n    --multilineField=*)\r\n      _arg_multilineField=\"${_key##--multilineField=}\"\r\n      ;;\r\n    --wysiwygField | --wysiwygfield | --wysiwyg | -w)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n      _arg_wysiwygField=$2\r\n      shift\r\n      ;;\r\n    --wysiwygField=*)\r\n      _arg_wysiwygField=\"${_key##--wysiwygField=}\"\r\n      ;;\r\n    --showDisabled | --showdisabled)\r\n      _arg_showDisabled=\"on\"\r\n      ;;\r\n    --help | -h)\r\n      _PRINT_HELP=yes die 0\r\n      ;;\r\n    *)\r\n      _PRINT_HELP=yes die \"FATAL ERROR: Got an unexpected argument '$1'\" 1\r\n      ;;\r\n    esac\r\n    shift\r\n  done\r\n}\r\n\r\n# Parses the command-line arguments passed to the script.\r\nparse_commandline \"$@\"\r\n\r\n# If dynamic script variables are used replace the commandline arguments with them.\r\nif [[ -n $daysInactive ]]; then\r\n  _arg_daysInactive=\"$daysInactive\"\r\nfi\r\n\r\nif [[ -n $includeDisabled &amp;&amp; $includeDisabled == \"true\" ]]; then\r\n  _arg_showDisabled=\"on\"\r\nfi\r\n\r\nif [[ -n $multilineCustomFieldName ]]; then\r\n  _arg_multilineField=\"$multilineCustomFieldName\"\r\nfi\r\n\r\nif [[ -n $wysiwygCustomFieldName ]]; then\r\n  _arg_wysiwygField=\"$wysiwygCustomFieldName\"\r\nfi\r\n\r\n# Check if _arg_daysInactive contains any non-digit characters or is less than zero.\r\n# If any of these conditions are true, display the help text and terminate with an error.\r\nif [[ -z $_arg_daysInactive || $_arg_daysInactive =~ [^0-9]+ || $_arg_daysInactive -lt 0 ]]; then\r\n  _PRINT_HELP=yes die \"FATAL ERROR: Days Inactive of '$_arg_daysInactive' is invalid! Days Inactive must be a positive number.\" 1\r\nfi\r\n\r\n# Check if both _arg_multilineField and _arg_wysiwygField are set and not empty.\r\nif [[ -n \"$_arg_multilineField\" &amp;&amp; -n \"$_arg_wysiwygField\" ]]; then\r\n  # Convert both field names to uppercase to check for equality.\r\n  multiline=$(echo \"$_arg_multilineField\" | tr '[:lower:]' '[:upper:]')\r\n  wysiwyg=$(echo \"$_arg_wysiwygField\" | tr '[:lower:]' '[:upper:]')\r\n\r\n  # If the converted names are the same, it means both fields cannot be identical.\r\n  # If they are, terminate the script with an error.\r\n  if [[ \"$multiline\" == \"$wysiwyg\" ]]; then\r\n    _PRINT_HELP=no die 'FATAL ERROR: Multline Field and WYSIWYG Field cannot be the same name. https:\/\/ninjarmm.zendesk.com\/hc\/en-us\/articles\/360060920631-Custom-Fields-Configuration-Device-Role-Fields'\r\n  fi\r\nfi\r\n\r\n# Retrieves the list of user accounts with UniqueIDs greater than 499 (typically these are all not service accounts) from the local user directory.\r\nuserAccounts=$(cut -d \":\" -f1,3 \/etc\/passwd | grep -v \"nobody\" | awk -F ':' '$2 &gt;= 1000 {print $1}')\r\n\r\n# Sets up a header string for the table that will display user account information.\r\nheader=$(printf '%s' \"Username\" ';' \"Password Last Set\" ';' \"Last Logon\" ';' \"Enabled\")\r\n\r\n# Initializes an empty string to store information about relevant user accounts.\r\nrelevantAccounts=\r\n\r\n# Iterates over each user account retrieved earlier.\r\nfor userAccount in $userAccounts; do\r\n  # Extracts the last login information for that user, filtering out unnecessary lines and formatting.\r\n  lastLogin=$(last -RF1 \"$userAccount\" | grep -v \"wtmp\" | grep \"\\S\" | tr -s \" \" | cut -f3-7 -d \" \")\r\n\r\n  # Converts the last login date to seconds since the epoch, for easier date comparison.\r\n  if [[ -n $lastLogin ]]; then\r\n    lastLogin=$(date -d \"$lastLogin\" +\"%s\")\r\n  fi\r\n\r\n  # Calculates the cutoff date in seconds since the epoch for inactivity comparison, based on the days inactive argument.\r\n  if [[ $_arg_daysInactive -gt 0 ]]; then\r\n    cutoffDate=$(date -d \"${_arg_daysInactive} days ago\" +\"%s\")\r\n  fi\r\n\r\n  # Retrieves the timestamp when the password was last set for the user account and converts it to a readable format.\r\n  passwordLastSet=$(passwd -S \"$userAccount\" | cut -f3 -d \" \")\r\n\r\n  # Checks if the user account is part of the group that defines disabled accounts, setting the 'enabled' variable accordingly.\r\n  unlockedaccount=$(passwd -S \"$userAccount\" | cut -f2 -d \" \" | grep -v \"L\")\r\n  nologin=$(grep \"$userAccount\" \/etc\/passwd | cut -d \":\" -f7 | grep \"nologin\")\r\n  if [[ -n $unlockedaccount &amp;&amp; -z $nologin ]]; then\r\n    enabled=\"true\"\r\n  else\r\n    enabled=\"false\"\r\n  fi\r\n\r\n  # Checks if the account is inactive based on the last login date and cutoff date or if the account should be included regardless of its active status.\r\n  if [[ $_arg_daysInactive == \"0\" || -z \"$lastLogin\" || $lastLogin -le $cutoffDate ]]; then\r\n    # Formats the last login date or sets it to \"Never\" if the user has never logged in.\r\n    if [[ -n $lastLogin ]]; then\r\n      lastLogin=$(date -d \"@$lastLogin\")\r\n    else\r\n      lastLogin=\"Never\"\r\n    fi\r\n\r\n    # Skips adding disabled accounts to the output if they should not be shown.\r\n    if [[ $_arg_showDisabled == \"off\" &amp;&amp; $enabled == \"false\" ]]; then\r\n      continue\r\n    fi\r\n\r\n    # Appends the account information to the 'relevantAccounts' string if it meets the criteria.\r\n    relevantAccounts+=$(printf '%s' '\\n' \"$userAccount\" ';' \"$passwordLastSet\" ';' \"$lastLogin\" ';' \"$enabled\")\r\n    foundInactiveAccounts=\"true\"\r\n  fi\r\ndone\r\n\r\n# Checks if there are any inactive accounts found.\r\nif [[ $foundInactiveAccounts == \"true\" ]]; then\r\n  # Formats a nice table for easier viewing\r\n  tableView=\"$header\"\r\n  tableView+=$(printf '%s' '\\n' \"--------\" ';' \"-----------------\" ';' \"----------\" ';' \"-------\")\r\n  tableView+=\"$relevantAccounts\"\r\n  tableView=$(printf '%b' \"$tableView\" | column -s ';' -t)\r\n\r\n  # Output to the activity log\r\n  echo \"\"\r\n  echo 'WARNING: Inactive accounts detected!'\r\n  echo \"\"\r\n  printf '%b' \"$tableView\"\r\n  echo \"\"\r\nelse\r\n  # If no inactive accounts were found, outputs a simple message.\r\n  echo \"No inactive accounts detected.\"\r\nfi\r\n\r\n# Checks if there is a multiline custom field set and if any inactive accounts have been found.\r\nif [[ -n $_arg_multilineField &amp;&amp; $foundInactiveAccounts == \"true\" ]]; then\r\n  echo \"\"\r\n  echo \"Attempting to set Custom Field '$_arg_multilineField'...\"\r\n\r\n  # Formats the relevantAccounts data for the multiline custom field.\r\n  multilineValue=$(printf '%b' \"$relevantAccounts\" | grep \"\\S\" | awk -F \";\" '{ \r\n      print \"Username: \"$1\r\n      print \"Password Last Set: \"$2\r\n      print \"Last Logon: \"$3\r\n      print \"Enabled: \"$4 \r\n      print \"\"\r\n  }')\r\n\r\n  # Tries to set the multiline custom field using ninjarmm-cli and captures the output.\r\n  if ! output=$(printf '%b' \"$multilineValue\" | \/opt\/NinjaRMMAgent\/programdata\/ninjarmm-cli set --stdin \"$_arg_multilineField\" 2&gt;&amp;1); then\r\n    echo \"[Error] $output\" &gt;&amp;2\r\n    EXITCODE=1\r\n  else\r\n    echo \"Successfully set Custom Field '$_arg_multilineField'!\"\r\n  fi\r\nfi\r\n\r\n# Checks if there is a WYSIWYG custom field set and if any inactive accounts have been found.\r\nif [[ -n $_arg_wysiwygField &amp;&amp; $foundInactiveAccounts == \"true\" ]]; then\r\n  echo \"\"\r\n  echo \"Attempting to set Custom Field '$_arg_wysiwygField'...\"\r\n\r\n  # Initializes an HTML formatted string with headers and account details.\r\n  htmlObject=\"$header\"\r\n  htmlObject+=\"$relevantAccounts\"\r\n\r\n  # Converts the text data to an HTML table format.\r\n  htmlObject=$(convertToHTMLTable --delimiter ';' \"$htmlObject\")\r\n\r\n  # Tries to set the WYSIWYG custom field using ninjarmm-cli and captures the output.\r\n  if ! output=$(echo \"$htmlObject\" | \/opt\/NinjaRMMAgent\/programdata\/ninjarmm-cli set --stdin \"$_arg_wysiwygField\" 2&gt;&amp;1); then\r\n    echo \"[Error] $output\" &gt;&amp;2\r\n    EXITCODE=1\r\n  else\r\n    echo \"Successfully set Custom Field '$_arg_wysiwygField'!\"\r\n  fi\r\nfi\r\n\r\n# Checks if an error code is set and exits the script with that code.\r\nif [[ -n $EXITCODE ]]; then\r\n  exit \"$EXITCODE\"\r\nfi<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Greifen Sie auf \u00fcber 300 Skripte im NinjaOne Dojo zu.<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/de\/kostenlosetestversionformular\/\">Zugang erhalten<\/a><\/p>\n<\/div>\n<h2>Detailansicht<\/h2>\n<p>Schauen wir uns an, wie dieses Skript funktioniert, um die Benutzerkontenordnung auf Ihren Linux-Systemen aufrechtzuerhalten.<\/p>\n<h3>Voreingestellte Parameter<\/h3>\n<p>Das Skript beginnt mit der Definition voreingestellter Parameter:<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\">&#8211;daysInactive: Die Anzahl der Tage, die ein Konto inaktiv sein muss, um eine Warnmeldung auszul\u00f6sen.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\">&#8211;showDisabled: Ob deaktivierte Konten in den Bericht aufgenommen werden sollen.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">&#8211;multilineField: Der Name eines mehrzeiligen benutzerdefinierten Feldes zum Speichern der Ergebnisse.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\">&#8211;wysiwygFeld: Der Name eines benutzerdefinierten WYSIWYG-Feldes zum Speichern der Ergebnisse.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\">&#8211;help: Zeigt den Hilfetext an.<\/li>\n<\/ul>\n<h3>Parsen von Befehlszeilenargumenten<\/h3>\n<p>Das Skript verwendet eine Funktion zum Parsen von Befehlszeilenargumenten und setzt Skriptvariablen dementsprechend. Wenn falsche Argumente angegeben werden, zeigt das Skript eine Hilfemeldung an und beendet sich.<\/p>\n<h3>Erkennung inaktiver Konten<\/h3>\n<p>Die Kernfunktionalit\u00e4t besteht in der Erkennung inaktiver Benutzerkonten. Es ruft eine Liste von Benutzerkonten mit UniqueIDs gr\u00f6\u00dfer als 499 (in der Regel Non-Service-Konten) aus dem lokalen Benutzerverzeichnis ab. Dann wird das Datum der letzten Anmeldung jedes Kontos gepr\u00fcft und mit dem aktuellen Datum abz\u00fcglich des Parameters &#8211;daysInactive verglichen. Konten, die die Inaktivit\u00e4tskriterien erf\u00fcllen, werden gekennzeichnet.<\/p>\n<h3>Berichterstellung<\/h3>\n<p>Wenn inaktive Konten erkannt werden, erzeugt das Skript eine formatierte Tabelle, die Folgendes anzeigt:<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"6\" data-aria-level=\"1\">Benutzername<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\">Passwort zuletzt gesetzt<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"8\" data-aria-level=\"1\">Letzte Anmeldung<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"9\" data-aria-level=\"1\">Aktiviert-Status<\/li>\n<\/ul>\n<h3>Integration benutzerdefinierter Felder<\/h3>\n<p>Das Script kann die Ergebnisse in den angegebenen benutzerdefinierten Feldern speichern. Es formatiert die Daten entweder in Plain-Text oder in HTML, je nachdem, ob sie in einem mehrzeiligen oder einem WYSIWYG-Feld gespeichert werden.<\/p>\n<h2>Potenzielle Anwendungsf\u00e4lle<\/h2>\n<p>Nehmen wir an, ein IT-Administrator verwaltet die Linux-Server eines Unternehmens. Regelm\u00e4\u00dfige \u00dcberpr\u00fcfungen der Benutzerkonten sind Teil des Sicherheitsprotokolls. Der Administrator plant dieses Skript f\u00fcr eine w\u00f6chentliche Ausf\u00fchrung ein. In einer Woche entdeckt das Skript mehrere inaktive Konten, die sich seit \u00fcber 90 Tagen nicht mehr angemeldet haben. Nach Pr\u00fcfung des Berichts beschlie\u00dft der Administrator, diese Konten bis zu einer weiteren \u00dcberpr\u00fcfung zu deaktivieren, um potenzielle Sicherheitsrisiken zu minimieren.<\/p>\n<h2>Vergleiche<\/h2>\n<p>Andere Methoden zur Erzielung \u00e4hnlicher Ergebnisse sind z. B. die manuelle Pr\u00fcfung oder die Verwendung komplexerer Tools zur Benutzerverwaltung. Die manuelle Pr\u00fcfung ist zeitaufw\u00e4ndig und anf\u00e4llig f\u00fcr menschliches Versagen. Fortgeschrittene Tools k\u00f6nnen kostspielig sein und erfordern m\u00f6glicherweise eine umfangreiche Einrichtung und Konfiguration. Dieses Skript bietet eine unkomplizierte, kosteng\u00fcnstige L\u00f6sung und ist damit ein guter Mittelweg.<\/p>\n<h2>FAQs<\/h2>\n<ol>\n<li><strong> Wie kann ich die Inaktivit\u00e4t f\u00fcr eine andere Anzahl von Tagen pr\u00fcfen?<\/strong> Passen Sie den Parameter &#8211;daysInactive entsprechend an. Verwenden Sie z. B. &#8211;daysInactive 60, um zu pr\u00fcfen, ob 60 Tage Inaktivit\u00e4t vorliegen.<\/li>\n<li><strong> Kann ich deaktivierte Konten aus dem Bericht ausschlie\u00dfen?<\/strong> Ja, das Skript enth\u00e4lt den Parameter &#8211;showDisabled, mit dem die Einbeziehung deaktivierter Konten umgeschaltet werden kann.<\/li>\n<li><strong>Wie kann ich die Ergebnisse in einem benutzerdefinierten Feld speichern?<\/strong> Geben Sie die Namen der benutzerdefinierten Felder mit den Parametern &#8211;multilineField oder &#8211;wysiwygField an.<\/li>\n<li><strong>Was passiert, wenn ich falsche Parameter eingebe?<\/strong> Das Skript zeigt eine Hilfemeldung an und beendet sich, um sicherzustellen, dass Sie die richtigen Eingaben machen.<\/li>\n<\/ol>\n<h2>Folgen<\/h2>\n<p>Die regelm\u00e4\u00dfige \u00dcberwachung inaktiver Konten hat tiefgreifende Auswirkungen auf die IT-Sicherheit. Es hilft, unbefugten Zugriff zu verhindern, die Angriffsfl\u00e4che zu verringern und die Compliance zu gew\u00e4hrleisten. Mit diesem Skript k\u00f6nnen Administratoren einen wichtigen Aspekt der Benutzerkontenverwaltung automatisieren und so die Sicherheit und Effizienz insgesamt erh\u00f6hen.<\/p>\n<h2>Empfehlungen<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"10\" data-aria-level=\"1\">Planen Sie die Ausf\u00fchrung des Skripts in regelm\u00e4\u00dfigen Abst\u00e4nden, z. B. w\u00f6chentlich oder monatlich.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"11\" data-aria-level=\"1\">\u00dcberpr\u00fcfen Sie den Bericht \u00fcber inaktive Konten umgehend und ergreifen Sie geeignete Ma\u00dfnahmen.<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"12\" data-aria-level=\"1\">Verwenden Sie die Funktion der benutzerdefinierten Felder, um die Ergebnisse in Ihre bestehenden IT-Management-Tools zu integrieren.<\/li>\n<\/ul>\n<h2>Abschlie\u00dfende \u00dcberlegungen<\/h2>\n<p>Eine <a href=\"https:\/\/www.ninjaone.com\/de\/effizienz\/\" target=\"_blank\" rel=\"noopener\">effiziente<\/a> Verwaltung inaktiver Benutzerkonten ist f\u00fcr die Aufrechterhaltung der IT-Sicherheit unerl\u00e4sslich. Dieses Skript bietet eine praktische und automatisierte L\u00f6sung, die es Administratoren erm\u00f6glicht, potenziellen Sicherheitsbedrohungen einen Schritt voraus zu sein. Wenn Sie dieses Tool in Ihre Sicherheitsprotokolle integrieren, k\u00f6nnen Sie eine sicherere und konforme IT-Umgebung gew\u00e4hrleisten.<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/de\/\" target=\"_blank\" rel=\"noopener\">NinjaOne<\/a> bietet umfassende IT-Management-L\u00f6sungen, die sich nahtlos in Skripte wie dieses integrieren lassen und so eine erweiterte Funktionalit\u00e4t und ein zentrales Management f\u00fcr Ihre IT-Infrastruktur bieten. Setzen Sie auf Automatisierung und robuste Sicherheitspraktiken mit NinjaOne, um Ihr Unternehmen effektiv zu sch\u00fctzen.<\/p>\n","protected":false},"author":35,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4211],"use_cases":[4309],"class_list":["post-377485","script_hub","type-script_hub","status-publish","hentry","script_hub_category-linux","use_cases-benutzerinnen-und-zugangsverwaltung"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub\/377485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/comments?post=377485"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/media?parent=377485"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/operating_system?post=377485"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/use_cases?post=377485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}