PoshCode Logo PowerShell Code Repository

Set-PowerGUIWelcomePage by Dmitry Sotnikov 35 months ago (modification of post by Dmitry Sotnikov view diff)
View followups from Dmitry Sotnikov | diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/961"></script>download | new post

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.
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

  1. ########################################################
  2. # Modifies the default PowerGUI admin console
  3. # welcome screen to the mht file you supply
  4. # Details available at:
  5. # http://dmitrysotnikov.wordpress.com/2009/02/11/rebranding-powergui-consolerebranding-powergui-console/
  6. ########################################################
  7. # Usage:
  8. # & .\Set-PowerGUIWelcomePage.ps1 \\server\share\my.mht
  9. ########################################################
  10. # (c) Dmitry Sotnikov, Oleg Shevnin
  11. #  1.1 - Mar 17: added exception if PowerGUI Admin Console is running
  12. #  v1, Feb 11, 2009
  13. #
  14. ########################################################
  15.  
  16. param ($mhtpath)
  17. # this should be path (local or UNC) to the new welcome page
  18.  
  19. # make sure that the admin console is closed
  20. if (( get-process Quest.PowerGUI -ErrorAction SilentlyContinue ) -ne $null) {
  21.         throw "Please close the PowerGUI administrative console before running this script "
  22. }
  23.  
  24. # verify that the new file exists and is mht
  25. if ( $mhtpath -eq $null ) {
  26.         $mhtpath = Read-Host "Please provide path to the MHT file."
  27. }
  28. $mhtfile = Get-ChildItem $mhtpath
  29. if ( $mhtfile -eq $null) {
  30.         throw "MHT file $mhtpath not found. Please verify the script parameter."
  31. }
  32. if ( $mhtfile.Extension -ne ".mht" ) {
  33.         throw "File $mhtpath is not an MHT file. Only MHT files are supported."
  34. }
  35.  
  36. # Locate PowerGUI configuration for current user on this computer
  37. $cfgpath = "$($env:APPDATA)\Quest Software\PowerGUI\quest.powergui.xml"
  38.  
  39. # Create backup
  40. Copy-Item $cfgpath "$cfgpath.backupconfig"
  41.  
  42. # Read the file
  43. $xml = [xml]$(Get-Content $cfgpath)
  44.  
  45. # If the section for custom welcome page does not exist - create it
  46. $node = $xml.SelectSingleNode("//container[@id='4b510268-a4eb-42e0-9276-06223660291d']")
  47. if ($node -eq $null) {
  48.         $node = $xml.CreateElement("container")
  49.        
  50.         $node.SetAttribute("id", "4b510268-a4eb-42e0-9276-06223660291d")
  51.         $node.SetAttribute("name", "Home Page")
  52.        
  53.         $node.AppendChild($xml.CreateElement("value"))
  54.         $xml.SelectSingleNode("/configuration/items").AppendChild($node)
  55. }
  56.  
  57. # Set the new value and save the file
  58. $node.Value = $mhtpath
  59. $xml.Save($cfgpath)

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me