Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 34
  • Last Modified:

Powershell

Hi All,

This is a compliance issue where we need to track each and every time the user has a logon/logoff, and know the date and time.

Can I have a script whaich can be deployed through appsense instead GPO.
0
Techie solution
Asked:
Techie solution
  • 7
  • 6
2 Solutions
 
James RankinCommented:
0
 
Techie solutionAuthor Commented:
There is no ~Custom key , what should I do now
0
 
James RankinCommented:
The custom key is just an area where you write the value. Create or change it as appropriate for your environment - create it with a group policy preference if necessary.
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
Techie solutionAuthor Commented:
I dont want to include registry . I need to save the login and logoff user computername and date and time in one file.
0
 
James RankinCommented:
Ok, just write the data to a file instead of to the registry using Out-File or similar cmdlet
0
 
James RankinCommented:
Although that script I linked to does actually write out to a file when the user logs out
0
 
Techie solutionAuthor Commented:
Created the powershell script , working for domain admins but not for domain users.
Please help.
0
 
James RankinCommented:
Can you post the script you are using? Sounds like it is trying to write to HKLM or a restricted filesystem area
0
 
Techie solutionAuthor Commented:
$LogPath = "\\X-syslog-01\D$\Logs\LogIn.log"
   
If(!(Test-Path -Path $LogPath)){
    New-Item -Path $LogPath -Value "" -ItemType File  
}
   
$LogValue = "Log In User:"+$env:username+",Time:"+(Get-Date).ToString()+",Machine:"+$env:computername
   
Add-Content -Path $LogPath -Value $LogValue
Add-Content -Path $LogPath -Value "*********************"
   



$LogPath = "\\X-syslog-01\D$\Logs\LogOff.log"
   
If(!(Test-Path -Path $LogPath)){
    New-Item -Path $LogPath -Value "" -ItemType File  
}
   
$LogValue = "Log Off User:"+$env:username+",Time:"+(Get-Date).ToString()+",Machine:"+$env:computername
   
Add-Content -Path $LogPath -Value $LogValue
Add-Content -Path $LogPath -Value "*********************"
0
 
James RankinCommented:
The problem is the D ( dollar) share in your log file path is only accessible to administrators. Use a different share , you could simply share the d: drive again under a different share name and use that.
0
 
Techie solutionAuthor Commented:
what do you mean i am unable to get you.
0
 
James RankinCommented:
This is your log path - $LogPath = "\\X-syslog-01\D$\Logs\LogIn.log"

The "d$" share is a hidden share which is only accessible to local Administrators. Therefore the log can only be written by a user with admin rights, hence why it is not working. The second log file path also traverses the d$ share.

Share the D: drive again, this time giving it a different name (for instance "D" instead). Allow Users Read/Write access to the share. Update the log file to $LogPath = "\\X-syslog-01\D\Logs\LogIn.log" This should now work for everyone.

There are security issues possibly attached - you may want to consider a separate file share with no sensitive information underneath, but this should get you going.
0
 
Techie solutionAuthor Commented:
I wrote the code.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now