Created
July 13, 2021 19:18
-
-
Save SoulOfUniverse/0462aacd966b61369d4293cd07b2559c to your computer and use it in GitHub Desktop.
Sitecore Powershell Get Sitecore Logs Remotely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Set-ExecutionPolicy RemoteSigned | |
#> | |
Import-Module -Name SPE | |
$session = New-ScriptSession -Username "Remoting" -Password "test" -ConnectionUri https://sitecore.instance.local | |
$jobId = Invoke-RemoteScript -ScriptBlock { | |
$filename = "log*" | |
Write-Verbose ("Started at " + [System.DateTime]::Now) | |
$files = Get-ChildItem $SitecoreLogFolder | |
$files | sort LastWriteTime | select -last 10 #| Get-Content -Tail 100 | |
Write-Verbose "#### next ####" -ForegroundColor Yellow | |
$files | Where-Object {$_.Name -like $filename} | sort LastWriteTime | select -last 1 | Get-Content -Tail 300 | |
Write-Verbose ("Finished at " + [System.DateTime]::Now) | |
} -AsJob -Session $session -Verbose | |
Wait-RemoteScriptSession -Session $session -Id $jobId -Delay 1 -Verbose | |
Stop-ScriptSession -Session $session |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment