Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, April 17, 2014 10:19 PM
Is there a powershell cmdlet to let me look at a log/text file on a remote machine?
thanks
All replies (2)
Friday, April 18, 2014 12:34 AM ✅Answered | 1 vote
Hi,
As long as you have access to the file, you can use Get-Content and the UNC path:
Get-Content \\ComputerName\c$\Folder\File.txt
http://ss64.com/ps/get-content.html
Don't retire TechNet! - (Don't give up yet - 12,830+ strong and growing)
Friday, April 18, 2014 7:33 AM ✅Answered | 1 vote
Hi Scott_m,
In addition, if you can try to remote access with powershell remote seesion, you can try the cmdlet Enter-Pssession, for example server1 remote to server2:
Run the cmdlet below on server 2 to configure the server to receive remote access:
Enable-PSRemoting -Force
Then run the script below on server1 to bulid the remote session:
Enter-PSSession -ComputerName server2 #remote to server2
Get-ChildItem c:\windows\logs\*.log -Recurse #filter the log files under the folder "c:\windows\logs"
Get-Content C:\windows\logs\cbs\hahaha.log #read log file
I hope this helps.