Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for login_log_access.ps

(view source code of login_log_access.ps as plain text)

  1. # Get today's date in YYYYMMDD format and time in HHmmss format
  2. $Today = Get-Date -Format 'yyyyMMdd'
  3. $Now   = Get-Date -Format 'HHmmss'
  4. # Create the directory if it doesn't exist
  5. if ( !( Test-Path "\\Server\Logs\$Today" -PathType Container ) ) {
  6. 	New-Item -Path "\\Server\Logs" -Name $Today -ItemType "directory"
  7. }
  8. # Log current computer access
  9. "$Env:ComputerName,$Today,$Now\n" | Out-File -FilePath "\\Server\Logs\$Today\$Env:UserName.log" -Encoding ASCII

page last modified: 2024-04-16; loaded in 0.0085 seconds