Buscar

ad-neverexpires

Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original

.\ad-neverexpires.ps1
.NOTES
 Name: Marcos Henrique
	E-mail: marcos@100security.com.br
.LINK
 WebSite: http://www.100security.com.br
	Facebook: https://www.facebook.com/seguranca.da.informacao
	Twitter: https://twitter.com/100Security
	GitHub: https://www.github.com/100security
	Youtube: https://www.youtube.com/user/videos100security
#>
$report = $null
$table = $null
$date = Get-Date -format "yyyy-MM-dd"
$mounth = Get-Date -format "MMM"
$directorypath = (Get-Item -Path ".\").FullName
$path = "ad-reports\ad-neverexpires"
#$html = "$path\ad-neverexpires-$date.html"
#$csv = "$path\ad-neverexpires-$date.csv"
$html = "$path\ad-neverexpires.html"
$csv = "$path\ad-neverexpires.csv"
#-- Password Never Expires
$t_pne = (Get-ADUser -filter * -properties PasswordNeverExpires | where { $_.PasswordNeverExpires -eq "true" } | where {$_.enabled -eq "true"} ).count
$domain = (Get-ADDomain).Forest
# Config
$config = Get-Content (JOIN-PATH $directorypath "config\config.txt")
$company = $config[7]
$owner = $config[9]
#-- Import Module
Import-Module ActiveDirectory
#-- Show Total
$table += "Password Never Expires: $t_pne
"
#-- Filter
$neverexpires = @(Get-ADUser -filter * -properties PasswordNeverExpires | where { $_.PasswordNeverExpires -eq "true" } | where {$_.enabled -eq "true"} )
$result = @($neverexpires | Select-Object Name, SamAccountName)
#-- Order by (A-Z)
$result = $result | Sort "Name"
#-- Display result on screen
#$result | ft -auto 
$table += $result | ConvertTo-Html -Fragment
 
$format=
		"
		
		 
		"
$title=
		"
			
		Active Directory - Password Never Expires
		Company: $company - Domain: $domain - Date: $date - Owner: $owner
		
		
		"
$footer=
		"
		
			
		ADRT - Active Directory Report Tool
		
		"
$message = ""
$message = $message + "
"
$message = $message + "	Active Directory
"
$message = $message + "	Description	Total
"
$message = $message + "	Password Users Never Expires	$t_pne
"
$message = $message + "	Information Security
"
$message = $message + ""
$report = $format + $title + $table + $footer
#-- Generate HTML file
$report | Out-File $html -Encoding Utf8
#-- Export to CSV
$result | Sort Company | Export-Csv $csv -NoTypeInformation -Encoding Utf8
#-- Send report by email
#$Subject = "[ Report-$mounth ] Active Directory - Password Never Expires"
#$SmtpServer	= $config[11]
#$Port = $config[13]
#$From = $config[15]
#$To = $config[17]
#Send-MailMessage -From $From -To $To -Subject $Subject -Attachments $html,$csv -bodyashtml -Body $message -SmtpServer $SmtpServer -Port $Port
cls

Teste o Premium para desbloquear

Aproveite todos os benefícios por 3 dias sem pagar! 😉
Já tem cadastro?

Outros materiais