Solved

Powershell

Posted on 2016-07-21
13
26 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Don't miss ATEN at NAB Show April 24-27!

Visit ATEN at NAB Show to learn how our "Seamlessly Entertaining" solutions deliver fast, precise video streaming without delays for the broadcasting and media environment. ATEN will showcase its 16x16 Modular Matrix Switch (VM1600) and KVM Over IP Solution (KE6900 series).

Question has a verified solution.

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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
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…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

740 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