<# Set-UserStatus.ps1 **************************************************************** * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED * * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK. IF * * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, * * DO NOT USE IT OUTSIDE OF A SECURE, TEST ENVIRONMENT. * **************************************************************** #> Param( [Parameter(Position=0)] [ValidateSet("Logon","Logoff","Unknown")] [string]$Status="Unknown" ) #no spaces in the filter [adsisearcher]$searcher="samaccountname=$env:username" #find the current user $find = $searcher.FindOne() #get the user object [adsi]$user = $find.Path #define a string to indicate status $note = "{0} {1} to {2}" -f (Get-Date),$status.ToUpper(),$env:computername #update the Info user property $user.Info=$note #commit the change $user.SetInfo()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)