Hello All, I have a csv/excell file ![]() Server Database ![]() xxxxxx\yyyyyyy zzzzz $ISSAdxxxxxL xxxxxx\yyyyyyy zzzzz $ITIllllllllllallllll xxxxxx\yyyyyyy zzzzz svckaldfasdf xxxxxx\yyyyyyy zzzzz svcSQLSupportSrvr xxxxxx\yyyyyyy zzzzz us438478 I am writing a powershell script to help send an email to the manager of each line of user in the "Users" column to confirm if the user still need an access. Below is my attempt. ##Required for AD Support Import-Module activedirectory # List email ![]() $Dba = "dba@organization.com" #Application ![]() $ApplicationPath = "C:\script\databaseUsers\" $RemediationCSV = $ApplicationPath + "SQL2000_Remediation.csv" $ManagerCSV = $ApplicationPath + "ManagersResult.csv" $UserCSV = $ApplicationPath + "UsersResult.csv" ### Deletes previous file Remove-Item $UserCSV import-csv $RemediationCSV | foreach { $ServerName = $_.Server ![]() $DatabaseName = $_.Database $UserCSV = $_.Users if ($_.Users -like "us.*" or "ew.*" or "os.*" or "sp.*"){ # This is a single user account ### look in the LDAP for user's manager This part I am not sure how to go about this. Please help. ### Create the mail message and add the $Results.csv text file as an attachment### Send-MailMessage –From $InraDba –To $ManagerCSV –Subject "Confirm user access to Database" –Body "Below is the list of users who have access to the database $DatabaseName. As the manager, please confirm that users still need access to the datbase, else access will be revoked in 7 days." -Attachment $UserCSV –SmtpServer } else ### This is a service ![]() Not sure how to go into the database Send-MailMessage –From $InraDba –To $OwnerCSV –Subject "Confirm user access to Database" –Body "Below is the list of service account that have access to the database $. As the owner, please confirm that thise service account still need access to the datbase, else access will be revoked in 7 days." -Attachment $ResultsCSV –SmtpServer some.servers.com } Please help anyway you can to make this script work. Thanks in advance. |
↧
Help Newbie Powershell Scripter here
↧