A forum user asked if there was an easy way to copy all applications from one delivery group to another. Here is a simple PowerShell script to accomplish this:
Sunday, January 16, 2022
Copy Applications from One Delivery Group to Another
Thursday, October 14, 2021
Retrieve Local Administrators from Multiple Computers
A forum user asked for assistance with a PowerShell script that would read a list of servers from a text file and then either show the list of users in the local administrator groups on each server.
The script below, Get-LocalMembers, takes things a bit further. While it will default to the local administrators group, you can supply any number of groups to the script. It even supports wildcards! By default, the results are displayed on the console, but can also export the results as a .csv file.
The script takes 2 parameters (both optional):
Computers
A list of computers to query. The list may be provided as a parameter to the script, or read from a text file. Default: localhost
Groups
A list of local groups to query on each of the computers. Wildcards are support (see examples below). Default: Administrators
Examples
Get-LocalMembers
Retrieves the members of the default group (Administrators) on the default computer(localhost).
Get-LocalMembers -Computers (Get-Content -Path "c:\temp\computers.txt")
Will retrieve the members of the Administrators group on all the computers in the file computers.txt.
Get-LocalMembers -groups 'Remote*','Admin*'
Will retrieve the members of the Administrators, Remote Desktop Users and Remote Management Users groups on localhost.
Get-LocalMembers | Export-Csv -Path "c:\reports\GroupMembers.csv" -NoTypeInformation
Retrieves the members of the default group (Administrators) on the default computer(localhost) and exports them to the specified .csv file.
Sam Jacobs is the Director of Technology at Newtek Technology Systems (formerly IPM), the longest standing Citrix Platinum Partner on the East Coast. With more than 30 years of IT consulting, Sam is a NetScaler and StoreFront customizations and integrations industry expert. He holds Microsoft and Citrix certifications, and is the editor of TechDevCorner.com, a technical resource blog for IT professionals. He is one of the top Citrix support Forum contributors, and has earned industry praise for the tools he has developed to make NetScaler, StoreFront and Web Interface easier to manage for administrators and more intuitive for end users. Sam became a Citrix Technology Professional (CTP) in 2015, and can be reached at: sjacobs@newtekone.com or on Twitter at: @WIGuru.
Sunday, September 12, 2021
Log Off Idle Citrix Sessions
The simple PowerShell snippet below will log off any session that has been idle for more than the specified number of hours.
# the below number of hours will be logged off
$maxIdleHours = 24
# load the Citrix snapin
Add-PSSnapin Citrix*
# function to calculate the number of hours
# that a session has been idle
Function Get-IdleHours {
param ([TimeSpan] $IdleTime)
($IdleTime.Days * 24) + $IdleTime.Hours
}
# get sessions that are idle
$sessions = @(Get-Brokersession | ? IdleDuration -ne $null)
# cycle through the list, and log off sessions that
# have been idle for > the specified number of hours
foreach ($sess in $sessions) {
if ((Get-IdleHours($sess.IdleDuration)) -gt $maxIdleHours) {
Stop-BrokerSession $sess
}
}
Sam Jacobs is the Director of Technology at Newtek Technology Systems (formerly IPM), the longest standing Citrix Platinum Partner on the East Coast. With more than 30 years of IT consulting, Sam is a NetScaler and StoreFront customizations and integrations industry expert. He holds Microsoft and Citrix certifications, and is the editor of TechDevCorner.com, a technical resource blog for IT professionals. He is one of the top Citrix support Forum contributors, and has earned industry praise for the tools he has developed to make NetScaler, StoreFront and Web Interface easier to manage for administrators and more intuitive for end users. Sam became a Citrix Technology Professional (CTP) in 2015, and can be reached at: sjacobs@newtekone.com or on Twitter at: @WIGuru.
Monday, October 26, 2020
Quickly Disconnect All ICA Sessions
A client recently asked for a way to quickly and easily disconnect all ICA sessions. This seemed like an easy task, which could be accomplished by enabling the Disconnect button within StoreFront. The problem was that the client wanted the ability for users to disconnect their sessions without logging in! Since we don't know who the user is until after login, how would we know which session(s) to disconnect?
I then found out that the Citrix Receiver Self-Service Plug-in had a parameter that will allow you to disconnect all of your applications by simply running the following:
SelfService.exe -disconnectapps
Then it became a matter of creating a new URL Protocol to invoke the above when browsing to the specified protocol. With the assistance of my colleague Jacques Bensimon, we created the attached .REG file. An explanation of the keys in the .REG file follows.
[HKEY_CLASSES_ROOT\xica] defines a new URL protocol called xica.
[HKEY_CLASSES_ROOT\xica\shell\open\command] specifies the registered handler to execute when the URL protocol is invoked.
The final REG key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ProtocolExecute\xica]
eliminates the IE prompt asking permission to run the registered handler. (Note: Other browsers may or may not prompt, and may have their own way of eliminating prompts, including possibly giving the user the option to no longer be prompted for these protocols. Those settings may not be in the Registry at all, but rather in some config files in the user profile.)
To invoke the new protocol, you simply needed to browse to it. This could be accomplished in many ways. For example, you could create a shortcut on the desktop with the URL xica://DisconnectApps. You could also invoke the protocol via a hyperlink or a button on a web page.
Sam Jacobs is the Director of Technology Development at IPM, the longest standing Citrix Platinum Partner on the East Coast. With more than 30 years of IT consulting, Sam is a NetScaler and StoreFront customizations and integrations industry expert. He holds Microsoft MCSD, Citrix and CCP-N certifications, and is the editor of TechDevCorner.com, a technical resource blog for IT professionals. He is one of the top Citrix support Forum contributors, and has earned industry praise for the tools he has developed to make NetScaler, StoreFront and Web Interface easier to manage for administrators and more intuitive for end users. Sam became a Citrix Technology Professional (CTP) in 2015, and can be reached at: sam.jacobs@ipm.com or on Twitter at: @WIGuru.
Tuesday, September 10, 2019
Have PowerShell Keep Your Confidential Information … Confidential!
Monday, March 4, 2019
Adding Text, Links and Other Elements to the NetScaler Logon Page - Part 2
> add responder policy "Logon Page Redirect Policy" "HTTP.REQ.URL.PATH_AND_QUERY.CONTAINS(\"LogonPoint/index.html\")" "Logon Page Redirect Action"
> bind vpn vserver "AG vServer" -policy "Logon Page Redirect Policy" -priority 100 -gotoPriorityExpression END -type REQUEST
> save config
|
|
Original Themes
(Default, Green Bubble, X1)
|
Receiver for Web UI
(RfWebUI) Theme
|
|
Logon page directory
|
/netscaler/ns_gui/vpn/
|
/var/netscaler/logon/LogonPoint/
|
|
Updates to text strings
|
/var/netscaler/logon/themes/<theme>/
resources/<language code>.xml
|
/var/netscaler/logon/themes/
<theme>/strings/<language
code>.json
|
|
String format
|
<String id=”key”>Value</String> OR
<Property id="key"
property="property">Value</Property>
|
“key” : “value”
|
|
Custom text based on
|
<div> ID
|
class name (existing
keys are in /var/netscaler/
logon/LogonPoint/receiver/js/localization/
<language code>/ctxs.strings.js
|
|
CSS file
|
custom.css
|
theme.css
|
Friday, March 1, 2019
Adding Text, Links and Other Elements to the NetScaler Logon Page - Part 1
In this 2-part post, I will divide such customizations of the login page into three categories:
1) Customizations that do not require any rewrite policies/actions (which we’ll call “policies” for brevity) or source code modifications (“modifications”),
2) Customizations that can be accomplished using either policies or modification, and
3) Customizations that will most probably need modification of the source code (usually gateway_login_view.js and/or gateway_login_form_view.js).
In part 1, we will focus on the Default, Green Bubble, and X1 NetScaler 11 themes. In part 2, we will discuss the newest Receiver for Web UI (RfWebUI) theme, which uses a completely new mechanism, which is more similar to modifications made for StoreFront.
First off, regardless of whether modifications are made via policies or modifications, the policies or modifications should be minimized to whatever extent possible. There should never be style information or text strings in the policy or modification. Style information should be confined to the custom.css file, and strings should be placed into the appropriate XML file(s) in the resources directory of the theme, especially if you need localization (multi-language support).
So, for example, instead of:
<div style=’font-family: arial,helvetica,sans-serif;color:white;font-weight:bold;’>WARNING: Use of this system is limited to authorized users. Activities on this system are monitored, and subject to audit.</div>
... the policy or modification itself should only contain:
<div id=’unauthorizedUse’ />
Then, add the following to custom.css:
#unauthorizedUse {
font-family: arial,helvetica,sans-serif;
color:white;
font-weight:bold;
}
... and the following to en.xml (with appropriate entries in other language files):
<String id="unauthorizedUse"> WARNING: Use of this system is limited to authorized users. Activities on this system are monitored, and subject to audit.</String>
Let's take it a step further. As mentioned above, the first category of customizations do not require any policies or modifications at all. Included in this category would be the addition of a few lines of footer text (with or without links), such as the customization above. For example, I can create the following:
... by adding the following to the bottom of custom.css:
#logonbelt-bottomshadow,
#logonbelt-bottomshadow a {
text-align: center;
color: #FFFFFF;
font-size:12pt;
}
#logonbelt-bottomshadow a {
font-weight: bold;
text-decoration: underline;
}
... and adding the following text to en.xml (all on one line):
<String id="logonbelt-bottomshadow">WARNING: Use of this system is limited to authorized users. This system contains confidential and proprietary information. Any unauthorized trespass into or use of this system is prohibited. Any such unauthorized trespass or use may be referred to law enforcement agencies for criminal prosecution and may subject you to civil penalties. Activities on this system are monitored and recorded, and subject to audit.<br>Please refer to the firm's <a href='#'>Acceptable Use Policy</a> for additional details.</String>
The only item you need to be aware of, is that all HTML codes must be converted to their HTML-encoded equivalents. For example:
|
<a>
|
<a>
|
|
</a>
|
</a>
|
|
<b>
|
<b>
|
|
<br>
|
<br>
|
Note that I am not using any policies or modifications for the above. I was able to do this by leveraging the built-in <div> called logonbelt-bottomshadow. There is also a <div> called logonbelt-topshadow that one can use to add text and links above the logon box.
So, when would a policy or modification be called for? When you need to add extra elements to the page. If, for instance, I wanted to add a footer to the previous example:
... I could inject a <div> called footer (following our "Keep It Small" rule, the added code would simply be <div id='footer' />), and then add <String id="footer">myCUGC.org - All Rights Reserved.</String> to en.xml, and the following to custom.css:
#footer {
position: absolute;
bottom: 5px;
height: 30px;
font-size: 12px;
color: white;
font-weight: bold;
text-align: center;
width: 100%;
background-color: black;
padding-top: 5px;
}
Finally, there will be times where the number of modifications, or their complexity make using policies impractical. In those cases, it makes more sense to use modifications. Consider the following example:
First, there are all the added elements (color bars and the extra text on the bottom of the screen). Then there are the additional buttons which will need to be backed by JavaScript calls. While it is certainly possible to use policies for all the elements, it would be much simpler to use modifications in a case like this.
When you use modifications, do not modify the original .js file. Instead, make a copy of the original, and make your modifications to the copy. You can then use a rewrite action and policy to swap the modified file for the original. For example:
add rewrite action act_login_form_replace replace_all "HTTP.RES.BODY(120000)" q{"custom_login_form_view.js"} -search q{text("gateway_login_form_view.js")}
add rewrite policy pol_login_form_replace "HTTP.REQ.URL.EQ(\"/vpn/index.html\")" act_login_form_replace
bind vpn vserver "AG vServer" -policy pol_login_form_replace -priority 200 -gotoPriorityExpression NEXT -type RESPONSE
You also need to make sure your modified file survives a reboot, so you need to also copy your file into /var/vpn/vpn/js.
Sam Jacobs is the Director of Technology Development at IPM, the longest standing Citrix Platinum Partner on the East Coast. With more than 25 years of IT consulting, Sam is a NetScaler customizations and integrations industry expert. He holds Microsoft MCSD, Citrix CCP-M and CCP-N certifications, and is the editor of TechDevCorner.com, a technical resource blog for IT professionals. He is one of the top Citrix support Forum contributors, and has earned industry praise for the tools he has developed to make NetScaler, StoreFront and Web Interface easier to manage for administrators and more intuitive for end users. Sam became a Citrix Technology Professional (CTP) in 2015. Sam can be reached at: sam.jacobs@ipm.com or on Twitter at: @WIGuru.