PoshCode Archive  Artifact [5742e2c5aa]

Artifact 5742e2c5aad3f62161d849d3a610ed9ea400c71224659bdcf7a54ed13fded3de:

  • File PasswordNeverExpires.ps1 — part of check-in [fa9b707856] at 2018-06-10 13:18:30 on branch trunk — Email list of AD Accounts with PasswordNeverExpires Set (user: VulcanX size: 1443)

# encoding: ascii
# api: powershell
# title: PasswordNeverExpires
# description: Email list of AD Accounts with PasswordNeverExpires Set
# version: 1.0
# type: script
# author: VulcanX
# license: CC0
# x-poshcode-id: 2998
# x-archived: 2012-01-14T07:03:45
# x-published: 2012-10-12T02:50:00
#
#
# Synopsis:
# Windows Script to collect usernames and OU locations
# for User Account with Password Set to Never Expire
# and email .txt list to email address

# Author: VulcanX
# Date: 2011/10/11
# Version: 1.0

# Requirements:
# -Quest PSSnapin Installed Locally
# -SMTP Access to Relay/Exchange

# Import AD module for additionals cmdlets
Import-Module ActiveDirectory

# Add Quest Snapin for Get-Q* cmdlets
Add-PSSnapin Quest.ActiveRoles.ADManagement

# Create variable for use later in script
$currentDate = get-date -format "yyyy-MM-dd"

# Find all users with Password Set to Never Expire and Export to a txt
Get-Qaduser -PasswordNeverExpires | Out-File "C:\Password_Exp\Exp_$currentdate.txt"

# Create variable for logfile location + name
$attach = "C:\Password_Exp\Exp_$currentdate.txt"

# Send Email with .txt attachment to infosec
Send-MailMessage -From 'email1@domain.com' -to 'email2@domain.com' -Subject `
"Password Expiration - $currentDate" -Body "User Accounts whose Passwords Never Expire `n `r Please refer to the txt attachment" `
-Attachments $attach -SmtpServer 'smtp01.domain.com'