From c89661407657591a6d72a6547462ebb388050020 Mon Sep 17 00:00:00 2001 From: Easit AB Date: Mon, 11 Dec 2023 12:42:43 +0100 Subject: [PATCH 1/3] update for how we check who called Write-EPRInstallLog --- source/private/Write-EPRInstallLog.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/private/Write-EPRInstallLog.ps1 b/source/private/Write-EPRInstallLog.ps1 index f768396..426c971 100644 --- a/source/private/Write-EPRInstallLog.ps1 +++ b/source/private/Write-EPRInstallLog.ps1 @@ -44,11 +44,11 @@ function Write-EPRInstallLog { ) begin { Write-Verbose "$($MyInvocation.MyCommand) begin" - if ($PSCmdlet.MyInvocation.MyCommand.Name -ne 'New-EPRInstallation') { - Write-Warning "This function should only be used when installing a new instance of ProcessRunner." - } } process { + if ($((Get-PSCallStack)[1].Command) -ne 'New-EPRInstallation') { + Write-Warning "This function should only be used (by 'New-EPRInstallation') when installing a new instance of ProcessRunner. Please use 'Easit.GO.Webservice' for posting data to Easit GO." + } $FormattedDate = Get-Date -Format "yyyy-MM-dd HH:mm:ss.fff" $today = Get-Date -Format "yyyyMMdd" $LogName = "${LogName}_${today}.log" From 75df977fa356419f13e08af9ade522c80286d20b Mon Sep 17 00:00:00 2001 From: Easit AB Date: Mon, 11 Dec 2023 12:43:33 +0100 Subject: [PATCH 2/3] add check if session is elevated and removed 'LogLevel' from loggingParameters hash as it is the same as default --- source/public/New-EPRInstallation.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/public/New-EPRInstallation.ps1 b/source/public/New-EPRInstallation.ps1 index 88d3008..c30af09 100644 --- a/source/public/New-EPRInstallation.ps1 +++ b/source/public/New-EPRInstallation.ps1 @@ -57,6 +57,10 @@ function New-EPRInstallation { [Switch]$DoNotSendInstallationDetailsToEasit ) begin { + $Elevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) + if ( -not $Elevated ) { + throw "In order to install Easit Process Runner correctly, this session requires elevation (i.e open PowerShell as admin)." + } $InformationPreference = 'Continue' $script:ProgressPreference = 'SilentlyContinue' $startingDirectory = Get-Location @@ -84,7 +88,6 @@ function New-EPRInstallation { if (Test-Path -Path $installPackagePath) { $script:loggingParameters = @{ LogDirectory = "$installPackagePath" - LogLevel = 'INFO' } Set-Location $installPackagePath Write-EPRInstallLog -Message "-- Installation start --" @loggingParameters From ef947709c1b59d9e7840e918643dd00ffd960f19 Mon Sep 17 00:00:00 2001 From: Easit AB Date: Mon, 11 Dec 2023 15:04:52 +0100 Subject: [PATCH 3/3] update warning for when using Write-EPRInstallLog instead of Write-CustomLog --- source/private/New-PostBody.ps1 | 6 +++--- source/private/Write-EPRInstallLog.ps1 | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/private/New-PostBody.ps1 b/source/private/New-PostBody.ps1 index 8b4a433..62ff9ea 100644 --- a/source/private/New-PostBody.ps1 +++ b/source/private/New-PostBody.ps1 @@ -49,11 +49,11 @@ function New-PostBody { ) begin { Write-Verbose "$($MyInvocation.MyCommand) begin" - if ($PSCmdlet.MyInvocation.MyCommand.Name -ne 'New-EPRInstallation') { - Write-Warning "This function should only be used when installing a new instance of ProcessRunner. Please use 'Easit.GO.Webservice' for posting data to Easit GO." - } } process { + if ($((Get-PSCallStack)[1].Command) -ne 'New-EPRInstallation') { + Write-Warning "This function should only be used (by 'New-EPRInstallation') when installing a new instance of ProcessRunner. Please use 'Easit.GO.Webservice' for posting data to Easit GO." + } $items = @() $propertiesArray = @() foreach ($prop in $InstallerSettings.FeedbackSettings.postBody.properties) { diff --git a/source/private/Write-EPRInstallLog.ps1 b/source/private/Write-EPRInstallLog.ps1 index 426c971..3e0c92b 100644 --- a/source/private/Write-EPRInstallLog.ps1 +++ b/source/private/Write-EPRInstallLog.ps1 @@ -47,7 +47,7 @@ function Write-EPRInstallLog { } process { if ($((Get-PSCallStack)[1].Command) -ne 'New-EPRInstallation') { - Write-Warning "This function should only be used (by 'New-EPRInstallation') when installing a new instance of ProcessRunner. Please use 'Easit.GO.Webservice' for posting data to Easit GO." + Write-Warning "This function should only be used (by 'New-EPRInstallation') when installing a new instance of ProcessRunner. Please use 'Write-CustomLog' instead." } $FormattedDate = Get-Date -Format "yyyy-MM-dd HH:mm:ss.fff" $today = Get-Date -Format "yyyyMMdd"