Quantcast
Channel: Software Communities : Popular Discussions - ActiveRoles
Viewing all articles
Browse latest Browse all 1277

Get the samAccountname from the currentUser

$
0
0

Hello,

 

i started right now scripting with PowerShell for ARS. I want fid out the samAccoutName of the current user.

 

In VBS is the code:

 

Sub onPreModify(Request)

 

If (Request.Class <> "user") Then Exit Sub

 

strUserName = Request.get("sAMACcountName")

Eventlog.ReportEvent 4, "This is the samAccoutName: " & $currentUser

 

End If

End Sub

 

Now I want to write this code in PS. I've try:

 

function onPreModify($Request)

{

$currentUser = [string]$Request.Get("samAccountName")

 

}

 

or

 

function onPreModify($Request)

{

If ($Request.Class -ne "user")

{

$currentUser = [string]$Request.Get("samAccountName")

$EventLog.ReportEvent(4,"This is the samAccoutName: " + $currentUser

 

}

}

 

The EventLog works, but the var $currentUser is still empty.

 

//Background is: This user shoud add to a Group. Befor the user can be added to this group, must prove some settings.

 

 

with kind regards

and sorry for my bad gramma

 

woody


Viewing all articles
Browse latest Browse all 1277

Trending Articles