Skip to content

Instantly share code, notes, and snippets.

@alainassaf
Last active February 5, 2021 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alainassaf/b9c59e5a7f5e1658b51119e4a8cf7c0c to your computer and use it in GitHub Desktop.
Save alainassaf/b9c59e5a7f5e1658b51119e4a8cf7c0c to your computer and use it in GitHub Desktop.
Script to open the Citrix WEM Console
<#
.SYNOPSIS
Opens WEM Mgmt Console connected to entered WEM Infrastrucure Server
.DESCRIPTION
Opens WEM Mgmt Console connected to entered WEM Infrastrucure Server
.PARAMETER WEMServer
Optional string parameter. The WEM Infrastrucure server the WEM Console will connect to.
.EXAMPLE
PS> open-WemConsole.ps1
Opens the WEM Console connected to the last WEM infrastrcuture server.
.EXAMPLE
PS> open-WemConsole.ps1 -wemserver WEMSERVER
Updates the registry with WEMSERVER and opens the Console connected to WEMSERVER.
.EXAMPLE
PS> open-WemConsole.ps1 -wemserver WEMSERVER -verbose
Updates the registry with WEMSERVER and opens the Console connected to WEMSERVER. Provides additional verbose feedback.
.INPUTS
None
.OUTPUTS
None
.NOTES
NAME: open-WemConsole.ps1
VERSION: 1.00
CHANGE LOG - Version - When - What - Who
1.00 - 10/30/2020 - Initial script - Alain Assaf
AUTHOR: Alain Assaf
LASTEDIT: October 30, 2020
.LINK
http://www.linkedin.com/in/alainassaf/
#>
#requires -modules NetTCPIP
[CmdletBinding()]
param (
[Parameter()]
[ValidateScript( { Test-NetConnection -ComputerName $_ -Port 8284 -InformationLevel Quiet })]
[String]$WEMServer
)
#Constants
$datetime = Get-Date -Format "MM-dd-yyyy_HH-mm"
$Domain = (Get-ChildItem env:USERDNSDOMAIN).value
$ScriptRunner = (Get-ChildItem env:username).value
$compname = (Get-ChildItem env:COMPUTERNAME).value
$scriptName = $MyInvocation.MyCommand.Name
$scriptpath = $MyInvocation.MyCommand.Path
$currentDir = Split-Path $MyInvocation.MyCommand.Path
$ConsolePath = 'C:\Program Files (x86)\Norskale\Norskale Administration Console\Norskale Administration Console.exe'
$registryPath = "HKCU:\SOFTWARE\VirtuAll Solutions\VirtuAll User Environment Manager\Administration Console"
$Name = "LastBrokerSvcName"
$value = $WEMServer
if ($WEMServer -eq "") {
$WEMServer = ((Get-ItemProperty -Path $registryPath -Name $name).LastBrokerSvcName).tostring()
} else {
if (!(Test-Path $registryPath)) {
Write-Warning "[$registryPath] not found. Confirm WEM Console is installed."
Exit 1
} else {
try {
Set-ItemProperty -Path $registryPath -Name $Name -Value $value
} catch {
Write-Warning "Failed to change [$registryPath\$Name]"
Exit 1
}
}
}
Write-Host "Starting WEM Console connected to [$WEMServer]"
Start-Process $ConsolePath
#Script info
Write-Verbose "SCRIPT NAME: $scriptName"
Write-Verbose "SCRIPT PATH: $scriptPath"
Write-Verbose "SCRIPT RUNTIME: $datetime"
Write-Verbose "SCRIPT USER: $ScriptRunner"
Write-Verbose "SCRIPT SYSTEM: $compname.$domain"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment