VMware Cloud Community
GoldWatch
Contributor
Contributor

SnapReminder with Local Users (No AD)

Hey All, At one point I was working with the SnapReminder script that everyone loves, but I do not have my vCenter connected to an Active Directory and use only local users. I have tried editing this part:

foreach ($snap in (Get-Cluster Eng-Cluster | Get-VM | Get-Snapshot | Where {$_.Created -lt ((Get-Date).AddDays(-14))})){

   $SnapshotInfo = Get-SnapshotExtra $snap

   $mailto = ((Find-User $SnapshotInfo.Creator).Properties.mail)

   $EmailCc = "myemail@emaildomain.com"

   SnapMail $mailto $SnapshotInfo

}

Since I don't have AD the .Properties.mail obviously doesn't work for me.  I've tried changing it to different things like .properties.name or even just left it as Find-User $Snapshotinfo.Creator and then doing + "@domain.com", but I am just getting errors.  The errors seem to be when trying to get the creators name.  I put the CC to myself and I get all the emails but with no actual to: part for the correct person.

I am using Vsphere Powercli 5.5 Release 1 .  Is there a way to make this for Local Users that I am just not looking into correctly?

Thanks,

Tyler

0 Kudos
5 Replies
sneddo
Hot Shot
Hot Shot

Are you wanting to lookup the local user in AD, or just generate the email address based off the local user?

If you don't need to touch AD, then don't call Find-User and just append the "@domain.com" and it should just work. Otherwise, you will need to modify Find-User as the username will not be in domain\username format.

0 Kudos
GoldWatch
Contributor
Contributor

I see what you are saying, but for some reason it is unable to even get the creator information so that's not even coming in.  Here is a screen shot of the errors.

0 Kudos
sneddo
Hot Shot
Hot Shot

Those errors have nothing to do with using local accounts, it looks like there is some issue returning the TaskManager view correctly. Do you have multiple vCenters connected? Looks like it is returning an array, where it is expecting a single object.

Perhaps try updating to PowerCLI 5.8 R1 as well.

GoldWatch
Contributor
Contributor

Its now running with no errors, but I'm not getting anything for the $mailto = $snapshotInfo.Creator + "@domain.com" .  It just tosses me @domain.com like its getting null expressions from the Get-SnapshotExtra function. I noticed my vCenter has it purge every 180 Days, so I wonder if my events were erased so it can't find the creator?

0 Kudos
GoldWatch
Contributor
Contributor

Has anyone else out there got a script working that uses Local Accounts instead of AD?

0 Kudos