Solved

Powershell

Posted on 2016-07-21
13
24 Views
Last Modified: 2016-07-31
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
Comment
Question by:Techie solution
  • 7
  • 6
13 Comments
 
LVL 8

Expert Comment

by:James Rankin
ID: 41723636
0
 

Author Comment

by:Techie solution
ID: 41723648
There is no ~Custom key , what should I do now
0
 
LVL 8

Expert Comment

by:James Rankin
ID: 41723669
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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:Techie solution
ID: 41723700
I dont want to include registry . I need to save the login and logoff user computername and date and time in one file.
0
 
LVL 8

Expert Comment

by:James Rankin
ID: 41723704
Ok, just write the data to a file instead of to the registry using Out-File or similar cmdlet
0
 
LVL 8

Expert Comment

by:James Rankin
ID: 41723707
Although that script I linked to does actually write out to a file when the user logs out
0
 

Author Comment

by:Techie solution
ID: 41725217
Created the powershell script , working for domain admins but not for domain users.
Please help.
0
 
LVL 8

Expert Comment

by:James Rankin
ID: 41725229
Can you post the script you are using? Sounds like it is trying to write to HKLM or a restricted filesystem area
0
 

Accepted Solution

by:
Techie solution earned 0 total points
ID: 41725236
$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
 
LVL 8

Expert Comment

by:James Rankin
ID: 41725253
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
 

Author Comment

by:Techie solution
ID: 41725268
what do you mean i am unable to get you.
0
 
LVL 8

Assisted Solution

by:James Rankin
James Rankin earned 500 total points
ID: 41725305
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
 

Author Closing Comment

by:Techie solution
ID: 41736367
I wrote the code.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
Advanced tutorial on how to run the esxtop command to capture a batch file in csv format in order to export the file and use it for performance analysis. He demonstrates how to download the file using a vSphere web client (or vSphere client) and exp…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question