Skip to content

Instantly share code, notes, and snippets.

@Nillth
Last active July 27, 2022 04:10
Show Gist options
  • Save Nillth/173a5b6dd7c5e802c119e88d8e7a6fec to your computer and use it in GitHub Desktop.
Save Nillth/173a5b6dd7c5e802c119e88d8e7a6fec to your computer and use it in GitHub Desktop.
<#
.NOTES
===========================================================================
Created by: Marc Collins
Organization: Qlik
Filename: Set-GeneratePublisherEvidence.ps1
===========================================================================
.DESCRIPTION
Configure GeneratePublisherEvidence
https://community.qlik.com/t5/Knowledge/An-error-occurred-Failed-to-load-connection-error-message-in/ta-p/1714051
https://community.qlik.com/t5/Knowledge/Database-connection-fails-with-Error-quot-The-selected-Connector/ta-p/1713650
https://community.qlik.com/t5/Knowledge/Data-connections-in-Qlik-Sense-not-visible-in-Data-Load-Editor/ta-p/1715385
https://community.qlik.com/t5/Knowledge/App-Reload-Fail-With-quot-Error-QlikView-Connector-is-not/ta-p/1714695
https://community.qlik.com/t5/Knowledge/Operation-and-License-Monitor-App-Fail-With-Error-Connection/ta-p/1713805
#>
function Set-GeneratePublisherEvidence
{
param
(
[switch]$Enabled,
[Parameter(ParameterSetName = 'Machine',
Mandatory = $true)]
[switch]$Machine,
[Parameter(ParameterSetName = 'Application',
Mandatory = $true)]
[System.IO.FileInfo]$File
)
switch ($PsCmdlet.ParameterSetName)
{
"Machine" {
$Config = [System.Configuration.ConfigurationManager]::OpenMachineConfiguration()
}
"Application" {
$Config = [System.Configuration.ConfigurationManager]::OpenExeConfiguration($ConfigFile.FullName)
}
}
Add-Type -AssemblyName System.Xml.Linq
$runtimeSection = $Config.GetSection("runtime")
[System.Xml.Linq.XElement]$runtimeSectionXML = $runtimeSection.SectionInformation.GetRawXml()
if ($null -eq $runtimeSectionXML)
{
$runtimeSectionXML = [System.Xml.Linq.XElement]::new([System.Xml.Linq.XName]::Get("runtime"))
}
$el = $runtimeSectionXML.Element("generatePublisherEvidence")
if ($null -eq $el)
{
$el = [System.Xml.Linq.XElement]::new([System.Xml.Linq.XName]::Get("generatePublisherEvidence"))
$runtimeSectionXML.Add($el)
}
$el.SetAttributeValue("enabled", $Enabled.IsPresent)
$runtimeSection.SectionInformation.SetRawXml($runtimeSectionXML.ToString())
$Config.Save()
}
Function Show-OptionMenu
{
Write-Host "Select from the Following Options"
Write-Host "`t(" -NoNewline; Write-Host "M" -NoNewline -ForegroundColor Yellow; Write-Host ")achine Config"
Write-Host "`t(" -NoNewline; Write-Host "A" -NoNewline -ForegroundColor Green; Write-Host ")pplication Config"
Write-Host "`t(" -NoNewline; Write-Host "E" -NoNewline -ForegroundColor Red; Write-Host ")xit"
#Write-Host "`t(A)pplication Configs"
#Write-Host "`t(E)xit"
$Response = Read-Host #"(M)achine Config or (A)pplication Configs - (E)xit"
Switch ($Response)
{
"A"{
$ApplicationConfigs = Get-ChildItem 'C:\Program Files\Common Files\Qlik\Custom Data' -Recurse -Filter "qv*.exe"
foreach ($ConfigFile in $ApplicationConfigs)
{
Write-Host "Processing: $($ConfigFile.FullName)"
Set-GeneratePublisherEvidence -File $ConfigFile.FullName
}
}
"M"{
Write-Host "Processing: Machine Config"
Set-GeneratePublisherEvidence -Machine
}
"E"{
"Exit"
}
default{
Write-Host "Incorrect Selection"; Show-OptionMenu
}
}
}
Show-OptionMenu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment