hchabria
asked on
PowerShell to test ICA connectivity
I want to check ICA connectivity with the XenApp 6 servers using PowerShell.
I have created .ica file for each server and want PowerShell to execute each .ica file in background with my saved username and password and log the result.
For example, we have two XenApp 6 servers.
XEN-1
XEN-2
I created two .ica files for each of the servers -
Notepad_XEN-1
Notepad_XEN-2
Is it possible to create a PowerShell script that will launch these two .ica files with my username and password in the background and store the result in a log file. The result should be like below-
Notepad_XEN-1 - Launched
Notepad_XEN-2 - Error
I have created .ica file for each server and want PowerShell to execute each .ica file in background with my saved username and password and log the result.
For example, we have two XenApp 6 servers.
XEN-1
XEN-2
I created two .ica files for each of the servers -
Notepad_XEN-1
Notepad_XEN-2
Is it possible to create a PowerShell script that will launch these two .ica files with my username and password in the background and store the result in a log file. The result should be like below-
Notepad_XEN-1 - Launched
Notepad_XEN-2 - Error
ASKER
Thanks for the script. However, it is providing error at the time of launching the .ica file (screenshot attached).
One thing I should mention that in our environment we have to accept the company provided security message that pops up before launching any of the published applications (screenshot attached).
Please help.
One thing I should mention that in our environment we have to accept the company provided security message that pops up before launching any of the published applications (screenshot attached).
Please help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the link. It can also fulfill my requirement as I just want to check whether the ICA connection with the XenApp servers are Okay or not.
However, I am facing problem with the script. I am getting the below error while running the script. As I am not that much expert in PowerShell can you please help me out to resolve this error?
I am providing the full script also.
However, I am facing problem with the script. I am getting the below error while running the script. As I am not that much expert in PowerShell can you please help me out to resolve this error?
I am providing the full script also.
###########################################################################
#
# NAME: Test-ICA.ps1
#
# AUTHOR: Leon van Efferen
#
# E-MAIL: leon@efferen.nl
#
# COMMENT: Test ICA port for correct response.
#
# VERSION HISTORY:
# 1.0 4-7-2012 - Initial release
#
###########################################################################
param(
[string] $ComputerName = "",
[int] $port = 1494
)
[string] $output = ""
## Read output from a remote host
function GetOutput
{
## Create a buffer to receive the response
$buffer = new-object System.Byte[] 1024
$encoding = new-object System.Text.AsciiEncoding
$outputBuffer = ""
$foundMore = $false
## Read all the data available from the stream, writing it to the
## output buffer when done.
do
{
## Allow data to buffer for a bit
#start-sleep -m 100
## Read what data is available
$foundmore = $false
$stream.ReadTimeout = 250
do
{
try
{
$read = $stream.Read($buffer, 0, 1024)
if($read -gt 0)
{
$foundmore = $true
$outputBuffer += ($encoding.GetString($buffer, 0, $read))
}
} catch { $foundMore = $false; $read = 0 }
} while($read -gt 0)
} while($foundmore)
$outputBuffer
}
## Open the socket, and connect to the computer on the specified port
#write-host "Connecting to $ComputerName on port $port"
trap { Write-Error "Could not connect to remote computer: $_"; exit }
$socket = new-object System.Net.Sockets.TcpClient($ComputerName, $port)
$stream = $socket.GetStream()
$writer = new-object System.IO.StreamWriter $stream
## Receive the output that has buffered so far
$SCRIPT:output += GetOutput
## Close the streams
$writer.Close()
$stream.Close()
if ($output -match "ICA") {$result = "Success"}
Else {$result = "Failed"}
$obj = new-object psobject
$obj | add-member noteproperty ComputerName ($ComputerName)
$obj | add-member noteproperty Status ($result)
$obj | add-member noteproperty Output ($output)
$obj
Try removing [int] and see if it works
ASKER
Thanks so much. After removing [int] it's working fine.
I am using following command to test ICA for multiple servers and it's working fine.
Get-Content C:\Servers.txt |% {.\Test-ICA.ps1 -ComputerName $_ -TimeOut } | Out-File C:\ICAResult.txt
How can I run this command through batch file?
I am using following command to test ICA for multiple servers and it's working fine.
Get-Content C:\Servers.txt |% {.\Test-ICA.ps1 -ComputerName $_ -TimeOut } | Out-File C:\ICAResult.txt
How can I run this command through batch file?
There's a couple of really easy ways to do this with EdgeSight. If you enable Active Application Monitoring, you can test synthetic app launches. Or, within XenApp, if you set up Health Monitoring within your XenApp farm (the default install only provides 4 tests), you can see the output from the ICA test within EdgeSight.
ASKER
Though we have EdgeSight, we don't have Active Application Monitoring installed.
We have already configured Health Monitoring for all XenApp servers but how do we check the ICA test withing EdgeSight? Can you please let me know the steps?
We have already configured Health Monitoring for all XenApp servers but how do we check the ICA test withing EdgeSight? Can you please let me know the steps?
Thanks a lot. The script mentioned above (after removing the Int) works perfectly.
TestUser01 --- your username
MyUsersPassword ---- your password
DOM --- your domain
The result files are stored in c:\XEN1_....txt
Run in powershell the following:
Replace the exact location of ICA Client on your machine. Open Powershell x86 (32bit version )
-----------------------
[System.Reflection.Assembl
$ICA = New-Object WFICALib.ICAClientClass
$ICA.Address = "Notepad_XEN-1"
$ICA.Username = "TestUser01"
$ICA.SetProp("Password","M
$ICA.Domain = "DOM"
$ICA.Application = ""
$ICA.Launch = $true
$ICA.OutputMode = [WFICALib.OutputMode]::Out
$ICA.DesiredHRes = 1024
$ICA.DesiredVRes = 768
$ICA.DesiredColor = [WFICALib.ICAColorDepth]::
Register-ObjectEvent -InputObject $ICA -EventName OnConnectFailed -Action { "$ICA.Address : Connection failed..." | Add-content c:\XEN1_failed.txt }
Register-ObjectEvent -InputObject $ICA -EventName OnLogonFailed -Action { "$ICA.Address : Logon failed... | add-content c:\XEN1_failed.txt" }
Register-ObjectEvent -InputObject $ICA -EventName OnLogon -Action { "$ICA.Address : User has logged on..." | add-content c:\XEN1_launched.txt}
$ICA.Connect()