Quantcast
Channel: psappdeploytoolkit Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1769

New Post: Is there a way to disable logging?

$
0
0
Well AppDeployToolkitMain.ps1 does have DisableLogging as a parameter
[switch]$DisableLogging = $false,
but it also has this conflicting chunk of code (So Devs, is it set in Param or as part of the code? )
        ## Initialize $DisableLogging variable to avoid error if 'Set-StrictMode' is set
        If (-not (Test-Path -Path 'variable:DisableLogging')) { $DisableLogging = $false }
Anyhow, for your purposes, it is doable. The problem is that it's not that clean and easy to do it as it should.
It's also not very useful to turn off logging so I can understand why they didn't bother to test it.
Why have scripts run blind and not have logs to know what happened when things go wrong?
But you have your reasons, right?


Any how, without actually testing it, I would try these 2 things:

Option 1: declare $DisableLogging in Deploy-Application.ps1 before it Dot sources AppDeployToolkitMain.ps1
In Deploy-Application.ps1 add this:
[switch]$DisableLogging = $true
Before this chunk of code
    ## Dot source the required App Deploy Toolkit Functions
    Try {
        [string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
        If (-not (Test-Path -Path $moduleAppDeployToolkitMain -PathType Leaf)) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
        . $moduleAppDeployToolkitMain
    }
    Catch {
        [int32]$mainExitCode = 1
        Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: `n$($_.Exception.Message)`n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
        Exit $mainExitCode
    }
Somehow, I don't have "warm and fuzzy feelings" that Option 1 will work so...



Option 2: Modify Deploy-Application.ps1 by adding -DisableLogging when it Dot sources AppDeployToolkitMain.ps1
    ## Dot source the required App Deploy Toolkit Functions
    Try {
        [string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
        If (-not (Test-Path -Path $moduleAppDeployToolkitMain -PathType Leaf)) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
        . $moduleAppDeployToolkitMain -DisableLogging
    }
    Catch {
        [int32]$mainExitCode = 1
        Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: `n$($_.Exception.Message)`n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
        Exit $mainExitCode
    }
I'm more confident that this will work but this is modifying one of the "Do not touch" sections of Deploy-Application.ps1

Option 3: Spoof it!

Edit AppDeployToolkitConfig.xml and change the log file location to %temp% where nobody will look
<Toolkit_LogPath>$envTemp</Toolkit_LogPath>


NOTE: The source I posted is from the most current v3.6 beta so it might not match 100% but the $DisableLogging variable name probably has not been changed since v3.5.

Viewing all articles
Browse latest Browse all 1769

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>