[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 36
  • 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 solutionVMware SpecialistAuthor 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
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
Techie solutionVMware SpecialistAuthor 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 solutionVMware SpecialistAuthor 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 solutionVMware SpecialistAuthor 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 solutionVMware SpecialistAuthor 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 solutionVMware SpecialistAuthor Commented:
I wrote the code.
0

Featured Post

SMB Security Just Got a Layer Stronger

WatchGuard acquires Percipient Networks to extend protection to the DNS layer, further increasing the value of Total Security Suite.  Learn more about what this means for you and how you can improve your security with WatchGuard today!

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