Vaša lozinka istječe $ExpireDate_User za Vaše korisničko ime (username): <font color=blue><b> $userlogin </b></font> pa bi vas ovim putem podsjetili da ju trebate promijeniti.<br><br>Lozinku možete promjeniti koristeći jedan od sljedećih načina:
Can someone help me how to make my script understand that $userlogin is not a string but some variable that has to be filled with information. Thank you very much for help!
Here is a full code:
`#–This section determines which users to notify and to which email adress
foreach( $User in $ADUsers ){
# Get the expiry date and convert to date time
$ExpireDate = [datetime]::FromFileTime( $User.‘msDS-UserPasswordExpiryTimeComputed’ )
$ExpireDate_String = $ExpireDate.ToString(“dd/MM/yyyy h:mm tt”) # Format as UK
$ExpireDate_User = $ExpireDate.ToString(“dd/MM/yyyy”) # Format time for user notification
# Calculate the days remaining
$daysRmmaining = New-TimeSpan -Start $Today -End $ExpireDate
$daysRmmaining = $daysRmmaining.Days
$usersName = $User.Name
$manager = $user.ManagerMail
$userMail = $user.mail
$userlogin = $user.SamAccountName
# Email users with a remaining count less than or equal to $warnDays but also 0 or greater (no expired yet)
if ($daysRmmaining -le $warnDays -And $daysRmmaining -ge 0)
{
# Generate email subject from days remaining
if ($daysRmmaining -eq 0)
{
$emailSubject = "Vaša Lozinka istječe danas!!"
$emailrec = "Lozinka za $usersName istječe danas!!"
} else {
$emailSubject = "Vaša lozinka istječe za $daysRmmaining dana"
$emailrec = "Lozinka za $usersName istječe za $daysRmmaining dana"
}
# Get users email or if no mailbox for the account send email to the manager
if([string]::IsNullOrEmpty($userMail))
{
# The user does not have an email address in AD,send the notification to their manager
$sendTo = $manager
$attachment = 'C:\pwm\UputeValamarPasswordManager.docx','C:\pwm\Promjena lozinke unutar sustava Windows.docx', 'C:\pwm\Promjena lozinke prilikom prijave na računalo.docx' # enter location of guide documentation for password change
#create Email body with embeded images encoded to base64 to bypass outlook "block auto download" policy
$emailBody = Get-Content "C:\pwm\HTML_NoMail.html" -Encoding UTF8
} else {
# The user has an email address,send to user
$sendTo = $userMail
$attachment = 'C:\pwm\UputeValamarPasswordManager.docx','C:\pwm\Outlook upute.docx','C:\pwm\Promjena lozinke unutar sustava Windows.docx', 'C:\pwm\Promjena lozinke prilikom prijave na računalo.docx' # enter location of guide documentation for password change
$emailBody = Get-Content "C:\pwm\HTML_Mail.html" -Encoding UTF8