Last active
August 29, 2015 14:00
-
-
Save dotps1/11318873 to your computer and use it in GitHub Desktop.
Set the default method for Citrix Reciver to use Pass-Through Authentication first.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| Sets Single Sign On Option as the default sign on method to Pass-Through Authentication. | |
| .DESCRIPTION | |
| Exports the Configuration Model 000 Registry Binary Key. | |
| Converts the Binary to ASCII and then to an Xml Object. | |
| Using the Xml Class Methods, it modifes the 'LogonMethod' Value to 'sson'. | |
| If the 'LogonMethod' Node does not exist, it will be created and the Value set to 'sson'. | |
| Commits the changes, if there where any back to the registry. | |
| .EXAMPLE | |
| Set-CitrixReceiverSSON | |
| .EXAMPLE | |
| Set-CitrixReceiverSSON -ComputerName "MyComputer.mydomain.org" | |
| .NOTES | |
| This is useful when the prompt user authentication method is default. | |
| At a minimum a logon and logoff is requried to complete this process, reboot is recommended. | |
| Framework Credit to Remko Weijnen | |
| .LINK | |
| http://www.remkoweijnen.nl/blog/2012/02/13/scripting-citrix-online-plugin-settings | |
| http://support.citrix.com/article/CTX123150 | |
| http://dotps1.github.io | |
| #> | |
| function Set-CitrixReceiverSSON | |
| { | |
| [CmdletBinding()] | |
| [OutputType([Void])] | |
| param | |
| ( | |
| # ComputerName, Type String, Computer Name to to set value on. | |
| [Parameter(Position = 0)] | |
| [ValidateScript({ if (-not (Test-Connection -ComputerName $_ -Quiet -Count 2)) { throw "Failed to connect to $_. Please ensure the system is available." } else { $true } })] | |
| [String] | |
| $ComputerName = $env:COMPUTERNAME | |
| ) | |
| try | |
| { | |
| $regKey = ([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("CurrentUser", $ComputerName)).OpenSubKey("Software\Citrix\PNAgent", $true) | |
| $regValue = $regKey.GetValue("Configuration Model 000") | |
| } | |
| catch | |
| { | |
| throw "The Citrix PNA Agent Registry Key does not exist on $ComputerName." | |
| } | |
| $data = %{ [RegEx]::Replace([System.Text.ASCIIEncoding]::ASCII.GetString($regValue),'<([^>]+)>',{ $args[0] -replace ' ','_' }) } | |
| # Add dummy outter rood nodes. | |
| $data = "<root>$data</root>" | |
| $xml = [System.Xml.XmlDocument]$data | |
| $logonMethodValue = ($xml.root.User_Blob.Item | ?{ $_.Key -eq 'LogonMethod' }).Value | |
| if ($logonMethodValue -eq $null) | |
| { | |
| $item = $xml.CreateElement("Item") | |
| $key = $xml.CreateElement("Key") | |
| $key.AppendChild($xml.CreateTextNode("LogonMethod")) | Out-Null | |
| $item.AppendChild($key) | Out-Null | |
| $itemValue = $xml.CreateElement("Value") | |
| $itemValue.AppendChild($xml.CreateTextNode("sson")) | Out-Null | |
| $item.AppendChild($itemValue) | Out-Null | |
| $xml.root.User_Blob.AppendChild($item) | Out-Null | |
| $valueModified=$true | |
| } | |
| elseif ($logonMethodValue -ne "sson") | |
| { | |
| ($xml.root.User_Blob.Item | ?{ $_.Key -eq 'LogonMethod' }).Value = "sson" | |
| $valueModified = $true | |
| } | |
| if ($valueModified) | |
| { | |
| $rawData = $xml.root.InnerXml | %{ [regex]::replace($_,'<([^>]+)>',{ $args[0] -replace '_',' ' }) } | |
| $newValue = [System.Text.ASCIIEncoding]::ASCII.GetBytes($rawData) | |
| $regKey.SetValue("Configuration Model 000", $newValue) | |
| } | |
| $regKey.Close() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment