Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running from VBScript logon script Permissions

Status
Not open for further replies.

woter324

Technical User
Jan 26, 2007
179
GB
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:

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.
 
From your description, it doesn't sound like an Execution Policy issue. That only controls whether scripts can run or not. Execution Policy does not affect running commands directly, such as your embedded command.

It seems more like a permissions issue with non-Administrator accounts. Maybe they can't add the Citrix snap-in, or if they can then maybe they can't read the thin client name information.

Can you set up a test non-Administrator account that could access Powershell interactively? Then you could run those PS commands and maybe see where the failure occurs. I don't know anything about Xen 6 so can't offer any help beyond that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top