PoshCode Archive  Artifact Content

Artifact 0fccb632d5e3ca02f3ee953d9f11949847a65cf10ba7ea5250e4f123614460d8:

  • File Set-PowerGUIWelcomePage.ps1 — part of check-in [9b4edfc4a0] at 2018-06-10 14:25:27 on branch trunk — This script customizes the welcome screen which PowerGUI admin console displays on start-up or when a folder is selected in the left-hand tree. (user: Dmitry Sotnikov size: 2720)

# encoding: ascii
# api: powershell
# title: Set-PowerGUIWelcomePage
# description: This script customizes the welcome screen which PowerGUI admin console displays on start-up or when a folder is selected in the left-hand tree.
# version: 0.1
# type: script
# author: Dmitry Sotnikov
# license: CC0
# x-poshcode-id: 860
# x-archived: 2016-05-28T01:29:58
# x-published: 2009-02-11T06:06:00
#
# You can use it to introduce branding to the PowerGUI consoles used in your company or to provide your employees with additional information.
# Create the MHT file by saving it from Internet Explorer, Microsoft Word or another editor, then run this script to set a reference to the file from PowerGUI configuration.
# See http://dmitrysotnikov.wordpress.com/2009/02/11/rebranding-powergui-consolerebranding-powergui-console/ for details
#
########################################################
# Modifies the default PowerGUI admin console
# welcome screen to the mht file you supply
# Details available at:
# http://dmitrysotnikov.wordpress.com/2009/02/11/rebranding-powergui-consolerebranding-powergui-console/ 
########################################################
# Usage:
# & .\Set-PowerGUIWelcomePage.ps1 \\server\share\my.mht
########################################################
# (c) Dmitry Sotnikov, Oleg Shevnin
# v1, Feb 11, 2009
########################################################

param ($mhtpath)
# this should be path (local or UNC) to the new welcome page

# verify that the new file exists and is mht
if ( $mhtpath -eq $null ) {
	$mhtpath = Read-Host "Please provide path to the MHT file."
}
$mhtfile = Get-ChildItem $mhtpath
if ( $mhtfile -eq $null) { 
	throw "MHT file $mhtpath not found. Please verify the script parameter." 
}
if ( $mhtfile.Extension -ne ".mht" ) {
	throw "File $mhtpath is not an MHT file. Only MHT files are supported." 
}

# Locate PowerGUI configuration for current user on this computer
$cfgpath = "$($env:APPDATA)\Quest Software\PowerGUI\quest.powergui.xml"

# Create backup
Copy-Item $cfgpath "$cfgpath.backupconfig"

# Read the file
$xml = [xml]$(Get-Content $cfgpath)

# If the section for custom welcome page does not exist - create it
$node = $xml.SelectSingleNode("//container[@id='4b510268-a4eb-42e0-9276-06223660291d']")
if ($node -eq $null) {
	$node = $xml.CreateElement("container")
	
	$node.SetAttribute("id", "4b510268-a4eb-42e0-9276-06223660291d")
	$node.SetAttribute("name", "Home Page")
	
	$node.AppendChild($xml.CreateElement("value"))
	$xml.SelectSingleNode("/configuration/items").AppendChild($node)
}

# Set the new value and save the file
$node.Value = $mhtpath
$xml.Save($cfgpath)