Jump to content

Yoda

Members
  • Gesamte Inhalte

    269
  • Registriert seit

  • Letzter Besuch

Beste Lösungen

  1. Yoda's post in Variablen werden nicht angezeigt wurde als beste Lösung markiert.   
    Guten Morgen,
     
    hab mich jetzt doch dazu entschieden die einzelnen Sprachen mit in das Script zu nehmen.
    War die einfachste Methoden.
     
    Anbei das fertige Script, falls es jemand mal benötigt.
    ################################################################################################################# # # Version 1.1 May 2014 # Robert Pearman (WSSMB MVP) # TitleRequired.com # Script to Automated Email Reminders when Users Passwords due to Expire. # # Requires: Windows PowerShell Module for Active Directory # # For assistance and ideas, visit the TechNet Gallery Q&A Page. http://gallery.technet.microsoft.com/Password-Expiry-Email-177c3e27/view/Discussions#content # ################################################################################################################## # Please Configure the following variables.... $smtpServer="127.0.0.1" $expireindays = 8 $from = "Password Reminder <password@xyz.de>" $logging = "Enabled" # Set to Disabled to Disable Logging $logFile = "C:\PasswordReminder\pwd.csv" # ie. c:\mylog.csv $testing = "Disabled" # Set to Disabled to Email Users $bccRecipient = "abc@yxz.de" $testRecipient = "abc@yxz.de" $date = Get-Date -format ddMMyyyy # ################################################################################################################### # Check Logging Settings if (($logging) -eq "Enabled") {     # Test Log File Path     $logfilePath = (Test-Path $logFile)     if (($logFilePath) -ne "True")     {         # Create CSV File and Headers         New-Item $logfile -ItemType File         Add-Content $logfile "Date,Surname,GivenName,EmailAddress,DaystoExpire,ExpiresOn"     } } # End Logging Check # Get Users From AD who are Enabled, Passwords Expire and are Not Currently Expired Import-Module ActiveDirectory $users = get-aduser -filter * -properties GivenName, Surname, PasswordNeverExpires, PasswordExpired, PasswordLastSet, EmailAddress, co |where {$_.Enabled -eq "True"} | where { $_.PasswordNeverExpires -eq $false } | where { $_.passwordexpired -eq $false } $DefaultmaxPasswordAge = (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge # Process Each User for Password Expiry foreach ($user in $users) {     $Name = $user.Name     $Surname= $user.Surname     $GivenName= $user.GivenName     $emailaddress = $user.emailaddress     $passwordSetDate = $user.PasswordLastSet     $country = $user.co     $PasswordPol = (Get-AduserResultantPasswordPolicy $user)     # Check for Fine Grained Password     if (($PasswordPol) -ne $null)     {         $maxPasswordAge = ($PasswordPol).MaxPasswordAge     }     else     {         # No FGP set to Domain Default         $maxPasswordAge = $DefaultmaxPasswordAge     }       $expireson = $passwordsetdate + $maxPasswordAge     $today = (get-date)     $daystoexpire = (New-TimeSpan -Start $today -End $Expireson).Days              # Set Greeting based on Number of Days to Expiry.     # Check Number of Days to Expiry     $messageDays = $daystoexpire     if (($messageDays) -ge "1")     {         switch ($country) {             "Vereinigtes Königreich" {                 $messageDays = "in " + "$daystoexpire" + " days"                 }             "Polen" {                 $messageDays = "za " + "$daystoexpire" + " dni"                 }             "Frankreich" {                 $messageDays = "dans " + "$daystoexpire" + " jours"                 }             default {                 $messageDays = "in " + "$daystoexpire" + " Tagen"                 }         }         }     else     {         switch ($country) {             "Vereinigtes Königreich" {                 $messageDays = "today"                 }             "Polen" {                 $messageDays = "dzisiaj"                 }             "Frankreich" {                 $messageDays = "aujourd'hui"                 }             default {                 $messageDays = "heute"                 }         }     }     switch ($country) {         "Vereinigtes Königreich" {             $subject = "Your Windows password expires $messageDays!"             $body = "Hello $GivenName $Surname,                         <p>Your Windows password expires $messageDays.<br>                         <p><b>You can change this as follow:</b><br>                         <ul>                             <li>Press STRG+ALT+DEL</li>                             <li>Select 'Change password...'</li>                             <li>Fill and confirm the appropriate fields</li>                         </ul>                         <p><b>Password requirements</b><br>                         <ul>                             <li>You must not use essential parts of the user name nor the full user name</li>                             <li>Mind. 9 characters</li>                             <li>Characters from three of the following four categories must be included:<ul>                             <li>Uppercase</li>                             <li>Lowercase</li>                             <li>Numbers (0 bis 9)</li>                             <li>One of the following special characters: !, $, #, %, &, (, ), *, +, -, .</li></ul>                         </ul>                         <p>many thanks<br>                         - EDV -                         </P>"                 }             "Polen" {             $subject = "Twoje hasło do systemu MS Windows wygaśnie $messageDays!"             $body = "Witaj $GivenName $Surname,                         <p>Twoje hasło do systemu MS Windows wygaśnie $messageDays.<br>                         <p><b>Możesz je zmienić tak jak napisano poniżej (pracownicy biurowi pomijają punkt pierwszy):</b><br>                         <ul>                             <li>Włączyć VPN </li>                             <li>nacisnąć razem przyciski Ctrl+ALT+DEL</li>                             <li>wybrać opcje 'zmiana hasła…'</li>                             <li>uzupełnić odpowiednie pola i nacisnąć 'Enter'</li>                         </ul>                         <p><b>Zasady polityki długości i złożoności hasła:</b><br>                         <ul>                             <li>nie można w haśle wykorzystywać ciągów znaków z loginu użytkownika oraz z imienia i nazwiska użytkownika.</li>                             <li>Minimum 9 znaków</li>                             <li>Znaki z minimum trzech z czterech kategorii musza być wykorzystywane:<ul>                             <li>Wielkie litery</li>                             <li>Małe litery</li>                             <li>Cyrfy (od 0 do 9)</li>                             <li>Jeden z następujących znaków specjalnych: !, $, #, %, &, (, ), *, +, -, .</li></ul>                         </ul>                         <p>Dziękujemy za współpracę<br>                         - IT -                         </P>"                 }         "Frankreich"{             $subject = "Votre mot de passe Windows expire $messageDays!"             $body = "Bonjour $GivenName $Surname,                         <p> Votre mot de passe Windows expire $messageDays.<br>                         <p><b>Vous pouvez modifier cette comme suit:</b><br>                         <ul>                             <li>appuyez sur CTRL + ALT + SUPPR</li>                             <li>option 'Change Password ...' Sélectionnez</li>                             <li>Remplir et confirmer champs appropriés </li>                         </ul>                         <p><b> Mot de passe requis</b><br>                         <ul>                             <li>Vous ne devez pas utiliser des pièces essentielles du nom d'utilisateur ni le nom d'utilisateur complet. </li>                             <li>esprit. 9 caractères </li>                             <li>Les caractères de trois des quatre catégories suivantes doivent être incluses:<ul>                             <li>majuscules</li>                             <li>minuscules</li>                             <li>numéros (0 à 9)</li>                             <li>L'un des caractères spéciaux suivants: !, $, #, %, &, (, ), *, +, -, .</li></ul>                         </ul>                         <p>Merci Beaucoup<br>                         - Informatique -                         </P>"             }         default {             $subject = "Ihr Windows Passwort läuft $messageDays ab!"             $body = "Hallo $GivenName $Surname,                         <p> Ihr Windows Passwort läuft $messageDays ab.<br>                         <p><b>Sie können dies wie folgt ändern:</b><br>                         <ul>                             <li>STRG+ALT+ENTF drücken </li>                             <li>Option 'Kennwort ändern...' auswählen </li>                             <li>Entsprechenden Felder ausfüllen und bestätigen </li>                         </ul>                         <p><b> Kennwortvoraussetzungen</b><br>                         <ul>                             <li>Sie dürfen weder wesentliche Teile des Benutzernamens noch den vollständigen Benutzernamen verwenden. </li>                             <li>Mind. 9 Zeichen </li>                             <li>Zeichen aus drei der vier folgenden Kategorien müssen enthalten sein:<ul>                             <li>Großbuchstaben</li>                             <li>Kleinbuchstaben</li>                             <li>Ziffern (0 bis 9)</li>                             <li>Eines der folgenden Sonderzeichen: !, $, #, %, &, (, ), *, +, -, .</li></ul>                         </ul>                         <p>Vielen Dank <br>                         - EDV -                         </P>"                 }     }          # If Testing Is Enabled - Email Administrator     if (($testing) -eq "Enabled")     {         $emailaddress = $testRecipient     } # End Testing     # If a user has no email address listed     if (($emailaddress) -eq $null)     {         $emailaddress = $testRecipient         }# End No Valid Email     # Send Email Message     if (($daystoexpire -ge "0") -and ($daystoexpire -lt $expireindays))     {          # If Logging is Enabled Log Details         if (($logging) -eq "Enabled")         {             Add-Content $logfile "$date,$Surname,$GivenName,$emailaddress,$daystoExpire,$expireson"         }                  # Send Email Message         Send-Mailmessage -smtpServer $smtpServer -encoding ([System.Text.Encoding]::UTF8)  -from $from -to $emailaddress -subject $subject -body $body -bcc $bccRecipient -bodyasHTML -priority High           } # End Send Message   } # End User Processing End Im AD-Benutzerobjekt wird unter Adresse - Land/Region das Land eingestellt. Entsprechend wird die Password Erinnerung in der jeweiligen Sprache versendet.
    Läuft bei uns 1x in der Nacht als geplanter Task.
     
    Gruß
    Yoda
     
×
×
  • Neu erstellen...