Skip to content

Instantly share code, notes, and snippets.

@bsnape
Last active August 10, 2017 12:08
Show Gist options
  • Save bsnape/84f45e497606e5d9abe6a15b09725124 to your computer and use it in GitHub Desktop.
Save bsnape/84f45e497606e5d9abe6a15b09725124 to your computer and use it in GitHub Desktop.
function Invoke-SeqLogConfiguration {
$tempRoot = "D:"
$tempDirectory = "$tempRoot\temp"
if ([System.IO.Directory]::Exists($tempDirectory) -eq $true) {
rm $tempDirectory -Recurse -Force -Verbose -ErrorAction Ignore
}
mkdir $tempDirectory -ErrorAction Ignore
Invoke-WebRequest -Uri "https://getseq.blob.core.windows.net/releases/Seq-4.1.17.msi" -OutFile "$tempDirectory\seq.msi" -ErrorAction Stop -Verbose
Start-Process -FilePath "$tempDirectory\seq.msi" /qn -Wait
$serviceDisplayName = "Serilog Service"
New-Service -Name "SerilogService" -BinaryPathName "C:\Program Files\Seq\Seq.exe run" -DisplayName $serviceDisplayName -StartupType Automatic -Description "Listening for logs on port 5341" -Verbose
Start-Service -displayname $serviceDisplayName -Verbose
$serilogFirewallRule = Get-NetFirewallRule -Name "AllowLoggingInbound" -ErrorAction Ignore
if ($serilogFirewallRule -eq $null) {
New-NetFirewallRule -Name "AllowLoggingInbound" -DisplayName "Allow Inbound Port 5341" -Description "Allow Inbound Port 5341" -Direction Inbound -LocalPort 5341 -Protocol TCP -Action Allow
}
exit
}
function Invoke {
$logFile = "D:\temp\logs\configure-seq-log-{0}.txt" -f (Get-Date).ToString("yyyy-MM-dd-HH_mm_ss")
Start-Transcript -Path $logFile
Invoke-SeqLogConfiguration
Stop-Transcript
}
Invoke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment