<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Requires &amp;mdash; cruisinit</title>
    <link>https://wordsmith.social/cruisinit/tag:Requires</link>
    <description>Sample work, IT tools self-made, IT tools usage. There&#39;s more to collect and publish. PGP Fingerprint 3E2A EC6D A0D4 214B EC3E 6593 4AC3 784F D6A4 25F4</description>
    <pubDate>Wed, 13 May 2026 23:21:25 +0000</pubDate>
    <item>
      <title>ProgramUpdater.ps1, Teil 1</title>
      <link>https://wordsmith.social/cruisinit/programupdater-ps1</link>
      <description>&lt;![CDATA[Automates upgrading a .NET and ASP.NET web application on IIS with MSSQL backend and .NET client installers. Chooses correct deployment packages, starts data model upgrade, builds a new web.config with the new settings from deployment packages and by selectively copying the installation specific, client side settings from the old files by attrib name.&#xA;&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;#Requires -Version 4/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;#Requires -RunAsAdmin/span&#xA;&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;# Todo: $strNewVersion, zunaechst aus .msi-Props ausgelesen, aus dann entpackter Anwendung -&amp;gt; bin\ -&amp;gt; .dll neu auslesen, falls nicht zueinander passende Deploymentpakete .zip und .msi zusammenkopiert wurden [string]$strNewVersion = ((Get-ItemProperty ($strNewVerFolder + &#34;bin\&amp;lt;filename&amp;gt;.dll&#34;)).VersionInfo).ProductVersion fuehrt aktuell zu Mosern ueber mangelnde Zugriffsrechte/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;# Todo: Optische Aufbereitung des Mailbodys oder Attachments ueber CC-Webservice/span&#xA;&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;&amp;lt;#/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;.SYNOPSIS/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    Update &amp;lt;Program&amp;gt; Standard. Automates upgrading a .NET and ASP.NET web application on IIS with MSSQL backend and .NET client installers. Chooses correct deployment packages, starts data model upgrade, builds a new web.config with the new settings from deployment packages and by selectively copying the installation specific, client side settings from the old files by attrib name./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;.DESCRIPTION/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    Update &amp;lt;Program&amp;gt; Standard/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    Syntax: [D:\Websites\Deploy\UpdaterScript\]ProgramUpdaterAsAdmin.lnk (with a script file path in the command line saying D:\Websites\Deploy\UpdaterScript\ProgramUpdater.ps1. The default paths (see below) to both .INIs will usually work. If you need to supply an absolute path to one or boths .INIs, edit ProgramUpdaterAsAdmin.lnk&#39;s command line along this syntax note: D:\Websites\Deploy\UpdaterScript\ProgramUpdater.ps1 [[-IniFileUser] &amp;lt;String&amp;gt;] [[-IniFileWebConfig] &amp;lt;String&amp;gt;] [&amp;lt;CommonParameters&amp;gt;] )/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    Use this internal helper at your own risk. Addressed audience are informed IT workers. The author cannot be held liable for loss of data by the use of this script./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     This script requires PowerShell version 4 (in WMF, but if you need update anyway, install WMF 5, https://www.microsoft.com/en-us/download/confirmation.aspx?id=54616&amp;amp;6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1)./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     This script requires to be run as admin./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     You may supply absolute paths inc. file name to the two .ini files as the only parameter. Use &#34; &#34; if path contains blanks./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     Run without parameter, this script searches its .ini at D:\Websites\Deploy\UpdaterScript\ProgramUpdaterSettingsuser.ini plus D:\Websites\Deploy\UpdaterScript\ProgramUpdaterSettingsweb.config.ini. (In fact, this script retrieves its own full path and/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        replaces &#34;.ps1&#34; with &#34;Settingsuser.ini&#34; / &#34;Settingsweb.config.ini&#34;, and this will regularly lead to the paths mentioned above.)/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     Your website folder path in Settingsuser.ini must start with &#34;D:\Websites\&#34;. If it does not, the script adds this automatically./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     Your website folder path in Settingsuser.ini must end with &#34;\Company.Program.Gui\&#34;. If it does not, the script adds this automatically./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     Deployment folder is always D:\websites\deploy\. Copy your deployment packages (.ZIPs, .MSIs, UpgradeTool.exe) into this folder./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     The current default for the MS SQL version (part of deployment packages&#39; names) is 2008  (means: 2008 and 2008 R2). You can define other versions (allowed: 2012, 2014) by machine name in Settingsuser.ini, and you can change the default in Settingsuser.ini. When the script lists the detected parameters and paths and asks for your permission to go on, check the MS SQL version (check everything). If the version does not match the &amp;lt;Program&amp;gt; instance of SQL Server on the customer&#39;s machine, stop the script and edit Settingsuser.ini before you start it again./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     To not overwrite user settings during deployment, this script is shipped with ProgramUpdaterSettingsusermaster.ini used for dev tests. You can check this e.g. for version updates. You are warned if script and ini versions (inside) don&#39;t fit./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     The old version is detected from &amp;lt;WebsiteFolder&amp;gt;\bin\&amp;lt;FirstDll&amp;gt;.dll&#39;s file properties (&#39;Product version&#39;)./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     The new version is detected from D:\websites\deploy\&amp;lt;FirstMsi&amp;gt;.msi&#39;s file properties (&#39;Tags&#39;)./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     The backup folder is always &amp;lt;WebsiteFolder&amp;gt;&amp;lt;OldVersion&amp;gt;&amp;lt;DateTime&amp;gt;./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     The script log folder is always D:\websites\deploy\UpdateLogs\&amp;lt;DateTime&amp;gt;\. You will find some explicitly logged results, powershell script errors,/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        and the UpgradeTool log in there./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     DevExpress deployment folder is always D:\websites\deploy\DevExpress\&amp;lt;Version&amp;gt;\. Ensure the DevExpress runtime files are copied to this folder before./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;     The script stops the IIS website for the duration of its run./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;.PARAMETER IniFileUser/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    Default: &amp;lt;ThisScriptsPath&amp;gt;\&amp;lt;ThisScriptsNameWithoutExtension&amp;gt;Settingsuser.ini (almost always D:\Websites\Deploy\UpdaterScript\ProgramUpdaterSettingsuser.ini)./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;.PARAMETER IniFileWebConfig/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    Default: &amp;lt;ThisScriptsPath&amp;gt;\&amp;lt;ThisScriptsNameWithoutExtension&amp;gt;Settingsweb.config.ini (almost always D:\Websites\Deploy\UpdaterScript\ProgramUpdaterSettingsweb.config.ini)./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;.EXAMPLE/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    PS C:\util&amp;gt; .\ProgramUpdaterAsAdmin.lnk/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    # This script is shipped with ProgramUpdaterAsAdmin.lnk, you should prefer this. If you need to change the call e.g. to call another .ini, edit the .lnk./span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;.NOTES/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    Author:  ps@&amp;lt;mydomain&amp;gt;.de/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    Date:    2 June 2016 to 24 Jan 2019/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    Todo:    $strNewVersion, zunaechst aus .msi-Props ausgelesen, aus dann entpacktem CC -&amp;gt; bin\ -&amp;gt; .dll neu auslesen, falls nicht zueinander passende Deploymentpakete .zip und .msi zusammenkopiert wurden [string]$strNewVersion = ((Get-ItemProperty ($strNewVerFolder + &#34;bin\Company.Program.BusinessLogik.dll&#34;)).VersionInfo).ProductVersion fuehrt aktuell zu Mosern ueber mangelnde Zugriffsrechte/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    Todo:    Optische Aufbereitung des Mailbodys oder Attachments ueber Webservice/span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    Version: 1.2.0.2  -- check with TFS/span&#xA;&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;#&amp;gt;/span&#xA;&#xA;span style=&#34;color:#007020; font-weight:bold&#34;param/span&#xA;(&#xA;    [Parameter(Position=0)]&#xA;    span style=&#34;color:#60a0b0; font-style:italic&#34;# [string]$strWebsiteFolder = &#34;D:\Websites\Company\Company.Program.Gui\&#34;/span&#xA;    [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$IniFileUser/span = span style=&#34;color:#19177c&#34;$PSCommandPath/span -replace(span style=&#34;color:#4070a0&#34;&#34;.ps1&#34;/span,span style=&#34;color:#4070a0&#34;&#34;Settingsuser.ini&#34;/span),&#xA;    [Parameter(Position=1)]&#xA;    span style=&#34;color:#60a0b0; font-style:italic&#34;# [string]$strWebsiteFolder = &#34;D:\Websites\Company\Company.Program.Gui\&#34;/span&#xA;    [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$IniFileWebConfig/span = span style=&#34;color:#19177c&#34;$PSCommandPath/span -replace(span style=&#34;color:#4070a0&#34;&#34;.ps1&#34;/span,span style=&#34;color:#4070a0&#34;&#34;Settingsweb.config.ini&#34;/span)&#xA;&#xA;)&#xA;&#xA;span style=&#34;color:#007020; font-weight:bold&#34;PROCESS/span&#xA;{&#xA;&#xA;span style=&#34;color:#19177c&#34;$Error/span.span style=&#34;color:#06287e&#34;Clear/span()&#xA;&#xA;span style=&#34;color:#007020; font-weight:bold&#34;if/span (span style=&#34;color:#19177c&#34;$IniFileUser/span -in (span style=&#34;color:#19177c&#34;$null/span, span style=&#34;color:#4070a0&#34;&#34;&#34;/span)) { [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$IniFileUser/span = span style=&#34;color:#19177c&#34;$PSCommandPath/span -replace(span style=&#34;color:#4070a0&#34;&#34;.ps1&#34;/span,span style=&#34;color:#4070a0&#34;&#34;Settingsuser.ini&#34;/span) }&#xA;span style=&#34;color:#007020; font-weight:bold&#34;if/span (span style=&#34;color:#19177c&#34;$IniFileUserWebConfig/span -in (span style=&#34;color:#19177c&#34;$null/span, span style=&#34;color:#4070a0&#34;&#34;&#34;/span)) { [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$IniFileWebConfig/span = span style=&#34;color:#19177c&#34;$PSCommandPath/span -replace(span style=&#34;color:#4070a0&#34;&#34;.ps1&#34;/span,span style=&#34;color:#4070a0&#34;&#34;Settingsweb.config.ini&#34;/span) }&#xA;&#xA;[span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strWebConfigMsiContent/span = span style=&#34;color:#4070a0&#34;@&#34;/span&#xA;span style=&#34;color:#4070a0&#34;&amp;lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&amp;gt;/span&#xA;span style=&#34;color:#4070a0&#34;&amp;lt;configuration&amp;gt;/span&#xA;span style=&#34;color:#4070a0&#34;    &amp;lt;system.webServer&amp;gt;/span&#xA;span style=&#34;color:#4070a0&#34;        &amp;lt;directoryBrowse enabled=&#34;true&#34; showFlags=&#34;Date, Time, Size, Extension, LongDate&#34; /&amp;gt;/span&#xA;span style=&#34;color:#4070a0&#34;    &amp;lt;/system.webServer&amp;gt;/span&#xA;span style=&#34;color:#4070a0&#34;&amp;lt;/configuration&amp;gt;/span&#xA;span style=&#34;color:#4070a0&#34;&#34;@/span&#xA;&#xA;[span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strIniVersion/span = span style=&#34;color:#4070a0&#34;&#34;1.520181019&#34;/span&#xA;&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;# if ($psise -ne $null) { $strWebsiteFolder = &#34;Company&#34; } # Edit the $strWebsiteFolder part of this line to run this script in ISE./span&#xA;&#xA;span style=&#34;color:#06287e&#34;Add-Type/span -AssemblyName System.span style=&#34;color:#06287e&#34;Windows/span.span style=&#34;color:#06287e&#34;Forms/span&#xA;span style=&#34;color:#06287e&#34;Import-Module/span WebAdministration&#xA;&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;#region Functions/span&#xA;&#xA;span style=&#34;color:#007020; font-weight:bold&#34;Function/span Get-IniContent&#xA;{  &#xA;    span style=&#34;color:#60a0b0; font-style:italic&#34;&amp;lt;#  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    .Synopsis  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        Gets the content of an INI file  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;          /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    .Description  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        Gets the content of an INI file and returns it as a hashtable  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;          /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    .Notes  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        Author        : Oliver Lipkau &amp;lt;oliver@lipkau.net&amp;gt;  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        Blog        : http://oliver.lipkau.net/blog/  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        Source        : https://github.com/lipkau/PsIni /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;                      http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91 /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        Version        : 1.0 - 2010/03/12 - Initial release  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;                      1.1 - 2014/12/11 - Typo (Thx SLDR) /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;                                         Typo (Thx Dave Stiff) /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;          /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        #Requires -Version 2.0  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;          /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    .Inputs  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        System.String  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;          /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    .Outputs  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        System.Collections.Hashtable  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;          /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    .Parameter FilePath  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        Specifies the path to the input file.  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;          /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    .Example  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        $FileContent = Get-IniContent &#34;C:\myinifile.ini&#34;  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        -----------  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        Description  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        Saves the content of the c:\myinifile.ini in a hashtable called $FileContent  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;      /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    .Example  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        $inifilepath | $FileContent = Get-IniContent  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        -----------  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        Description  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        Gets the content of the ini file passed through the pipe into a hashtable called $FileContent  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;      /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    .Example  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        C:\PS&amp;gt;$FileContent = Get-IniContent &#34;c:\settings.ini&#34;  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        C:\PS&amp;gt;$FileContent&#34;Section&#34;  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        -----------  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        Description  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        Returns the key &#34;Key&#34; of the section &#34;Section&#34; from the C:\settings.ini file  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;          /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    .Link  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;        Out-IniFile  /span&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;    #&amp;gt;/span  &#xA;      &#xA;    span style=&#34;color:#007020; font-weight:bold&#34;Param/span(  &#xA;        [ValidateNotNullOrEmpty()]  &#xA;        [ValidateScript({(span style=&#34;color:#06287e&#34;Test-Path/span span style=&#34;color:#19177c&#34;$/span) -and ((span style=&#34;color:#06287e&#34;Get-Item/span span style=&#34;color:#19177c&#34;$/span).span style=&#34;color:#06287e&#34;Extension/span -eq span style=&#34;color:#4070a0&#34;&#34;.ini&#34;/span)})]  &#xA;        [Parameter(ValueFromPipeline=span style=&#34;color:#19177c&#34;$True/span,Mandatory=span style=&#34;color:#19177c&#34;$True/span)]  &#xA;        [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$FilePath/span  &#xA;    )  &#xA;      &#xA;    span style=&#34;color:#06287e&#34;Write-Verbose/span span style=&#34;color:#4070a0&#34;&#34;$($MyInvocation.MyCommand.Name):: Function started&#34;/span&#xA;          &#xA;    span style=&#34;color:#06287e&#34;Write-Verbose/span span style=&#34;color:#4070a0&#34;&#34;$($MyInvocation.MyCommand.Name):: Processing file: $Filepath&#34;/span  &#xA;              &#xA;    span style=&#34;color:#19177c&#34;$ini/span = @{}  &#xA;    span style=&#34;color:#007020; font-weight:bold&#34;switch/span -regex -file span style=&#34;color:#19177c&#34;$FilePath/span  &#xA;    {  &#xA;        span style=&#34;color:#4070a0&#34;&#34;^\[(.+)\]$&#34;/span span style=&#34;color:#60a0b0; font-style:italic&#34;# Section  /span&#xA;        {  &#xA;            span style=&#34;color:#19177c&#34;$section/span = span style=&#34;color:#19177c&#34;$matches/span[1]  &#xA;            span style=&#34;color:#19177c&#34;$ini/span[span style=&#34;color:#19177c&#34;$section/span] = @{}  &#xA;            span style=&#34;color:#19177c&#34;$CommentCount/span = 0  &#xA;        }  &#xA;        span style=&#34;color:#4070a0&#34;&#34;^(;.)$&#34;/span span style=&#34;color:#60a0b0; font-style:italic&#34;# Comment  /span&#xA;        {  &#xA;            span style=&#34;color:#007020; font-weight:bold&#34;if/span (!(span style=&#34;color:#19177c&#34;$section/span))  &#xA;            {  &#xA;                span style=&#34;color:#19177c&#34;$section/span = span style=&#34;color:#4070a0&#34;&#34;No-Section&#34;/span  &#xA;                span style=&#34;color:#19177c&#34;$ini/span[span style=&#34;color:#19177c&#34;$section/span] = @{}  &#xA;            }  &#xA;            span style=&#34;color:#19177c&#34;$value/span = span style=&#34;color:#19177c&#34;$matches/span[1]  &#xA;            span style=&#34;color:#19177c&#34;$CommentCount/span = span style=&#34;color:#19177c&#34;$CommentCount/span + 1  &#xA;            span style=&#34;color:#19177c&#34;$name/span = span style=&#34;color:#4070a0&#34;&#34;Comment&#34;/span + span style=&#34;color:#19177c&#34;$CommentCount/span  &#xA;            span style=&#34;color:#19177c&#34;$ini/spanspan style=&#34;color:#19177c&#34;$section/span = span style=&#34;color:#19177c&#34;$value/span  &#xA;        }   &#xA;        span style=&#34;color:#4070a0&#34;&#34;(.+?)\s=\s(.)&#34;/span span style=&#34;color:#60a0b0; font-style:italic&#34;# Key  /span&#xA;        {  &#xA;            span style=&#34;color:#007020; font-weight:bold&#34;if/span (!(span style=&#34;color:#19177c&#34;$section/span))  &#xA;            {  &#xA;                span style=&#34;color:#19177c&#34;$section/span = span style=&#34;color:#4070a0&#34;&#34;No-Section&#34;/span  &#xA;                span style=&#34;color:#19177c&#34;$ini/span[span style=&#34;color:#19177c&#34;$section/span] = @{}  &#xA;            }  &#xA;            span style=&#34;color:#19177c&#34;$name/span,span style=&#34;color:#19177c&#34;$value/span = span style=&#34;color:#19177c&#34;$matches/span[1..span style=&#34;color:#06287e&#34;2/span]  &#xA;            span style=&#34;color:#19177c&#34;$ini/spanspan style=&#34;color:#19177c&#34;$section/span = span style=&#34;color:#19177c&#34;$value/span  &#xA;        }  &#xA;    }&#xA;    &#xA;    span style=&#34;color:#06287e&#34;Write-Verbose/span span style=&#34;color:#4070a0&#34;&#34;$($MyInvocation.MyCommand.Name):: Finished Processing file: $FilePath&#34;/span  &#xA;    span style=&#34;color:#007020; font-weight:bold&#34;Return/span span style=&#34;color:#19177c&#34;$ini/span  &#xA;      &#xA;    span style=&#34;color:#06287e&#34;Write-Verbose/span span style=&#34;color:#4070a0&#34;&#34;$($MyInvocation.MyCommand.Name):: Function ended&#34;/span&#xA;} span style=&#34;color:#60a0b0; font-style:italic&#34;# Function Get-IniContent/span&#xA;&#xA;span style=&#34;color:#007020; font-weight:bold&#34;function/span CopyWebConfigAttrValue(span style=&#34;color:#19177c&#34;$rootNew/span, span style=&#34;color:#19177c&#34;$rootOld/span, span style=&#34;color:#19177c&#34;$strSection/span, span style=&#34;color:#19177c&#34;$strKeyName/span, span style=&#34;color:#19177c&#34;$strLog/span)&#xA;{&#xA;    [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strKeyValueRead/span = span style=&#34;color:#19177c&#34;$rootOld/span.span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;//$strSection&#34;/span).span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;add[@key=&#39;$strKeyName&#39;]/@value&#34;/span).&#39;span style=&#34;color:#60a0b0; font-style:italic&#34;#text&#39;/span&#xA;    [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strKeyValueReadNew/span = span style=&#34;color:#19177c&#34;$rootNew/span.span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;//$strSection&#34;/span).span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;add[@key=&#39;$strKeyName&#39;]/@value&#34;/span).&#39;span style=&#34;color:#60a0b0; font-style:italic&#34;#text&#39;/span&#xA;    span style=&#34;color:#007020; font-weight:bold&#34;if/span ( span style=&#34;color:#19177c&#34;$strKeyValueReadNew/span -in (span style=&#34;color:#19177c&#34;$null/span, span style=&#34;color:#4070a0&#34;&#34;&#34;/span) ) &#xA;    {&#xA;        span style=&#34;color:#19177c&#34;$newItem/span = span style=&#34;color:#19177c&#34;$rootNew/span.span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;//$strSection&#34;/span).span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;add[1]&#34;/span).span style=&#34;color:#06287e&#34;Clone/span()&#xA;        span style=&#34;color:#19177c&#34;$newItem/span.span style=&#34;color:#06287e&#34;SetAttribute/span(span style=&#34;color:#4070a0&#34;&#34;key&#34;/span,span style=&#34;color:#19177c&#34;$strKeyName/span)&#xA;        span style=&#34;color:#19177c&#34;$newItem/span.span style=&#34;color:#06287e&#34;SetAttribute/span(span style=&#34;color:#4070a0&#34;&#34;value&#34;/span,span style=&#34;color:#19177c&#34;$strKeyValueRead/span)&#xA;        span style=&#34;color:#19177c&#34;$rootNew/span.span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;//$strSection&#34;/span).span style=&#34;color:#06287e&#34;AppendChild/span(span style=&#34;color:#19177c&#34;$newItem/span)&#xA;        [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strMsg/span = span style=&#34;color:#4070a0&#34;&#34;web.config: Setting &#39;$strSection.$strKeyName&#39; did not exist in webref.config (you should maintain webref.config) and has been automatically created by this script in target web.config, value has been set to &#39;$strKeyValueRead&#39;, from former version&#39;s web.config. &#34;/span + (span style=&#34;color:#06287e&#34;Get-Date/span -format span style=&#34;color:#4070a0&#34;&#34;yyyyMMddHHmm&#34;/span)&#xA;        span style=&#34;color:#06287e&#34;Add-Type/span -AssemblyName PresentationFramework&#xA;        [System.span style=&#34;color:#06287e&#34;Windows/span.span style=&#34;color:#06287e&#34;MessageBox/span]::Show(span style=&#34;color:#19177c&#34;$strMsg/span,&#39;&amp;lt;Program&amp;gt; Updater: New Setting&#39;,&#39;OK&#39;,&#39;Error&#39;)&#xA;        span style=&#34;color:#06287e&#34;Add-Content/span -Value span style=&#34;color:#19177c&#34;$strMsg/span -PassThru -Path span style=&#34;color:#19177c&#34;$strLog/span&#xA;    }&#xA;    span style=&#34;color:#007020; font-weight:bold&#34;else/span&#xA;    {&#xA;        span style=&#34;color:#19177c&#34;$rootNew/span.span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;//$strSection&#34;/span).span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;add[@key=&#39;$strKeyName&#39;]/@value&#34;/span).&#39;span style=&#34;color:#60a0b0; font-style:italic&#34;#text&#39; = $strKeyValueRead/span&#xA;    }&#xA;    [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strKeyValueWritten/span = span style=&#34;color:#19177c&#34;$rootNew/span.span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;//$strSection&#34;/span).span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;add[@key=&#39;$strKeyName&#39;]/@value&#34;/span).&#39;span style=&#34;color:#60a0b0; font-style:italic&#34;#text&#39;/span&#xA;    span style=&#34;color:#007020; font-weight:bold&#34;switch/span (span style=&#34;color:#19177c&#34;$strKeyName/span)&#xA;    {&#xA;        &#39;DbVerbindungString&#39; {&#xA;            span style=&#34;color:#06287e&#34;Add-Content/span -Value (span style=&#34;color:#19177c&#34;$strKeyName/span + span style=&#34;color:#4070a0&#34;&#34;: &#34;/span + span style=&#34;color:#19177c&#34;$strKeyValueWritten/span + (span style=&#34;color:#06287e&#34;Get-Date/span -format span style=&#34;color:#4070a0&#34;&#34;yyyyMMddHHmm&#34;/span)) -PassThru -Path span style=&#34;color:#19177c&#34;$strLog/span&#xA;        }&#xA;        { span style=&#34;color:#19177c&#34;$/span -in &#39;SystemAccountPw&#39;, &#39;SmtpPw&#39; } {&#xA;            span style=&#34;color:#19177c&#34;$strKeyValueRead/span = span style=&#34;color:#4070a0&#34;&#34;(confidential)&#34;/span&#xA;            span style=&#34;color:#19177c&#34;$strKeyValueWritten/span = span style=&#34;color:#4070a0&#34;&#34;(confidential)&#34;/span&#xA;        }&#xA;    }&#xA;    span style=&#34;color:#06287e&#34;Add-Content/span -Value (span style=&#34;color:#4070a0&#34;&#34;web.config: Setting &#39;$strSection.$strKeyName&#39;: read &#39;$strKeyValueRead&#39;, written &#39;$strKeyValueWritten&#39; &#34;/span + (span style=&#34;color:#06287e&#34;Get-Date/span -format span style=&#34;color:#4070a0&#34;&#34;yyyyMMddHHmm&#34;/span)) -PassThru -Path span style=&#34;color:#19177c&#34;$strLog/span&#xA;} span style=&#34;color:#60a0b0; font-style:italic&#34;# function CopyWebConfigAttrValue/span&#xA;&#xA;span style=&#34;color:#007020; font-weight:bold&#34;function/span SetWebConfigAttrValue(span style=&#34;color:#19177c&#34;$root/span, span style=&#34;color:#19177c&#34;$strSection/span, span style=&#34;color:#19177c&#34;$strKeyName/span, span style=&#34;color:#19177c&#34;$strKeyValue/span, span style=&#34;color:#19177c&#34;$strLog/span)&#xA;{&#xA;    span style=&#34;color:#19177c&#34;$strKeyValueRead/span = span style=&#34;color:#19177c&#34;$root/span.span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;//$strSection&#34;/span).span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;add[@key=&#39;$strKeyName&#39;]/@value&#34;/span).&#39;span style=&#34;color:#60a0b0; font-style:italic&#34;#text&#39;/span&#xA;    span style=&#34;color:#007020; font-weight:bold&#34;if/span ( span style=&#34;color:#19177c&#34;$strKeyValueRead/span -in (span style=&#34;color:#19177c&#34;$null/span, span style=&#34;color:#4070a0&#34;&#34;&#34;/span) )&#xA;    {&#xA;        span style=&#34;color:#19177c&#34;$newItem/span = span style=&#34;color:#19177c&#34;$root/span.span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;//$strSection&#34;/span).span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;add[1]&#34;/span).span style=&#34;color:#06287e&#34;Clone/span()&#xA;        span style=&#34;color:#19177c&#34;$newItem/span.span style=&#34;color:#06287e&#34;SetAttribute/span(span style=&#34;color:#4070a0&#34;&#34;key&#34;/span,span style=&#34;color:#19177c&#34;$strKeyName/span)&#xA;        span style=&#34;color:#19177c&#34;$newItem/span.span style=&#34;color:#06287e&#34;SetAttribute/span(span style=&#34;color:#4070a0&#34;&#34;value&#34;/span,span style=&#34;color:#19177c&#34;$strKeyValue/span)&#xA;        span style=&#34;color:#19177c&#34;$rootNew/span.span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;//$strSection&#34;/span).span style=&#34;color:#06287e&#34;AppendChild/span(span style=&#34;color:#19177c&#34;$newItem/span)&#xA;        [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strMsg/span = span style=&#34;color:#4070a0&#34;&#34;web.config: Setting &#39;$strSection.$strKeyName&#39; did not exist in webref.config (you should maintain webref.config) and has been automatically created by this script in target web.config, value has been set to &#39;$strKeyValueRead&#39;, from former version&#39;s web.config. &#34;/span + (span style=&#34;color:#06287e&#34;Get-Date/span -format span style=&#34;color:#4070a0&#34;&#34;yyyyMMddHHmm&#34;/span)&#xA;        span style=&#34;color:#06287e&#34;Add-Type/span -AssemblyName PresentationFramework&#xA;        [System.span style=&#34;color:#06287e&#34;Windows/span.span style=&#34;color:#06287e&#34;MessageBox/span]::Show(span style=&#34;color:#19177c&#34;$strMsg/span,&#39;&amp;lt;Program&amp;gt; Updater: New Setting&#39;,&#39;OK&#39;,&#39;Error&#39;)&#xA;        span style=&#34;color:#06287e&#34;Add-Content/span -Value span style=&#34;color:#19177c&#34;$strMsg/span -PassThru -Path span style=&#34;color:#19177c&#34;$strLog/span&#xA;    }&#xA;    span style=&#34;color:#007020; font-weight:bold&#34;else/span&#xA;    {&#xA;        span style=&#34;color:#19177c&#34;$root/span.span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;//$strSection&#34;/span).span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;add[@key=&#39;$strKeyName&#39;]/@value&#34;/span).&#39;span style=&#34;color:#60a0b0; font-style:italic&#34;#text&#39; = $strKeyValue/span&#xA;    }&#xA;    &#xA;    [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strKeyValueWritten/span = span style=&#34;color:#19177c&#34;$root/span.span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;//$strSection&#34;/span).span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;add[@key=&#39;$strKeyName&#39;]/@value&#34;/span).&#39;span style=&#34;color:#60a0b0; font-style:italic&#34;#text&#39;/span&#xA;    span style=&#34;color:#007020; font-weight:bold&#34;switch/span (span style=&#34;color:#19177c&#34;$strKeyName/span)&#xA;    {&#xA;        &#39;DbVerbindungString&#39; {&#xA;            span style=&#34;color:#06287e&#34;Add-Content/span -Value (span style=&#34;color:#19177c&#34;$strKeyName/span + span style=&#34;color:#4070a0&#34;&#34;: &#34;/span + span style=&#34;color:#19177c&#34;$strKeyValueWritten/span + (span style=&#34;color:#06287e&#34;Get-Date/span -format span style=&#34;color:#4070a0&#34;&#34;yyyyMMddHHmm&#34;/span)) -PassThru -Path span style=&#34;color:#19177c&#34;$strLog/span&#xA;        }&#xA;        { span style=&#34;color:#19177c&#34;$/span -in &#39;SystemAccountPw&#39;, &#39;SmtpPw&#39; } {&#xA;            span style=&#34;color:#19177c&#34;$strKeyValueRead/span = span style=&#34;color:#4070a0&#34;&#34;(confidential)&#34;/span&#xA;            span style=&#34;color:#19177c&#34;$strKeyValueWritten/span = span style=&#34;color:#4070a0&#34;&#34;(confidential)&#34;/span&#xA;        }&#xA;    }&#xA;    span style=&#34;color:#06287e&#34;Add-Content/span -Value (span style=&#34;color:#4070a0&#34;&#34;web.config: Setting &#39;$strSection.$strKeyName&#39; was set to &#39;$strKeyValueWritten&#39; &#34;/span + (span style=&#34;color:#06287e&#34;Get-Date/span -format span style=&#34;color:#4070a0&#34;&#34;yyyyMMddHHmm&#34;/span)) -PassThru -Path span style=&#34;color:#19177c&#34;$strLog/span&#xA;} span style=&#34;color:#60a0b0; font-style:italic&#34;# function SetWebConfigAttrValue/span&#xA;&#xA;span style=&#34;color:#60a0b0; font-style:italic&#34;# copy authorization keys - http://michlstechblog.info/blog/powershell-some-basic-xml-handling-with-powershell-and-net//span&#xA;span style=&#34;color:#007020; font-weight:bold&#34;function/span CopyWebConfigAuthorizationNode(span style=&#34;color:#19177c&#34;$rootNew/span, span style=&#34;color:#19177c&#34;$rootOld/span, span style=&#34;color:#19177c&#34;$xmlConfigNew/span, span style=&#34;color:#19177c&#34;$strLog/span)&#xA;{&#xA;&#xA;    span style=&#34;color:#19177c&#34;$rootNew/span.&#39;system.span style=&#34;color:#06287e&#34;web/span&#39;.span style=&#34;color:#06287e&#34;RemoveChild/span(span style=&#34;color:#19177c&#34;$rootNew/span.&#39;system.span style=&#34;color:#06287e&#34;web/span&#39;.span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;authorization&#34;/span)) | span style=&#34;color:#06287e&#34;Out-Null/span&#xA;    span style=&#34;color:#19177c&#34;$newNode/span = span style=&#34;color:#19177c&#34;$xmlConfigNew/span.span style=&#34;color:#06287e&#34;ImportNode/span(span style=&#34;color:#19177c&#34;$rootOld/span.&#39;system.span style=&#34;color:#06287e&#34;web/span&#39;.span style=&#34;color:#06287e&#34;SelectSingleNode/span(span style=&#34;color:#4070a0&#34;&#34;authorization&#34;/span), span style=&#34;color:#19177c&#34;$true/span)&#xA;    span style=&#34;color:#19177c&#34;$rootNew/span.&#39;system.span style=&#34;color:#06287e&#34;web/span&#39;.span style=&#34;color:#06287e&#34;AppendChild/span(span style=&#34;color:#19177c&#34;$newNode/span) | span style=&#34;color:#06287e&#34;Out-Null/span&#xA;    span style=&#34;color:#06287e&#34;Add-Content/span -Value (span style=&#34;color:#4070a0&#34;&#34;web.config: Copied &#39;authorization&#39; section. &#34;/span + (span style=&#34;color:#06287e&#34;Get-Date/span -format span style=&#34;color:#4070a0&#34;&#34;yyyyMMddHHmm&#34;/span)) -PassThru -Path span style=&#34;color:#19177c&#34;$strLog/span&#xA;&#xA;}&#xA;&#xA;span style=&#34;color:#007020; font-weight:bold&#34;function/span AdaptWebConfig([span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strNewVerFolder/span, [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strOldVerFolder/span, [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strNewVersion/span, [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strLog/span, span style=&#34;color:#19177c&#34;$hshSettings/span)&#xA;{&#xA;    &#xA;    span style=&#34;color:#06287e&#34;Rename-Item/span (span style=&#34;color:#19177c&#34;$strNewVerFolder/span + span style=&#34;color:#4070a0&#34;&#34;webref.config&#34;/span) span style=&#34;color:#4070a0&#34;&#34;web.config&#34;/span&#xA;    [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strOldVerConfig/span = span style=&#34;color:#19177c&#34;$strOldVerFolder/span + span style=&#34;color:#4070a0&#34;&#34;web.config&#34;/span&#xA;    [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strNewVerConfig/span = span style=&#34;color:#19177c&#34;$strNewVerFolder/span + span style=&#34;color:#4070a0&#34;&#34;web.config&#34;/span&#xA;&#xA;    span style=&#34;color:#06287e&#34;Add-Content/span -Value (span style=&#34;color:#4070a0&#34;&#34;Old web.config: &#34;/span + span style=&#34;color:#19177c&#34;$strOldVerConfig/span) -Path span style=&#34;color:#19177c&#34;$strLog/span -PassThru&#xA;    span style=&#34;color:#06287e&#34;Add-Content/span -Value (span style=&#34;color:#4070a0&#34;&#34;New web.config: &#34;/span + span style=&#34;color:#19177c&#34;$strNewVerConfig/span) -Path span style=&#34;color:#19177c&#34;$strLog/span -PassThru&#xA;&#xA;    span style=&#34;color:#4070a0&#34;&#34;Adapting $strNewVerConfig&#34;/span&#xA;&#xA;    [xml]span style=&#34;color:#19177c&#34;$xmlConfigOld/span = span style=&#34;color:#06287e&#34;Get-Content/span span style=&#34;color:#19177c&#34;$strOldVerConfig/span&#xA;    [xml]span style=&#34;color:#19177c&#34;$xmlConfigNew/span = span style=&#34;color:#06287e&#34;Get-Content/span span style=&#34;color:#19177c&#34;$strNewVerConfig/span&#xA;    span style=&#34;color:#19177c&#34;$rootOld/span = span style=&#34;color:#19177c&#34;$xmlConfigOld/span.span style=&#34;color:#06287e&#34;getDocumentElement/span()&#xA;    span style=&#34;color:#19177c&#34;$rootNew/span = span style=&#34;color:#19177c&#34;$xmlConfigNew/span.span style=&#34;color:#06287e&#34;getDocumentElement/span()&#xA;&#xA;    [span style=&#34;color:#902000&#34;int/span]span style=&#34;color:#19177c&#34;$intProgMainVersion/span = (span style=&#34;color:#19177c&#34;$strNewVersion/span.span style=&#34;color:#06287e&#34;Split/span(span style=&#34;color:#4070a0&#34;&#34;.&#34;/span))[0]&#xA;    &#xA;    span style=&#34;color:#007020; font-weight:bold&#34;switch/span (span style=&#34;color:#19177c&#34;$intProgMainVersion/span)&#xA;    {&#xA;    2 {&#xA;        span style=&#34;color:#60a0b0; font-style:italic&#34;# NotebookVersion/span&#xA;        SetWebConfigAttrValue span style=&#34;color:#19177c&#34;$rootNew/span span style=&#34;color:#4070a0&#34;&#34;appSettingsNotebook&#34;/span span style=&#34;color:#4070a0&#34;&#34;NotebookVersion&#34;/span span style=&#34;color:#19177c&#34;$strNewVersion/span span style=&#34;color:#19177c&#34;$strLog/span&#xA;&#xA;        span style=&#34;color:#60a0b0; font-style:italic&#34;# &amp;lt;authorization&amp;gt;/span&#xA;        CopyWebConfigAuthorizationNode span style=&#34;color:#19177c&#34;$rootNew/span span style=&#34;color:#19177c&#34;$rootOld/span span style=&#34;color:#19177c&#34;$xmlConfigNew/span span style=&#34;color:#19177c&#34;$strLog/span &#xA;&#xA;        span style=&#34;color:#60a0b0; font-style:italic&#34;# appSettings/span&#xA;        span style=&#34;color:#007020; font-weight:bold&#34;foreach/span (span style=&#34;color:#19177c&#34;$key/span span style=&#34;color:#007020; font-weight:bold&#34;in/span span style=&#34;color:#19177c&#34;$hshSettings/span[span style=&#34;color:#4070a0&#34;&#34;web.config v2 appSettings&#34;/span].span style=&#34;color:#06287e&#34;Keys/span)&#xA;        {&#xA;            CopyWebConfigAttrValue span style=&#34;color:#19177c&#34;$rootNew/span span style=&#34;color:#19177c&#34;$rootOld/span span style=&#34;color:#4070a0&#34;&#34;appSettings&#34;/span span style=&#34;color:#19177c&#34;$hshSettings/spanspan style=&#34;color:#4070a0&#34;&#34;web.config v2 appSettings&#34;/span span style=&#34;color:#19177c&#34;$strLog/span&#xA;        }&#xA;&#xA;        span style=&#34;color:#60a0b0; font-style:italic&#34;# appSettingsNotebook/span&#xA;        span style=&#34;color:#007020; font-weight:bold&#34;foreach/span (span style=&#34;color:#19177c&#34;$key/span span style=&#34;color:#007020; font-weight:bold&#34;in/span span style=&#34;color:#19177c&#34;$hshSettings/span[span style=&#34;color:#4070a0&#34;&#34;web.config v2 appSettingsNotebook&#34;/span].span style=&#34;color:#06287e&#34;Keys/span)&#xA;        {&#xA;            CopyWebConfigAttrValue span style=&#34;color:#19177c&#34;$rootNew/span span style=&#34;color:#19177c&#34;$rootOld/span span style=&#34;color:#4070a0&#34;&#34;appSettingsNotebook&#34;/span span style=&#34;color:#19177c&#34;$hshSettings/spanspan style=&#34;color:#4070a0&#34;&#34;web.config v2 appSettingsNotebook&#34;/span span style=&#34;color:#19177c&#34;$strLog/span&#xA;        }&#xA;&#xA;      } span style=&#34;color:#60a0b0; font-style:italic&#34;# switch 2/span&#xA;    &#xA;    3 {&#xA;        span style=&#34;color:#60a0b0; font-style:italic&#34;# appSettings/span&#xA;        span style=&#34;color:#007020; font-weight:bold&#34;foreach/span (span style=&#34;color:#19177c&#34;$key/span span style=&#34;color:#007020; font-weight:bold&#34;in/span span style=&#34;color:#19177c&#34;$hshSettings/span[span style=&#34;color:#4070a0&#34;&#34;web.config v3 appSettings&#34;/span].span style=&#34;color:#06287e&#34;Keys/span)&#xA;        {&#xA;            CopyWebConfigAttrValue span style=&#34;color:#19177c&#34;$rootNew/span span style=&#34;color:#19177c&#34;$rootOld/span span style=&#34;color:#4070a0&#34;&#34;appSettings&#34;/span span style=&#34;color:#19177c&#34;$hshSettings/spanspan style=&#34;color:#4070a0&#34;&#34;web.config v3 appSettings&#34;/span span style=&#34;color:#19177c&#34;$strLog/span&#xA;        }        &#xA;&#xA;        span style=&#34;color:#60a0b0; font-style:italic&#34;# appSettingsNotebook/span&#xA;        span style=&#34;color:#007020; font-weight:bold&#34;foreach/span (span style=&#34;color:#19177c&#34;$key/span span style=&#34;color:#007020; font-weight:bold&#34;in/span span style=&#34;color:#19177c&#34;$hshSettings/span[span style=&#34;color:#4070a0&#34;&#34;web.config v3 appSettingsNotebook&#34;/span].span style=&#34;color:#06287e&#34;Keys/span)&#xA;        {&#xA;            CopyWebConfigAttrValue span style=&#34;color:#19177c&#34;$rootNew/span span style=&#34;color:#19177c&#34;$rootOld/span span style=&#34;color:#4070a0&#34;&#34;appSettingsNotebook&#34;/span span style=&#34;color:#19177c&#34;$hshSettings/spanspan style=&#34;color:#4070a0&#34;&#34;web.config v3 appSettingsNotebook&#34;/span span style=&#34;color:#19177c&#34;$strLog/span&#xA;        }&#xA;&#xA;      } span style=&#34;color:#60a0b0; font-style:italic&#34;# switch 3/span&#xA;    } span style=&#34;color:#60a0b0; font-style:italic&#34;# switch/span&#xA;&#xA;    span style=&#34;color:#19177c&#34;$xmlConfigNew/span.span style=&#34;color:#06287e&#34;Save/span(span style=&#34;color:#19177c&#34;$strNewVerConfig/span) | span style=&#34;color:#06287e&#34;Out-Null/span&#xA;&#xA;    [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strNewVerConfigBak/span = span style=&#34;color:#19177c&#34;$strNewVerFolder/span + span style=&#34;color:#4070a0&#34;&#34;BakCfg\&#34;/span&#xA;    span style=&#34;color:#007020; font-weight:bold&#34;if/span ((span style=&#34;color:#06287e&#34;Test-Path/span span style=&#34;color:#19177c&#34;$strNewVerConfigBak/span) -eq span style=&#34;color:#19177c&#34;$false/span)&#xA;        { span style=&#34;color:#06287e&#34;New-Item/span -Path (span style=&#34;color:#06287e&#34;Split-Path/span -Path span style=&#34;color:#19177c&#34;$strNewVerConfigBak/span -Parent) -Name (span style=&#34;color:#06287e&#34;Split-Path/span -Path span style=&#34;color:#19177c&#34;$strNewVerConfigBak/span -Leaf) -ItemType directory | span style=&#34;color:#06287e&#34;Out-Null/span }&#xA;    span style=&#34;color:#19177c&#34;$strNewVerConfigBak/span += (span style=&#34;color:#4070a0&#34;&#34;web.config.&#34;/span + (span style=&#34;color:#06287e&#34;Get-Date/span -format span style=&#34;color:#4070a0&#34;&#34;yyyyMMdd.HHmm&#34;/span) + span style=&#34;color:#4070a0&#34;&#34;h&#34;/span)&#xA;    span style=&#34;color:#06287e&#34;Copy-Item/span span style=&#34;color:#19177c&#34;$strNewVerConfig/span span style=&#34;color:#19177c&#34;$strNewVerConfigBak/span&#xA;&#xA;} span style=&#34;color:#60a0b0; font-style:italic&#34;# function AdaptWebConfig/span&#xA;&#xA;span style=&#34;color:#007020; font-weight:bold&#34;function/span MailResult (span style=&#34;color:#19177c&#34;$strLogFolder/span, span style=&#34;color:#19177c&#34;$hshSettings/span)&#xA;{&#xA;    [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$ThisScriptCopy/span = span style=&#34;color:#19177c&#34;$PSCommandPath/span + span style=&#34;color:#4070a0&#34;&#34;.txt&#34;/span &#xA;    span style=&#34;color:#06287e&#34;Copy-Item/span span style=&#34;color:#19177c&#34;$PSCommandPath/span span style=&#34;color:#19177c&#34;$ThisScriptCopy/span -Force&#xA;    span style=&#34;color:#19177c&#34;$dirLogs/span = span style=&#34;color:#06287e&#34;Get-ChildItem/span (span style=&#34;color:#19177c&#34;$strLogFolder/span + span style=&#34;color:#4070a0&#34;&#34;&#34;/span)&#xA;    &#xA;    [span style=&#34;color:#902000&#34;string/span[]]span style=&#34;color:#19177c&#34;$astrAttachments/span = @()&#xA;    span style=&#34;color:#19177c&#34;$astrAttachments/span += span style=&#34;color:#19177c&#34;$ThisScriptCopy/span&#xA;    span style=&#34;color:#007020; font-weight:bold&#34;foreach/span (span style=&#34;color:#19177c&#34;$strLogFile/span span style=&#34;color:#007020; font-weight:bold&#34;in/span span style=&#34;color:#19177c&#34;$dirLogs/span)&#xA;    {&#xA;        span style=&#34;color:#19177c&#34;$astrAttachments/span += span style=&#34;color:#19177c&#34;$strLogFile/span.span style=&#34;color:#06287e&#34;FullName/span&#xA;    }&#xA;&#xA;    [span style=&#34;color:#902000&#34;string/span]span style=&#34;color:#19177c&#34;$strBody/span = span style=&#34;color:#4070a0&#34;&#34;ProgramUpdater was started by &#34;/span + span style=&#34;color:#19177c&#34;$env/span:USERDOMAIN + span style=&#34;color:#4070a0&#34;&#34;\&#34;/span + span style=&#34;color:#19177c&#34;$env/span:USERNAME &#xA;    span style=&#34;color:#19177c&#34;$strBody/span += span style=&#34;color:#4070a0&#34;&#34; on &#34;/span + [System.span style=&#34;color:#06287e&#34;Net/span.span style=&#34;color:#06287e&#34;Dns/span]::GetHostByName((hostname)).span style=&#34;color:#06287e&#34;HostName/span&#xA;&#xA;    span style=&#34;color:#007020; font-weight:bold&#34;foreach/span (span style=&#34;color:#19177c&#34;$strAttachment/span span style=&#34;color:#007020; font-weight:bold&#34;in/span span style=&#34;color:#19177c&#34;$astrAttachments/span)&#xA;    {&#xA;        span style=&#34;color:#19177c&#34;$strBody/span += span style=&#34;color:#4070a0&#34;&#34;nn ====================&#34;/span&#xA;        span style=&#34;color:#19177c&#34;$strBody/span += span style=&#34;color:#4070a0&#34;&#34;nn &#34;/span + span style=&#34;color:#19177c&#34;$strAttachment/span&#xA;        span style=&#34;color:#19177c&#34;$strBody/span += span style=&#34;color:#06287e&#34;Get-Content/span span style=&#34;color:#19177c&#34;$strAttachment/span&#xA;    }&#xA; &#xA;    [span style=&#34;color:#902000&#34;string/span[]]span style=&#34;color:#19177c&#34;$astrMailRecipients/span = @()&#xA;    span style=&#34;color:#007020; font-weight:bold&#34;foreach/span (span style=&#34;color:#19177c&#34;$key/span span style=&#34;color:#007020; font-weight:bold&#34;in/span span style=&#34;color:#19177c&#34;$hshSettings/span[span style=&#34;color:#4070a0&#34;&#34;Result mail&#34;/span].span style=&#34;color:#06287e&#34;Keys/span)&#xA;    {&#xA;        span style=&#34;color:#007020; font-weight:bold&#34;if/span (span style=&#34;color:#19177c&#34;$key/span -like span style=&#34;color:#4070a0&#34;&#34;To*&#34;/span)&#xA;            { span style=&#34;color:#19177c&#34;$astrMailRecipients/span += span style=&#34;color:#19177c&#34;$hshSettings/spanspan style=&#34;color:#4070a0&#34;&#34;Result mail&#34;/span }&#xA;    }&#xA;    &#xA;    span style=&#34;color:#007020; font-weight:bold&#34;if/span (span style=&#34;color:#19177c&#34;$hshSettings/spanspan style=&#34;color:#4070a0&#34;&#34;Result mail&#34;/span -eq span style=&#34;color:#4070a0&#34;&#34;1&#34;/span)&#xA;    {&#xA;        span style=&#34;color:#06287e&#34;Send-MailMessage/span -To span style=&#34;color:#19177c&#34;$astrMailRecipients/span `&#xA;            -From span style=&#34;color:#19177c&#34;$hshSettings/spanspan style=&#34;color:#4070a0&#34;&#34;Result mail&#34;/span `&#xA;            -Subject span style=&#34;color:#4070a0&#34;&#34;ProgramUpdater&#34;/span `&#xA;            -Body span style=&#34;color:#19177c&#34;$strBody/span `&#xA;            -SmtpServer span style=&#34;color:#19177c&#34;$hshSettings/spanspan style=&#34;color:#4070a0&#34;&#34;Result mail&#34;/span `&#xA;            -Attachments span style=&#34;color:#19177c&#34;$astrAttachments/span `&#xA;            -ErrorAction SilentlyContinue&#xA;    }&#xA;    &#xA;    span style=&#34;color:#007020; font-weight:bold&#34;if/span (span style=&#34;color:#19177c&#34;$hshSettings/spanspan style=&#34;color:#4070a0&#34;&#34;Result mail WS&#34;/span -eq span style=&#34;color:#4070a0&#34;&#34;1&#34;/span)&#xA;    {&#xA;        span style=&#34;color:#19177c&#34;$pw/span = span style=&#34;color:#06287e&#34;ConvertTo-SecureString/span -String span style=&#34;color:#19177c&#34;$hshSettings/spanspan style=&#34;color:#4070a0&#34;&#34;Result mail WS&#34;/span -AsPlainText -Force&#xA;        span style=&#34;color:#19177c&#34;$creds/span = span style=&#34;color:#06287e&#34;New-Object/span System.span style=&#34;color:#06287e&#34;Management/span.span style=&#34;color:#06287e&#34;Automation/span.span style=&#34;color:#06287e&#34;PSCredential/span span style=&#34;color:#19177c&#34;$hshSettings/spanspan style=&#34;color:#4070a0&#34;&#34;Result mail WS&#34;/span, span style=&#34;color:#19177c&#34;$pw/span&#xA;        span style=&#34;color:#19177c&#34;$wsSmtp/span = span style=&#34;color:#06287e&#34;New-WebServiceProxy/span span style=&#34;color:#19177c&#34;$hshSettings/spanspan style=&#34;color:#4070a0&#34;&#34;Result mail WS&#34;/span -Credential span style=&#34;color:#19177c&#34;$creds/span&#xA;        span style=&#34;color:#007020; font-weight:bold&#34;foreach/span (span style=&#34;color:#19177c&#34;$Addr/span span style=&#34;color:#007020; font-weight:bold&#34;in/span span style=&#34;color:#19177c&#34;$astrMailRecipients/span)&#xA;        {&#xA;            span style=&#34;color:#19177c&#34;$wsSmtp/span.span style=&#34;color:#06287e&#34;SendeEmailMitStandardAbsender/span(span style=&#34;color:#19177c&#34;$Addr/span,span style=&#34;color:#4070a0&#34;&#34;&#34;/span,span style=&#34;color:#4070a0&#34;&#34;&#34;/span,span style=&#34;color:#4070a0&#34;&#34;ProgramUpdater&#34;/span,span style=&#34;color:#19177c&#34;$strBody/span)&#xA;        }&#xA;    }&#xA;} span style=&#34;color:#60a0b0; font-style:italic&#34;# function MailResult/span&#xA;&#xA;span style=&#34;color:#007020; font-weight:bold&#34;Function/span BackslashTrailToFolder (span style=&#34;color:#19177c&#34;$strFolder/span)&#xA;{&#xA;    span style=&#34;color:#007020; font-weight:bold&#34;if/span ( (span style=&#34;color:#19177c&#34;$strFolder/span.span style=&#34;color:#06287e&#34;Substring/span(span style=&#34;color:#19177c&#34;$strFolder/span.span style=&#34;color:#06287e&#34;Length/span - 1)) -ne span style=&#34;color:#4070a0&#34;&#34;\&#34;/span )&#xA;    {&#xA;        span style=&#34;color:#19177c&#34;$strFolder/span += span style=&#34;color:#4070a0&#34;&#34;\&#34;/span&#xA;        span style=&#34;color:#007020; font-weight:bold&#34;return/span span style=&#34;color:#19177c&#34;$strFolder/span&#xA;    }&#xA;}&#xA;&#xA;span style=&#34;color:#007020; font-weight:bold&#34;Function/span FolderNameWoTrailingBackslash (span style=&#34;color:#19177c&#34;$strFolder/span)&#xA;{&#xA;    span style=&#34;color:#007020; font-weight:bold&#34;if/span ( (span style=&#34;color:#19177c&#34;$strFolder/span.span style=&#34;color:#06287e&#34;Substring/span(span style=&#34;color:#19177c&#34;$strFolder/span.span style=&#34;color:#06287e&#34;Length/span - 1)) -eq span style=&#34;color:#4070a0&#34;&#34;\&#34;/span )&#xA;    {&#xA;        span style=&#34;color:#19177c&#34;$strFolder/span = span style=&#34;color:#19177c&#34;$strFolder/span.span style=&#34;color:#06287e&#34;Substring/span(0, span style=&#34;color:#19177c&#34;$strFolder/span.span style=&#34;color:#06287e&#34;Length/span - 1)&#xA;        span style=&#34;color:#007020; font-weight:bold&#34;return/span span style=&#34;color:#19177c&#34;$strFolder/span&#xA;    }&#xA;}]]&gt;</description>
      <content:encoded><![CDATA[<p>Automates upgrading a .NET and ASP.NET web application on IIS with MSSQL backend and .NET client installers. Chooses correct deployment packages, starts data model upgrade, builds a new web.config with the new settings from deployment packages and by selectively copying the installation specific, client side settings from the old files by attrib name.</p>

<p><span style="color:#60a0b0; font-style:italic"><a href="/cruisinit/tag:Requires" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Requires</span></a> -Version 4</span>
<span style="color:#60a0b0; font-style:italic"><a href="/cruisinit/tag:Requires" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Requires</span></a> -RunAsAdmin</span></p>

<p><span style="color:#60a0b0; font-style:italic"># Todo: $strNewVersion, zunaechst aus .msi-Props ausgelesen, aus dann entpackter Anwendung -&gt; bin\ -&gt; .dll neu auslesen, falls nicht zueinander passende Deploymentpakete .zip und .msi zusammenkopiert wurden [string]$strNewVersion = ((Get-ItemProperty ($strNewVerFolder + “bin&amp;lt;filename&gt;.dll”)).VersionInfo).ProductVersion fuehrt aktuell zu Mosern ueber mangelnde Zugriffsrechte</span>
<span style="color:#60a0b0; font-style:italic"># Todo: Optische Aufbereitung des Mailbodys oder Attachments ueber CC-Webservice</span></p>

<p><span style="color:#60a0b0; font-style:italic">&lt;#</span>
<span style="color:#60a0b0; font-style:italic">.SYNOPSIS</span>
<span style="color:#60a0b0; font-style:italic">    Update &lt;Program&gt; Standard. Automates upgrading a .NET and ASP.NET web application on IIS with MSSQL backend and .NET client installers. Chooses correct deployment packages, starts data model upgrade, builds a new web.config with the new settings from deployment packages and by selectively copying the installation specific, client side settings from the old files by attrib name.</span>
<span style="color:#60a0b0; font-style:italic">.DESCRIPTION</span>
<span style="color:#60a0b0; font-style:italic">    Update &lt;Program&gt; Standard</span>
<span style="color:#60a0b0; font-style:italic">    Syntax: [D:\Websites\Deploy\UpdaterScript]ProgramUpdaterAsAdmin.lnk (with a script file path in the command line saying D:\Websites\Deploy\UpdaterScript\ProgramUpdater.ps1. The default paths (see below) to both .INIs will usually work. If you need to supply an absolute path to one or boths .INIs, edit ProgramUpdaterAsAdmin.lnk&#39;s command line along this syntax note: D:\Websites\Deploy\UpdaterScript\ProgramUpdater.ps1 [[-IniFileUser] &lt;String&gt;] [[-IniFileWebConfig] &lt;String&gt;] [&lt;CommonParameters&gt;] )</span>
<span style="color:#60a0b0; font-style:italic">    Use this internal helper at your own risk. Addressed audience are informed IT workers. The author cannot be held liable for loss of data by the use of this script.</span>
<span style="color:#60a0b0; font-style:italic">    * This script requires PowerShell version 4 (in WMF, but if you need update anyway, install WMF 5, <a href="https://www.microsoft.com/en-us/download/confirmation.aspx?id=54616&amp;6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1" rel="nofollow">https://www.microsoft.com/en-us/download/confirmation.aspx?id=54616&amp;6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1</a>).</span>
<span style="color:#60a0b0; font-style:italic">    * This script requires to be run as admin.</span>
<span style="color:#60a0b0; font-style:italic">    * You may supply absolute paths inc. file name to the two .ini files as the only parameter. Use “ ” if path contains blanks.</span>
<span style="color:#60a0b0; font-style:italic">    * Run without parameter, this script searches its .ini at D:\Websites\Deploy\UpdaterScript\ProgramUpdaterSettings<em>user.ini plus D:\Websites\Deploy\UpdaterScript\ProgramUpdaterSettings</em>web.config.ini. (In fact, this script retrieves its own full path and</span>
<span style="color:#60a0b0; font-style:italic">        replaces “.ps1” with “Settings<em>user.ini” / “Settings</em>web.config.ini”, and this will regularly lead to the paths mentioned above.)</span>
<span style="color:#60a0b0; font-style:italic">    * Your website folder path in Settings<em>user.ini must start with “D:\Websites\“. If it does not, the script adds this automatically.</span>
<span style="color:#60a0b0; font-style:italic">    * Your website folder path in Settings</em>user.ini must end with “\Company.Program.Gui\“. If it does not, the script adds this automatically.</span>
<span style="color:#60a0b0; font-style:italic">    * Deployment folder is always D:\websites\deploy. Copy your deployment packages (.ZIPs, .MSIs, UpgradeTool.exe) into this folder.</span>
<span style="color:#60a0b0; font-style:italic">    * The current default for the MS SQL version (part of deployment packages&#39; names) is 2008  (means: 2008 and 2008 R2). You can define other versions (allowed: 2012, 2014) by machine name in Settings<em>user.ini, and you can change the default in Settings</em>user.ini. When the script lists the detected parameters and paths and asks for your permission to go on, check the MS SQL version (check everything). If the version does not match the &lt;Program&gt; instance of SQL Server on the customer&#39;s machine, stop the script and edit Settings<em>user.ini before you start it again.</span>
<span style="color:#60a0b0; font-style:italic">    * To not overwrite user settings during deployment, this script is shipped with ProgramUpdaterSettings</em>user<em>master.ini used for dev tests. You can check this e.g. for version updates. You are warned if script and ini versions (inside) don&#39;t fit.</span>
<span style="color:#60a0b0; font-style:italic">    * The old version is detected from &lt;WebsiteFolder&gt;\bin&amp;lt;FirstDll&gt;.dll&#39;s file properties (&#39;Product version&#39;).</span>
<span style="color:#60a0b0; font-style:italic">    * The new version is detected from D:\websites\deploy&amp;lt;FirstMsi&gt;.msi&#39;s file properties (&#39;Tags&#39;).</span>
<span style="color:#60a0b0; font-style:italic">    * The backup folder is always &lt;WebsiteFolder&gt;</em>&lt;OldVersion&gt;<em>&lt;DateTime&gt;.</span>
<span style="color:#60a0b0; font-style:italic">    * The script log folder is always D:\websites\deploy\UpdateLogs&amp;lt;DateTime&gt;. You will find some explicitly logged results, powershell script errors,</span>
<span style="color:#60a0b0; font-style:italic">        and the UpgradeTool log in there.</span>
<span style="color:#60a0b0; font-style:italic">    * DevExpress deployment folder is always D:\websites\deploy\DevExpress&amp;lt;Version&gt;. Ensure the DevExpress runtime files are copied to this folder before.</span>
<span style="color:#60a0b0; font-style:italic">    * The script stops the IIS website for the duration of its run.</span>
<span style="color:#60a0b0; font-style:italic">.PARAMETER IniFileUser</span>
<span style="color:#60a0b0; font-style:italic">    Default: &lt;ThisScriptsPath&gt;&amp;lt;ThisScriptsNameWithoutExtension&gt;Settings</em>user.ini (almost always D:\Websites\Deploy\UpdaterScript\ProgramUpdaterSettings<em>user.ini).</span>
<span style="color:#60a0b0; font-style:italic">.PARAMETER IniFileWebConfig</span>
<span style="color:#60a0b0; font-style:italic">    Default: &lt;ThisScriptsPath&gt;&amp;lt;ThisScriptsNameWithoutExtension&gt;Settings</em>web.config.ini (almost always D:\Websites\Deploy\UpdaterScript\ProgramUpdaterSettings_web.config.ini).</span>
<span style="color:#60a0b0; font-style:italic">.EXAMPLE</span>
<span style="color:#60a0b0; font-style:italic">    PS C:\util&gt; .\ProgramUpdaterAsAdmin.lnk</span>
<span style="color:#60a0b0; font-style:italic">    # This script is shipped with ProgramUpdaterAsAdmin.lnk, you should prefer this. If you need to change the call e.g. to call another .ini, edit the .lnk.</span>
<span style="color:#60a0b0; font-style:italic">.NOTES</span>
<span style="color:#60a0b0; font-style:italic">    Author:  ps@&lt;mydomain&gt;.de</span>
<span style="color:#60a0b0; font-style:italic">    Date:    2 June 2016 to 24 Jan 2019</span>
<span style="color:#60a0b0; font-style:italic">    Todo:    $strNewVersion, zunaechst aus .msi-Props ausgelesen, aus dann entpacktem CC -&gt; bin\ -&gt; .dll neu auslesen, falls nicht zueinander passende Deploymentpakete .zip und .msi zusammenkopiert wurden [string]$strNewVersion = ((Get-ItemProperty ($strNewVerFolder + “bin\Company.Program.BusinessLogik.dll”)).VersionInfo).ProductVersion fuehrt aktuell zu Mosern ueber mangelnde Zugriffsrechte</span>
<span style="color:#60a0b0; font-style:italic">    Todo:    Optische Aufbereitung des Mailbodys oder Attachments ueber Webservice</span>
<span style="color:#60a0b0; font-style:italic">    </span>
<span style="color:#60a0b0; font-style:italic">    Version: 1.2.0.2  — check with TFS</span></p>

<p><span style="color:#60a0b0; font-style:italic">#&gt;</span></p>

<p><span style="color:#007020; font-weight:bold">param</span>
(
    [Parameter(Position=0)]
    <span style="color:#60a0b0; font-style:italic"># [string]$strWebsiteFolder = “D:\Websites\Company\Company.Program.Gui\”</span>
    [<span style="color:#902000">string</span>]<span style="color:#19177c">$IniFileUser</span> = <span style="color:#19177c">$PSCommandPath</span> -replace(<span style="color:#4070a0">”.ps1”</span>,<span style="color:#4070a0">“Settings<em>user.ini”</span>),
    [Parameter(Position=1)]
    <span style="color:#60a0b0; font-style:italic"># [string]$strWebsiteFolder = “D:\Websites\Company\Company.Program.Gui\”</span>
    [<span style="color:#902000">string</span>]<span style="color:#19177c">$IniFileWebConfig</span> = <span style="color:#19177c">$PSCommandPath</span> -replace(<span style="color:#4070a0">”.ps1”</span>,<span style="color:#4070a0">“Settings</em>web.config.ini”</span>)</p>

<p>)</p>

<p><span style="color:#007020; font-weight:bold">PROCESS</span>
{</p>

<p><span style="color:#19177c">$Error</span>.<span style="color:#06287e">Clear</span>()</p>

<p><span style="color:#007020; font-weight:bold">if</span> (<span style="color:#19177c">$IniFileUser</span> -in (<span style="color:#19177c">$null</span>, <span style="color:#4070a0">””</span>)) { [<span style="color:#902000">string</span>]<span style="color:#19177c">$IniFileUser</span> = <span style="color:#19177c">$PSCommandPath</span> -replace(<span style="color:#4070a0">”.ps1”</span>,<span style="color:#4070a0">“Settings<em>user.ini”</span>) }
<span style="color:#007020; font-weight:bold">if</span> (<span style="color:#19177c">$IniFileUserWebConfig</span> -in (<span style="color:#19177c">$null</span>, <span style="color:#4070a0">””</span>)) { [<span style="color:#902000">string</span>]<span style="color:#19177c">$IniFileWebConfig</span> = <span style="color:#19177c">$PSCommandPath</span> -replace(<span style="color:#4070a0">”.ps1”</span>,<span style="color:#4070a0">“Settings</em>web.config.ini”</span>) }</p>

<p>[<span style="color:#902000">string</span>]<span style="color:#19177c">$strWebConfigMsiContent</span> = <span style="color:#4070a0">@”</span>
<span style="color:#4070a0">&lt;?xml version=“1.0” encoding=“UTF-8”?&gt;</span>
<span style="color:#4070a0">&lt;configuration&gt;</span>
<span style="color:#4070a0">    &lt;system.webServer&gt;</span>
<span style="color:#4070a0">        &lt;directoryBrowse enabled=“true” showFlags=“Date, Time, Size, Extension, LongDate” /&gt;</span>
<span style="color:#4070a0">    &lt;/system.webServer&gt;</span>
<span style="color:#4070a0">&lt;/configuration&gt;</span>
<span style="color:#4070a0">”@</span></p>

<p>[<span style="color:#902000">string</span>]<span style="color:#19177c">$strIniVersion</span> = <span style="color:#4070a0">“1.5_20181019”</span></p>

<p><span style="color:#60a0b0; font-style:italic"># if ($psise -ne $null) { $strWebsiteFolder = “Company” } # Edit the $strWebsiteFolder part of this line to run this script in ISE.</span></p>

<p><span style="color:#06287e">Add-Type</span> -AssemblyName System.<span style="color:#06287e">Windows</span>.<span style="color:#06287e">Forms</span>
<span style="color:#06287e">Import-Module</span> WebAdministration</p>

<p><span style="color:#60a0b0; font-style:italic"><a href="/cruisinit/tag:region" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">region</span></a> Functions</span></p>

<p><span style="color:#007020; font-weight:bold">Function</span> Get-IniContent
{<br>
    <span style="color:#60a0b0; font-style:italic">&lt;#  </span>
<span style="color:#60a0b0; font-style:italic">    .Synopsis  </span>
<span style="color:#60a0b0; font-style:italic">        Gets the content of an INI file  </span>
<span style="color:#60a0b0; font-style:italic">          </span>
<span style="color:#60a0b0; font-style:italic">    .Description  </span>
<span style="color:#60a0b0; font-style:italic">        Gets the content of an INI file and returns it as a hashtable  </span>
<span style="color:#60a0b0; font-style:italic">          </span>
<span style="color:#60a0b0; font-style:italic">    .Notes  </span>
<span style="color:#60a0b0; font-style:italic">        Author        : Oliver Lipkau &lt;oliver@lipkau.net&gt;  </span>
<span style="color:#60a0b0; font-style:italic">        Blog        : <a href="http://oliver.lipkau.net/blog/" rel="nofollow">http://oliver.lipkau.net/blog/</a>  </span>
<span style="color:#60a0b0; font-style:italic">        Source        : <a href="https://github.com/lipkau/PsIni" rel="nofollow">https://github.com/lipkau/PsIni</a> </span>
<span style="color:#60a0b0; font-style:italic">                      <a href="http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91" rel="nofollow">http://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91</a> </span>
<span style="color:#60a0b0; font-style:italic">        Version        : 1.0 – 2010/03/12 – Initial release  </span>
<span style="color:#60a0b0; font-style:italic">                      1.1 – 2014/12/11 – Typo (Thx SLDR) </span>
<span style="color:#60a0b0; font-style:italic">                                         Typo (Thx Dave Stiff) </span>
<span style="color:#60a0b0; font-style:italic">          </span>
<span style="color:#60a0b0; font-style:italic">        <a href="/cruisinit/tag:Requires" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Requires</span></a> -Version 2.0  </span>
<span style="color:#60a0b0; font-style:italic">          </span>
<span style="color:#60a0b0; font-style:italic">    .Inputs  </span>
<span style="color:#60a0b0; font-style:italic">        System.String  </span>
<span style="color:#60a0b0; font-style:italic">          </span>
<span style="color:#60a0b0; font-style:italic">    .Outputs  </span>
<span style="color:#60a0b0; font-style:italic">        System.Collections.Hashtable  </span>
<span style="color:#60a0b0; font-style:italic">          </span>
<span style="color:#60a0b0; font-style:italic">    .Parameter FilePath  </span>
<span style="color:#60a0b0; font-style:italic">        Specifies the path to the input file.  </span>
<span style="color:#60a0b0; font-style:italic">          </span>
<span style="color:#60a0b0; font-style:italic">    .Example  </span>
<span style="color:#60a0b0; font-style:italic">        $FileContent = Get-IniContent “C:\myinifile.ini”  </span>
<span style="color:#60a0b0; font-style:italic">        —————–  </span>
<span style="color:#60a0b0; font-style:italic">        Description  </span>
<span style="color:#60a0b0; font-style:italic">        Saves the content of the c:\myinifile.ini in a hashtable called $FileContent  </span>
<span style="color:#60a0b0; font-style:italic">      </span>
<span style="color:#60a0b0; font-style:italic">    .Example  </span>
<span style="color:#60a0b0; font-style:italic">        $inifilepath | $FileContent = Get-IniContent  </span>
<span style="color:#60a0b0; font-style:italic">        —————–  </span>
<span style="color:#60a0b0; font-style:italic">        Description  </span>
<span style="color:#60a0b0; font-style:italic">        Gets the content of the ini file passed through the pipe into a hashtable called $FileContent  </span>
<span style="color:#60a0b0; font-style:italic">      </span>
<span style="color:#60a0b0; font-style:italic">    .Example  </span>
<span style="color:#60a0b0; font-style:italic">        C:\PS&gt;$FileContent = Get-IniContent “c:\settings.ini”  </span>
<span style="color:#60a0b0; font-style:italic">        C:\PS&gt;$FileContent[“Section”][“Key”]  </span>
<span style="color:#60a0b0; font-style:italic">        —————–  </span>
<span style="color:#60a0b0; font-style:italic">        Description  </span>
<span style="color:#60a0b0; font-style:italic">        Returns the key “Key” of the section “Section” from the C:\settings.ini file  </span>
<span style="color:#60a0b0; font-style:italic">          </span>
<span style="color:#60a0b0; font-style:italic">    .Link  </span>
<span style="color:#60a0b0; font-style:italic">        Out-IniFile  </span>
<span style="color:#60a0b0; font-style:italic">    #&gt;</span></p>

<p>    <span style="color:#007020; font-weight:bold">Param</span>(<br>
        [ValidateNotNullOrEmpty()]<br>
        [ValidateScript({(<span style="color:#06287e">Test-Path</span> <span style="color:#19177c">$<em></span>) -and ((<span style="color:#06287e">Get-Item</span> <span style="color:#19177c">$</em></span>).<span style="color:#06287e">Extension</span> -eq <span style="color:#4070a0">”.ini”</span>)})]<br>
        [Parameter(ValueFromPipeline=<span style="color:#19177c">$True</span>,Mandatory=<span style="color:#19177c">$True</span>)]<br>
        [<span style="color:#902000">string</span>]<span style="color:#19177c">$FilePath</span><br>
    )</p>

<p>    <span style="color:#06287e">Write-Verbose</span> <span style="color:#4070a0">”$($MyInvocation.MyCommand.Name):: Function started”</span></p>

<p>    <span style="color:#06287e">Write-Verbose</span> <span style="color:#4070a0">”$($MyInvocation.MyCommand.Name):: Processing file: $Filepath”</span></p>

<p>    <span style="color:#19177c">$ini</span> = @{}<br>
    <span style="color:#007020; font-weight:bold">switch</span> -regex -file <span style="color:#19177c">$FilePath</span><br>
    {<br>
        <span style="color:#4070a0">”^[(.+)]$”</span> <span style="color:#60a0b0; font-style:italic"># Section  </span>
        {<br>
            <span style="color:#19177c">$section</span> = <span style="color:#19177c">$matches</span>[1]<br>
            <span style="color:#19177c">$ini</span>[<span style="color:#19177c">$section</span>] = @{}<br>
            <span style="color:#19177c">$CommentCount</span> = 0<br>
        }<br>
        <span style="color:#4070a0">”^(;.<em>)$”</span> <span style="color:#60a0b0; font-style:italic"># Comment  </span>
        {<br>
            <span style="color:#007020; font-weight:bold">if</span> (!(<span style="color:#19177c">$section</span>))<br>
            {<br>
                <span style="color:#19177c">$section</span> = <span style="color:#4070a0">“No-Section”</span><br>
                <span style="color:#19177c">$ini</span>[<span style="color:#19177c">$section</span>] = @{}<br>
            }<br>
            <span style="color:#19177c">$value</span> = <span style="color:#19177c">$matches</span>[1]<br>
            <span style="color:#19177c">$CommentCount</span> = <span style="color:#19177c">$CommentCount</span> + 1<br>
            <span style="color:#19177c">$name</span> = <span style="color:#4070a0">“Comment”</span> + <span style="color:#19177c">$CommentCount</span><br>
            <span style="color:#19177c">$ini</span>[<span style="color:#19177c">$section</span>][<span style="color:#19177c">$name</span>] = <span style="color:#19177c">$value</span><br>
        }<br>
        <span style="color:#4070a0">”(.+?)\s</em>=\s<em>(.</em>)”</span> <span style="color:#60a0b0; font-style:italic"># Key  </span>
        {<br>
            <span style="color:#007020; font-weight:bold">if</span> (!(<span style="color:#19177c">$section</span>))<br>
            {<br>
                <span style="color:#19177c">$section</span> = <span style="color:#4070a0">“No-Section”</span><br>
                <span style="color:#19177c">$ini</span>[<span style="color:#19177c">$section</span>] = @{}<br>
            }<br>
            <span style="color:#19177c">$name</span>,<span style="color:#19177c">$value</span> = <span style="color:#19177c">$matches</span>[1..<span style="color:#06287e">2</span>]<br>
            <span style="color:#19177c">$ini</span>[<span style="color:#19177c">$section</span>][<span style="color:#19177c">$name</span>] = <span style="color:#19177c">$value</span><br>
        }<br>
    }</p>

<p>    <span style="color:#06287e">Write-Verbose</span> <span style="color:#4070a0">”$($MyInvocation.MyCommand.Name):: Finished Processing file: $FilePath”</span><br>
    <span style="color:#007020; font-weight:bold">Return</span> <span style="color:#19177c">$ini</span></p>

<p>    <span style="color:#06287e">Write-Verbose</span> <span style="color:#4070a0">”$($MyInvocation.MyCommand.Name):: Function ended”</span>
} <span style="color:#60a0b0; font-style:italic"># Function Get-IniContent</span></p>

<p><span style="color:#007020; font-weight:bold">function</span> CopyWebConfigAttrValue(<span style="color:#19177c">$rootNew</span>, <span style="color:#19177c">$rootOld</span>, <span style="color:#19177c">$strSection</span>, <span style="color:#19177c">$strKeyName</span>, <span style="color:#19177c">$strLog</span>)
{
    [<span style="color:#902000">string</span>]<span style="color:#19177c">$strKeyValueRead</span> = <span style="color:#19177c">$rootOld</span>.<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">”//$strSection”</span>).<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">“add[@key=&#39;$strKeyName&#39;]/@value”</span>).&#39;<span style="color:#60a0b0; font-style:italic"><a href="/cruisinit/tag:text" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">text</span></a>&#39;</span>
    [<span style="color:#902000">string</span>]<span style="color:#19177c">$strKeyValueReadNew</span> = <span style="color:#19177c">$rootNew</span>.<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">”//$strSection”</span>).<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">“add[@key=&#39;$strKeyName&#39;]/@value”</span>).&#39;<span style="color:#60a0b0; font-style:italic"><a href="/cruisinit/tag:text" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">text</span></a>&#39;</span>
    <span style="color:#007020; font-weight:bold">if</span> ( <span style="color:#19177c">$strKeyValueReadNew</span> -in (<span style="color:#19177c">$null</span>, <span style="color:#4070a0">””</span>) )
    {
        <span style="color:#19177c">$newItem</span> = <span style="color:#19177c">$rootNew</span>.<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">”//$strSection”</span>).<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">“add[1]”</span>).<span style="color:#06287e">Clone</span>()
        <span style="color:#19177c">$newItem</span>.<span style="color:#06287e">SetAttribute</span>(<span style="color:#4070a0">“key”</span>,<span style="color:#19177c">$strKeyName</span>)
        <span style="color:#19177c">$newItem</span>.<span style="color:#06287e">SetAttribute</span>(<span style="color:#4070a0">“value”</span>,<span style="color:#19177c">$strKeyValueRead</span>)
        <span style="color:#19177c">$rootNew</span>.<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">”//$strSection”</span>).<span style="color:#06287e">AppendChild</span>(<span style="color:#19177c">$newItem</span>)
        [<span style="color:#902000">string</span>]<span style="color:#19177c">$strMsg</span> = <span style="color:#4070a0">“web.config: Setting &#39;$strSection.$strKeyName&#39; did not exist in web<em>ref.config (you should maintain web</em>ref.config) and has been automatically created by this script in target web.config, value has been set to &#39;$strKeyValueRead&#39;, from former version&#39;s web.config. “</span> + (<span style="color:#06287e">Get-Date</span> -format <span style="color:#4070a0">“yyyyMMdd<em>HHmm”</span>)
        <span style="color:#06287e">Add-Type</span> -AssemblyName PresentationFramework
        [System.<span style="color:#06287e">Windows</span>.<span style="color:#06287e">MessageBox</span>]::Show(<span style="color:#19177c">$strMsg</span>,&#39;&lt;Program&gt; Updater: New Setting&#39;,&#39;OK&#39;,&#39;Error&#39;)
        <span style="color:#06287e">Add-Content</span> -Value <span style="color:#19177c">$strMsg</span> -PassThru -Path <span style="color:#19177c">$strLog</span>
    }
    <span style="color:#007020; font-weight:bold">else</span>
    {
        <span style="color:#19177c">$rootNew</span>.<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">”//$strSection”</span>).<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">“add[@key=&#39;$strKeyName&#39;]/@value”</span>).&#39;<span style="color:#60a0b0; font-style:italic"><a href="/cruisinit/tag:text" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">text</span></a>&#39; = $strKeyValueRead</span>
    }
    [<span style="color:#902000">string</span>]<span style="color:#19177c">$strKeyValueWritten</span> = <span style="color:#19177c">$rootNew</span>.<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">”//$strSection”</span>).<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">“add[@key=&#39;$strKeyName&#39;]/@value”</span>).&#39;<span style="color:#60a0b0; font-style:italic"><a href="/cruisinit/tag:text" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">text</span></a>&#39;</span>
    <span style="color:#007020; font-weight:bold">switch</span> (<span style="color:#19177c">$strKeyName</span>)
    {
        &#39;DbVerbindungString&#39; {
            <span style="color:#06287e">Add-Content</span> -Value (<span style="color:#19177c">$strKeyName</span> + <span style="color:#4070a0">“: “</span> + <span style="color:#19177c">$strKeyValueWritten</span> + (<span style="color:#06287e">Get-Date</span> -format <span style="color:#4070a0">“yyyyMMdd</em>HHmm”</span>)) -PassThru -Path <span style="color:#19177c">$strLog</span>
        }
        { <span style="color:#19177c">$<em></span> -in &#39;SystemAccountPw&#39;, &#39;SmtpPw&#39; } {
            <span style="color:#19177c">$strKeyValueRead</span> = <span style="color:#4070a0">”(confidential)”</span>
            <span style="color:#19177c">$strKeyValueWritten</span> = <span style="color:#4070a0">”(confidential)”</span>
        }
    }
    <span style="color:#06287e">Add-Content</span> -Value (<span style="color:#4070a0">“web.config: Setting &#39;$strSection.$strKeyName&#39;: read &#39;$strKeyValueRead&#39;, written &#39;$strKeyValueWritten&#39; “</span> + (<span style="color:#06287e">Get-Date</span> -format <span style="color:#4070a0">“yyyyMMdd</em>HHmm”</span>)) -PassThru -Path <span style="color:#19177c">$strLog</span>
} <span style="color:#60a0b0; font-style:italic"># function CopyWebConfigAttrValue</span></p>

<p><span style="color:#007020; font-weight:bold">function</span> SetWebConfigAttrValue(<span style="color:#19177c">$root</span>, <span style="color:#19177c">$strSection</span>, <span style="color:#19177c">$strKeyName</span>, <span style="color:#19177c">$strKeyValue</span>, <span style="color:#19177c">$strLog</span>)
{
    <span style="color:#19177c">$strKeyValueRead</span> = <span style="color:#19177c">$root</span>.<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">”//$strSection”</span>).<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">“add[@key=&#39;$strKeyName&#39;]/@value”</span>).&#39;<span style="color:#60a0b0; font-style:italic"><a href="/cruisinit/tag:text" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">text</span></a>&#39;</span>
    <span style="color:#007020; font-weight:bold">if</span> ( <span style="color:#19177c">$strKeyValueRead</span> -in (<span style="color:#19177c">$null</span>, <span style="color:#4070a0">””</span>) )
    {
        <span style="color:#19177c">$newItem</span> = <span style="color:#19177c">$root</span>.<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">”//$strSection”</span>).<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">“add[1]”</span>).<span style="color:#06287e">Clone</span>()
        <span style="color:#19177c">$newItem</span>.<span style="color:#06287e">SetAttribute</span>(<span style="color:#4070a0">“key”</span>,<span style="color:#19177c">$strKeyName</span>)
        <span style="color:#19177c">$newItem</span>.<span style="color:#06287e">SetAttribute</span>(<span style="color:#4070a0">“value”</span>,<span style="color:#19177c">$strKeyValue</span>)
        <span style="color:#19177c">$rootNew</span>.<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">”//$strSection”</span>).<span style="color:#06287e">AppendChild</span>(<span style="color:#19177c">$newItem</span>)
        [<span style="color:#902000">string</span>]<span style="color:#19177c">$strMsg</span> = <span style="color:#4070a0">“web.config: Setting &#39;$strSection.$strKeyName&#39; did not exist in web<em>ref.config (you should maintain web</em>ref.config) and has been automatically created by this script in target web.config, value has been set to &#39;$strKeyValueRead&#39;, from former version&#39;s web.config. “</span> + (<span style="color:#06287e">Get-Date</span> -format <span style="color:#4070a0">“yyyyMMdd_HHmm”</span>)
        <span style="color:#06287e">Add-Type</span> -AssemblyName PresentationFramework
        [System.<span style="color:#06287e">Windows</span>.<span style="color:#06287e">MessageBox</span>]::Show(<span style="color:#19177c">$strMsg</span>,&#39;&lt;Program&gt; Updater: New Setting&#39;,&#39;OK&#39;,&#39;Error&#39;)
        <span style="color:#06287e">Add-Content</span> -Value <span style="color:#19177c">$strMsg</span> -PassThru -Path <span style="color:#19177c">$strLog</span>
    }
    <span style="color:#007020; font-weight:bold">else</span>
    {
        <span style="color:#19177c">$root</span>.<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">”//$strSection”</span>).<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">“add[@key=&#39;$strKeyName&#39;]/@value”</span>).&#39;<span style="color:#60a0b0; font-style:italic"><a href="/cruisinit/tag:text" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">text</span></a>&#39; = $strKeyValue</span>
    }</p>

<p>    [<span style="color:#902000">string</span>]<span style="color:#19177c">$strKeyValueWritten</span> = <span style="color:#19177c">$root</span>.<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">”//$strSection”</span>).<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">“add[@key=&#39;$strKeyName&#39;]/@value”</span>).&#39;<span style="color:#60a0b0; font-style:italic"><a href="/cruisinit/tag:text" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">text</span></a>&#39;</span>
    <span style="color:#007020; font-weight:bold">switch</span> (<span style="color:#19177c">$strKeyName</span>)
    {
        &#39;DbVerbindungString&#39; {
            <span style="color:#06287e">Add-Content</span> -Value (<span style="color:#19177c">$strKeyName</span> + <span style="color:#4070a0">“: “</span> + <span style="color:#19177c">$strKeyValueWritten</span> + (<span style="color:#06287e">Get-Date</span> -format <span style="color:#4070a0">“yyyyMMdd<em>HHmm”</span>)) -PassThru -Path <span style="color:#19177c">$strLog</span>
        }
        { <span style="color:#19177c">$</em></span> -in &#39;SystemAccountPw&#39;, &#39;SmtpPw&#39; } {
            <span style="color:#19177c">$strKeyValueRead</span> = <span style="color:#4070a0">”(confidential)”</span>
            <span style="color:#19177c">$strKeyValueWritten</span> = <span style="color:#4070a0">”(confidential)”</span>
        }
    }
    <span style="color:#06287e">Add-Content</span> -Value (<span style="color:#4070a0">“web.config: Setting &#39;$strSection.$strKeyName&#39; was set to &#39;$strKeyValueWritten&#39; “</span> + (<span style="color:#06287e">Get-Date</span> -format <span style="color:#4070a0">“yyyyMMdd_HHmm”</span>)) -PassThru -Path <span style="color:#19177c">$strLog</span>
} <span style="color:#60a0b0; font-style:italic"># function SetWebConfigAttrValue</span></p>

<p><span style="color:#60a0b0; font-style:italic"># copy authorization keys – <a href="http://michlstechblog.info/blog/powershell-some-basic-xml-handling-with-powershell-and-net/" rel="nofollow">http://michlstechblog.info/blog/powershell-some-basic-xml-handling-with-powershell-and-net/</a></span>
<span style="color:#007020; font-weight:bold">function</span> CopyWebConfigAuthorizationNode(<span style="color:#19177c">$rootNew</span>, <span style="color:#19177c">$rootOld</span>, <span style="color:#19177c">$xmlConfigNew</span>, <span style="color:#19177c">$strLog</span>)
{</p>

<p>    <span style="color:#19177c">$rootNew</span>.&#39;system.<span style="color:#06287e">web</span>&#39;.<span style="color:#06287e">RemoveChild</span>(<span style="color:#19177c">$rootNew</span>.&#39;system.<span style="color:#06287e">web</span>&#39;.<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">“authorization”</span>)) | <span style="color:#06287e">Out-Null</span>
    <span style="color:#19177c">$newNode</span> = <span style="color:#19177c">$xmlConfigNew</span>.<span style="color:#06287e">ImportNode</span>(<span style="color:#19177c">$rootOld</span>.&#39;system.<span style="color:#06287e">web</span>&#39;.<span style="color:#06287e">SelectSingleNode</span>(<span style="color:#4070a0">“authorization”</span>), <span style="color:#19177c">$true</span>)
    <span style="color:#19177c">$rootNew</span>.&#39;system.<span style="color:#06287e">web</span>&#39;.<span style="color:#06287e">AppendChild</span>(<span style="color:#19177c">$newNode</span>) | <span style="color:#06287e">Out-Null</span>
    <span style="color:#06287e">Add-Content</span> -Value (<span style="color:#4070a0">“web.config: Copied &#39;authorization&#39; section. “</span> + (<span style="color:#06287e">Get-Date</span> -format <span style="color:#4070a0">“yyyyMMdd_HHmm”</span>)) -PassThru -Path <span style="color:#19177c">$strLog</span></p>

<p>}</p>

<p><span style="color:#007020; font-weight:bold">function</span> AdaptWebConfig([<span style="color:#902000">string</span>]<span style="color:#19177c">$strNewVerFolder</span>, [<span style="color:#902000">string</span>]<span style="color:#19177c">$strOldVerFolder</span>, [<span style="color:#902000">string</span>]<span style="color:#19177c">$strNewVersion</span>, [<span style="color:#902000">string</span>]<span style="color:#19177c">$strLog</span>, <span style="color:#19177c">$hshSettings</span>)
{</p>

<p>    <span style="color:#06287e">Rename-Item</span> (<span style="color:#19177c">$strNewVerFolder</span> + <span style="color:#4070a0">“web_ref.config”</span>) <span style="color:#4070a0">“web.config”</span>
    [<span style="color:#902000">string</span>]<span style="color:#19177c">$strOldVerConfig</span> = <span style="color:#19177c">$strOldVerFolder</span> + <span style="color:#4070a0">“web.config”</span>
    [<span style="color:#902000">string</span>]<span style="color:#19177c">$strNewVerConfig</span> = <span style="color:#19177c">$strNewVerFolder</span> + <span style="color:#4070a0">“web.config”</span></p>

<p>    <span style="color:#06287e">Add-Content</span> -Value (<span style="color:#4070a0">“Old web.config: “</span> + <span style="color:#19177c">$strOldVerConfig</span>) -Path <span style="color:#19177c">$strLog</span> -PassThru
    <span style="color:#06287e">Add-Content</span> -Value (<span style="color:#4070a0">“New web.config: “</span> + <span style="color:#19177c">$strNewVerConfig</span>) -Path <span style="color:#19177c">$strLog</span> -PassThru</p>

<p>    <span style="color:#4070a0">“Adapting $strNewVerConfig”</span></p>

<p>    [xml]<span style="color:#19177c">$xmlConfigOld</span> = <span style="color:#06287e">Get-Content</span> <span style="color:#19177c">$strOldVerConfig</span>
    [xml]<span style="color:#19177c">$xmlConfigNew</span> = <span style="color:#06287e">Get-Content</span> <span style="color:#19177c">$strNewVerConfig</span>
    <span style="color:#19177c">$rootOld</span> = <span style="color:#19177c">$xmlConfigOld</span>.<span style="color:#06287e">get<em>DocumentElement</span>()
    <span style="color:#19177c">$rootNew</span> = <span style="color:#19177c">$xmlConfigNew</span>.<span style="color:#06287e">get</em>DocumentElement</span>()</p>

<p>    [<span style="color:#902000">int</span>]<span style="color:#19177c">$intProgMainVersion</span> = (<span style="color:#19177c">$strNewVersion</span>.<span style="color:#06287e">Split</span>(<span style="color:#4070a0">”.”</span>))[0]</p>

<p>    <span style="color:#007020; font-weight:bold">switch</span> (<span style="color:#19177c">$intProgMainVersion</span>)
    {
    2 {
        <span style="color:#60a0b0; font-style:italic"># NotebookVersion</span>
        SetWebConfigAttrValue <span style="color:#19177c">$rootNew</span> <span style="color:#4070a0">“appSettingsNotebook”</span> <span style="color:#4070a0">“NotebookVersion”</span> <span style="color:#19177c">$strNewVersion</span> <span style="color:#19177c">$strLog</span></p>

<p>        <span style="color:#60a0b0; font-style:italic"># &lt;authorization&gt;</span>
        CopyWebConfigAuthorizationNode <span style="color:#19177c">$rootNew</span> <span style="color:#19177c">$rootOld</span> <span style="color:#19177c">$xmlConfigNew</span> <span style="color:#19177c">$strLog</span></p>

<p>        <span style="color:#60a0b0; font-style:italic"># appSettings</span>
        <span style="color:#007020; font-weight:bold">foreach</span> (<span style="color:#19177c">$key</span> <span style="color:#007020; font-weight:bold">in</span> <span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“web.config v2 appSettings”</span>].<span style="color:#06287e">Keys</span>)
        {
            CopyWebConfigAttrValue <span style="color:#19177c">$rootNew</span> <span style="color:#19177c">$rootOld</span> <span style="color:#4070a0">“appSettings”</span> <span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“web.config v2 appSettings”</span>][<span style="color:#19177c">$key</span>] <span style="color:#19177c">$strLog</span>
        }</p>

<p>        <span style="color:#60a0b0; font-style:italic"># appSettingsNotebook</span>
        <span style="color:#007020; font-weight:bold">foreach</span> (<span style="color:#19177c">$key</span> <span style="color:#007020; font-weight:bold">in</span> <span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“web.config v2 appSettingsNotebook”</span>].<span style="color:#06287e">Keys</span>)
        {
            CopyWebConfigAttrValue <span style="color:#19177c">$rootNew</span> <span style="color:#19177c">$rootOld</span> <span style="color:#4070a0">“appSettingsNotebook”</span> <span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“web.config v2 appSettingsNotebook”</span>][<span style="color:#19177c">$key</span>] <span style="color:#19177c">$strLog</span>
        }</p>

<p>      } <span style="color:#60a0b0; font-style:italic"># switch 2</span></p>

<p>    3 {
        <span style="color:#60a0b0; font-style:italic"># appSettings</span>
        <span style="color:#007020; font-weight:bold">foreach</span> (<span style="color:#19177c">$key</span> <span style="color:#007020; font-weight:bold">in</span> <span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“web.config v3 appSettings”</span>].<span style="color:#06287e">Keys</span>)
        {
            CopyWebConfigAttrValue <span style="color:#19177c">$rootNew</span> <span style="color:#19177c">$rootOld</span> <span style="color:#4070a0">“appSettings”</span> <span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“web.config v3 appSettings”</span>][<span style="color:#19177c">$key</span>] <span style="color:#19177c">$strLog</span>
        }</p>

<p>        <span style="color:#60a0b0; font-style:italic"># appSettingsNotebook</span>
        <span style="color:#007020; font-weight:bold">foreach</span> (<span style="color:#19177c">$key</span> <span style="color:#007020; font-weight:bold">in</span> <span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“web.config v3 appSettingsNotebook”</span>].<span style="color:#06287e">Keys</span>)
        {
            CopyWebConfigAttrValue <span style="color:#19177c">$rootNew</span> <span style="color:#19177c">$rootOld</span> <span style="color:#4070a0">“appSettingsNotebook”</span> <span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“web.config v3 appSettingsNotebook”</span>][<span style="color:#19177c">$key</span>] <span style="color:#19177c">$strLog</span>
        }</p>

<p>      } <span style="color:#60a0b0; font-style:italic"># switch 3</span>
    } <span style="color:#60a0b0; font-style:italic"># switch</span></p>

<p>    <span style="color:#19177c">$xmlConfigNew</span>.<span style="color:#06287e">Save</span>(<span style="color:#19177c">$strNewVerConfig</span>) | <span style="color:#06287e">Out-Null</span></p>

<p>    [<span style="color:#902000">string</span>]<span style="color:#19177c">$strNewVerConfigBak</span> = <span style="color:#19177c">$strNewVerFolder</span> + <span style="color:#4070a0">“BakCfg\”</span>
    <span style="color:#007020; font-weight:bold">if</span> ((<span style="color:#06287e">Test-Path</span> <span style="color:#19177c">$strNewVerConfigBak</span>) -eq <span style="color:#19177c">$false</span>)
        { <span style="color:#06287e">New-Item</span> -Path (<span style="color:#06287e">Split-Path</span> -Path <span style="color:#19177c">$strNewVerConfigBak</span> -Parent) -Name (<span style="color:#06287e">Split-Path</span> -Path <span style="color:#19177c">$strNewVerConfigBak</span> -Leaf) -ItemType directory | <span style="color:#06287e">Out-Null</span> }
    <span style="color:#19177c">$strNewVerConfigBak</span> += (<span style="color:#4070a0">“web.config.”</span> + (<span style="color:#06287e">Get-Date</span> -format <span style="color:#4070a0">“yyyyMMdd.HHmm”</span>) + <span style="color:#4070a0">“h”</span>)
    <span style="color:#06287e">Copy-Item</span> <span style="color:#19177c">$strNewVerConfig</span> <span style="color:#19177c">$strNewVerConfigBak</span></p>

<p>} <span style="color:#60a0b0; font-style:italic"># function AdaptWebConfig</span></p>

<p><span style="color:#007020; font-weight:bold">function</span> MailResult (<span style="color:#19177c">$strLogFolder</span>, <span style="color:#19177c">$hshSettings</span>)
{
    [<span style="color:#902000">string</span>]<span style="color:#19177c">$ThisScriptCopy</span> = <span style="color:#19177c">$PSCommandPath</span> + <span style="color:#4070a0">”.txt”</span>
    <span style="color:#06287e">Copy-Item</span> <span style="color:#19177c">$PSCommandPath</span> <span style="color:#19177c">$ThisScriptCopy</span> -Force
    <span style="color:#19177c">$dirLogs</span> = <span style="color:#06287e">Get-ChildItem</span> (<span style="color:#19177c">$strLogFolder</span> + <span style="color:#4070a0">“*”</span>)</p>

<p>    [<span style="color:#902000">string</span>[]]<span style="color:#19177c">$astrAttachments</span> = @()
    <span style="color:#19177c">$astrAttachments</span> += <span style="color:#19177c">$ThisScriptCopy</span>
    <span style="color:#007020; font-weight:bold">foreach</span> (<span style="color:#19177c">$strLogFile</span> <span style="color:#007020; font-weight:bold">in</span> <span style="color:#19177c">$dirLogs</span>)
    {
        <span style="color:#19177c">$astrAttachments</span> += <span style="color:#19177c">$strLogFile</span>.<span style="color:#06287e">FullName</span>
    }</p>

<p>    [<span style="color:#902000">string</span>]<span style="color:#19177c">$strBody</span> = <span style="color:#4070a0">“ProgramUpdater was started by “</span> + <span style="color:#19177c">$env</span>:USERDOMAIN + <span style="color:#4070a0">“\”</span> + <span style="color:#19177c">$env</span>:USERNAME
    <span style="color:#19177c">$strBody</span> += <span style="color:#4070a0">” on “</span> + [System.<span style="color:#06287e">Net</span>.<span style="color:#06287e">Dns</span>]::GetHostByName((hostname)).<span style="color:#06287e">HostName</span></p>

<p>    <span style="color:#007020; font-weight:bold">foreach</span> (<span style="color:#19177c">$strAttachment</span> <span style="color:#007020; font-weight:bold">in</span> <span style="color:#19177c">$astrAttachments</span>)
    {
        <span style="color:#19177c">$strBody</span> += <span style="color:#4070a0">“<code>n</code>n ====================”</span>
        <span style="color:#19177c">$strBody</span> += <span style="color:#4070a0">“<code>n</code>n “</span> + <span style="color:#19177c">$strAttachment</span>
        <span style="color:#19177c">$strBody</span> += <span style="color:#06287e">Get-Content</span> <span style="color:#19177c">$strAttachment</span>
    }</p>

<p>    [<span style="color:#902000">string</span>[]]<span style="color:#19177c">$astrMailRecipients</span> = @()
    <span style="color:#007020; font-weight:bold">foreach</span> (<span style="color:#19177c">$key</span> <span style="color:#007020; font-weight:bold">in</span> <span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“Result mail”</span>].<span style="color:#06287e">Keys</span>)
    {
        <span style="color:#007020; font-weight:bold">if</span> (<span style="color:#19177c">$key</span> -like <span style="color:#4070a0">“To*”</span>)
            { <span style="color:#19177c">$astrMailRecipients</span> += <span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“Result mail”</span>][<span style="color:#19177c">$key</span>] }
    }</p>

<p>    <span style="color:#007020; font-weight:bold">if</span> (<span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“Result mail”</span>][<span style="color:#4070a0">“Use”</span>] -eq <span style="color:#4070a0">“1”</span>)
    {
        <span style="color:#06287e">Send-MailMessage</span> -To <span style="color:#19177c">$astrMailRecipients</span> <code>
            -From &lt;span style=&#34;color:#19177c&#34;&gt;$hshSettings&lt;/span&gt;[&lt;span style=&#34;color:#4070a0&#34;&gt;&#34;Result mail&#34;&lt;/span&gt;][&lt;span style=&#34;color:#4070a0&#34;&gt;&#34;From&#34;&lt;/span&gt;]</code>
            -Subject <span style="color:#4070a0">“ProgramUpdater”</span> <code>
            -Body &lt;span style=&#34;color:#19177c&#34;&gt;$strBody&lt;/span&gt;</code>
            -SmtpServer <span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“Result mail”</span>][<span style="color:#4070a0">“SmtpServer”</span>] <code>
            -Attachments &lt;span style=&#34;color:#19177c&#34;&gt;$astrAttachments&lt;/span&gt;</code>
            -ErrorAction SilentlyContinue
    }</p>

<p>    <span style="color:#007020; font-weight:bold">if</span> (<span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“Result mail WS”</span>][<span style="color:#4070a0">“Use”</span>] -eq <span style="color:#4070a0">“1”</span>)
    {
        <span style="color:#19177c">$pw</span> = <span style="color:#06287e">ConvertTo-SecureString</span> -String <span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“Result mail WS”</span>][<span style="color:#4070a0">“WsUserPw”</span>] -AsPlainText -Force
        <span style="color:#19177c">$creds</span> = <span style="color:#06287e">New-Object</span> System.<span style="color:#06287e">Management</span>.<span style="color:#06287e">Automation</span>.<span style="color:#06287e">PSCredential</span> <span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“Result mail WS”</span>][<span style="color:#4070a0">“WsUserName”</span>], <span style="color:#19177c">$pw</span>
        <span style="color:#19177c">$wsSmtp</span> = <span style="color:#06287e">New-WebServiceProxy</span> <span style="color:#19177c">$hshSettings</span>[<span style="color:#4070a0">“Result mail WS”</span>][<span style="color:#4070a0">“WsUrl”</span>] -Credential <span style="color:#19177c">$creds</span>
        <span style="color:#007020; font-weight:bold">foreach</span> (<span style="color:#19177c">$Addr</span> <span style="color:#007020; font-weight:bold">in</span> <span style="color:#19177c">$astrMailRecipients</span>)
        {
            <span style="color:#19177c">$wsSmtp</span>.<span style="color:#06287e">SendeEmailMitStandardAbsender</span>(<span style="color:#19177c">$Addr</span>,<span style="color:#4070a0">””</span>,<span style="color:#4070a0">””</span>,<span style="color:#4070a0">“ProgramUpdater”</span>,<span style="color:#19177c">$strBody</span>)
        }
    }
} <span style="color:#60a0b0; font-style:italic"># function MailResult</span></p>

<p><span style="color:#007020; font-weight:bold">Function</span> BackslashTrailToFolder (<span style="color:#19177c">$strFolder</span>)
{
    <span style="color:#007020; font-weight:bold">if</span> ( (<span style="color:#19177c">$strFolder</span>.<span style="color:#06287e">Substring</span>(<span style="color:#19177c">$strFolder</span>.<span style="color:#06287e">Length</span> – 1)) -ne <span style="color:#4070a0">“\”</span> )
    {
        <span style="color:#19177c">$strFolder</span> += <span style="color:#4070a0">“\”</span>
        <span style="color:#007020; font-weight:bold">return</span> <span style="color:#19177c">$strFolder</span>
    }
}</p>

<p><span style="color:#007020; font-weight:bold">Function</span> FolderNameWoTrailingBackslash (<span style="color:#19177c">$strFolder</span>)
{
    <span style="color:#007020; font-weight:bold">if</span> ( (<span style="color:#19177c">$strFolder</span>.<span style="color:#06287e">Substring</span>(<span style="color:#19177c">$strFolder</span>.<span style="color:#06287e">Length</span> – 1)) -eq <span style="color:#4070a0">“\”</span> )
    {
        <span style="color:#19177c">$strFolder</span> = <span style="color:#19177c">$strFolder</span>.<span style="color:#06287e">Substring</span>(0, <span style="color:#19177c">$strFolder</span>.<span style="color:#06287e">Length</span> – 1)
        <span style="color:#007020; font-weight:bold">return</span> <span style="color:#19177c">$strFolder</span>
    }
}</p>
]]></content:encoded>
      <guid>https://wordsmith.social/cruisinit/programupdater-ps1</guid>
      <pubDate>Mon, 04 Jan 2021 19:15:10 +0000</pubDate>
    </item>
  </channel>
</rss>