(view source code of login_log_ip_mac.ps as plain text)
$MACAddress = ( Get-NetAdapter | Where-Object -Property Status -eq Up | Select-Object -First 1 ).MacAddress
$IPAddress = ( Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias Ethernet | Select-Object -First 1 ).IPAddress
$Today = Get-Date -Format 'yyyyMMdd'
# Append IP and MAC adresses to log file
"$IPAddress,$MACAddress\n" | Out-File -FilePath "\\Server\Logs\$Today\$Env:UserName.log" -Encoding ASCII -Append
page last modified: 2023-03-10