Is there a way to have a powershell script write to the logs in Adaxes?
I have a powershell script that removes all groups from a user. This script is executed from within Adaxes. I would like to report or log exactly what the script has removed from the user to Adaxes logs. Currently, the script is writing to the %info% field in Active Directory and is adequate, but could be some much more useful if it reported to the Adaxes log.
Here is the information that is reported:
[Groups cleared (7/25/2014 10:35:22 AM): IT, Human Resources, Sales, Shipping]
Here is the script:
Import-Module Adaxes
$user = Get-AdmUser "%distinguishedName%" -Properties MemberOf
if ($user.MemberOf -ne $Null)
{
foreach ($groupDN in $user.MemberOf)
{
$Group_collection = $groupDN.split('=')[1].split(',')[0] + ", $Group_collection"
Remove-AdmGroupMember $groupDN -Members $user -Confirm:$False
}
$old_notes = "%info%"
$Group_collection = "[Groups cleared (%datetime%): " + "$Group_collection" + "]" + "$old_notes"
$Group_collection = $Group_collection.Replace(", ]","]")
Set-Admuser -identity "%distinguishedName%" -Replace @{info=$Group_collection}
}