Hi,
I have a logon script that for historic reasons is written in VBScript. However, due to Citrix Xen 6, I have had to use powershell to obtain the thin client name using Xen 6 APIs. The powershell script is 'embedded' into the VBScript. No .PS1 file.
The code executes successfully for an administrator, but doesn't return the thin client name when executed as an ordinary user. If I was running the .PS1 file, I would expect the Set-ExecutionPolicy command to solve the issue. All though we have tried setting executionPolicy to both RemoteSigned and Unristricted we haven't had any luck.
So the question is, does anyone know if there is a way and if so could they point me in the right direction, or do we have to call the .ps1 script?
Here is the VBScript code:
If anyone could shed any light on how one might execute this code as an ordinary user, I'd be most grateful for any assistance.
Many thanks
W.
I have a logon script that for historic reasons is written in VBScript. However, due to Citrix Xen 6, I have had to use powershell to obtain the thin client name using Xen 6 APIs. The powershell script is 'embedded' into the VBScript. No .PS1 file.
The code executes successfully for an administrator, but doesn't return the thin client name when executed as an ordinary user. If I was running the .PS1 file, I would expect the Set-ExecutionPolicy command to solve the issue. All though we have tried setting executionPolicy to both RemoteSigned and Unristricted we haven't had any luck.
So the question is, does anyone know if there is a way and if so could they point me in the right direction, or do we have to call the .ps1 script?
Here is the VBScript code:
Code:
Function getTerminalName()
Set oShell = CreateObject("WScript.Shell")
strDomain = oShell.ExpandEnvironmentStrings("%USERDOMAIN%")
strUsername = oShell.ExpandEnvironmentStrings("%USERNAME%")
strAccount = strDomain &"\"& strUsername
pscommand = "Add-PSSnapin citrix* ; $sessions = Get-XASession -Account " & strAccount & " | ? {$_.ServerName -eq (gc env:computername)} ; foreach ($Item in $sessions) { write-host $Item.ClientName } ; exit $sessions "
cmd = "powershell.exe -noprofile -windowstyle Hidden -command " & pscommand
Set tcName = oShell.Exec(cmd)
tcName.StdIn.Close
tcName = Left(tcName.StdOut.ReadAll,3)
getTerminalName = tcName
End Function
If anyone could shed any light on how one might execute this code as an ordinary user, I'd be most grateful for any assistance.
Many thanks
W.