webui/savesettings.ps1

$theme       = $PoshPost.Theme
$cmdbhost    = $PoshPost.SkCmDBHost
$cmsitecode  = $PoshPost.SkCmSiteCode
$cmsmsprov   = $PoshPost.SkCmSMSProvider
$cmenabled   = $PoshPost.SkCmEnabled
$adGrpManage = $PoshPost.SkADGroupManage
$debugenable = $PoshPost.SkDebug

try {
    $cfgfile = "$($env:USERPROFILE)\Documents\skconfig.txt"
    $params = [ordered]@{
        _Comment               = "SkatterTools configuration file. Lines with underscore prefix are comments."
        _LastUpdated           = (Get-Date)
        _ModuleVersion         = (Get-Module sktools).Version -join '.'
        _UpdatedBy             = $env:USERNAME
        _LocalHost             = $env:COMPUTERNAME
        _UserDomain            = $env:USERDOMAIN
        SkAPPNAME              = "SkatterTools"
        SkTheme                = $theme
        SkADEnabled            = "TRUE"
        SkADGroupManage        = $adGrpManage
        SkCMEnabled            = $cmenabled
        SkCmDBHost             = $cmdbhost
        SkCmSMSProvider        = $cmsmsprov
        SkCmSiteCode           = $cmsitecode
        SkCmCollectionManage   = "TRUE"
        SkDebug                = $debugenable
        SkTabSelectAdUsers     = "A"
        SkTabSelectAdGroups    = "A"
        SkTabSelectAdComputers = "A"
        SkTabSelectCmFiles     = "A"
        SkTabSelectCmUsers     = "A"
        SkTabSelectCmDevices   = "A"
        SkTabSelectCmDevColls  = "A"
        SkTabSelectCmUserColls = "A"
        SkCmCollectionCheck    = "TRUE"
        SkUseDashboard         = "TRUE"
        SkToolsPath            = Join-Path -Path $env:USERPROFILE -ChildPath "Documents"
    }
    $params.Keys | %{ "$($_) = $($params.Item($_))" } | Out-File $cfgfile

    $content = "<table id=table2>
<tr><td>Theme</td><td>$themefile</td></tr>
<tr><td>CM DB Host</td><td>$cmdbhost</td></tr>
<tr><td>CM SMS Provider</td><td>$cmsmsprov</td></tr>
<tr><td>CM Site Code</td><td>$cmsitecode</td></tr>
<tr><td>CM Enabled</td><td>$cmenabled</td></tr>
<tr><td>Debug Enabled</td><td>$debugenable</td></tr>
</table>"

    $Global:SkTheme = $theme
}
catch {
    $content = "<table id=table2><tr><td>Failed!</td></tr></table>"
}

@"
<html>
<head>
<link rel="stylesheet" type="text/css" href="$SkTheme"/>
<title>SkatterTools Settings</title>
</head>
 
<body>
 
<h1>Settings</h1>
 
$content
 
<div align="center">
    <table style="border:none; width:150px;">
        <tr>
            <td style="padding:5px"><a href="./" target="_top">Reload Console</a></td>
        </tr>
    </table>
</div>
 
</body>
</html>
"@