Implicit Remoting Citrix DDC

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 5 years, 10 months ago.

  • Author
    Posts
  • #6105

    by i255d at 2013-01-24 07:14:51

    I was so excited to learn about Implicit Remoting to Exchange, but the very next second, I was trying to make it work with my Citrix Xendesktop DDC's.

    $citrix = New-PSSession -ComputerName Server321
    Invoke-Command -ScriptBlock { Asnp Citrix.* } -Session $citrix
    Enter-PSSession -Session $citrix

    I don't know how to get the Citrix cmdlets on my workstation. Any Ideas?

    I can see the cmdlets if I do this:

    Enter-PSSession -Session $citrix
    Get-Command –Module Citrix.*

    I want this to work like demonstrated in Exchange if possible.

    by DonJ at 2013-01-24 07:44:10

    You using v2 or v3?

    by i255d at 2013-01-24 08:06:08

    I have v2 on the Citrix Xendesktop box and v3 on my desktop.

    I would be open to any good blogs or contacts to people who are using the Citrix cmdlets too... I am working through them systematically trying to learn what I can.

    by DonJ at 2013-01-24 08:11:23

    So, from your client, establish a PSsession to the server. Then use Import-Module to load the module by name. Specify the PSsession object so it'll load from the server.

    You were using Enter-PSSession. Wrong command, is all.

    by i255d at 2013-01-25 07:27:05

    First I ender this:
    $citrix = New-PSSession -ComputerName server321
    Then I load the Citrix snapins (not modules):
    Invoke-Command -ScriptBlock { Asnp Citrix.* } -Session $citrix
    Have you done this with citrix? Is the asnp a module?
    Next I try import-module:
    Import-module -PSSession $citrix -Name Citrix*
    Import-module : Failure from remote command: Import-Module -Name 'Citrix*': The specified module
    'Citrix*' was not loaded because no valid module file was found in any module directory.
    At line:1 char:1
    + Import-module -PSSession $citrix -Name Citrix*
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ResourceUnavailable: (Citrix*:String) [Import-Module], FileNotFound
    Exception
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCo
    mmand

    by DonJ at 2013-01-25 07:46:26

    The in invoke-command isn't necessary. And, it isn't finding a module named Citrix. The module is probably not stored in a valid path. You may need to add the module location to the server PSModulePath environment variable.

    by i255d at 2013-01-25 08:50:56

    %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -ImportSystemModules
    This is the command in the shortcut.
    %HOMEDRIVE%%HOMEPATH%
    This is the Start in entry.
    When I am on the server this shortcut loads the citrix snapins. Is there a difference in the way this is done for modules or snapins?
    Does this info give any clues how to get this done? When I type import-modules, it seems to have a forced paramiter of name.

    by DonJ at 2013-01-25 08:57:19

    You can't implicitly remote a shortcut. You have to do the module. A shortcut can load a module from any arbitrary location; Import-Module can too (read its help) but it defaults to looking in the environment variable path.

    And things work entirely differently for snapins than for modules. You'd said this was a module; is that not the case? I don't have the Citrix stuff, so I'm relying on what you tell me to try and help out... What I've told you will only work for a module that's stored in the correct path.

    by i255d at 2013-01-25 11:43:41

    That is why I included the asnp Citrix.* in the invoke command to try and provide all the info that I have about how Citrix does there commands.
    I also thought that powershell.exe -importsystemmodules might give a clue.

    by DonJ at 2013-01-25 11:52:23

    Sadly, nope. Do this, on the server:

    Get-Module -List
    Get-PSSnapIn -reg

    And let me know what it does. I'm supposing this is a snapin, and the technique is a bit different and not always as reliable 🙁

    by i255d at 2013-01-25 13:21:49

    PS C:\Windows\system32> Get-pssnapin -Registered

    Name : Citrix.ADIdentity.Admin.V1
    PSVersion : 2.0
    Description : Manages Active Directory Computer Accounts

    Name : Citrix.Broker.Admin.V1
    PSVersion : 2.0
    Description : This PowerShell snap-in contains cmdlets used to manage the Citrix Broker.

    Name : Citrix.Common.Commands
    PSVersion : 2.0
    Description : Citrix Common Commands

    Name : Citrix.Common.GroupPolicy
    PSVersion : 2.0
    Description : Citrix Group Policy Provider

    Name : Citrix.Configuration.Admin.V1
    PSVersion : 2.0
    Description : Stores Service configuration information

    Name : Citrix.Host.Admin.V1
    PSVersion : 2.0
    Description : Manages Hosts, and Hypervisor Connections

    Name : Citrix.LicensingConfig.Admin.V1
    PSVersion : 2.0
    Description : Licensing Config PowerShell SnapIn

    Name : Citrix.MachineCreation.Admin.V1
    PSVersion : 2.0
    Description : Creates new Virtual Machines

    Name : Citrix.MachineIdentity.Admin.V1
    PSVersion : 2.0
    Description : Manages Virtual Machine Storage

    Name : PvsPsSnapIn
    PSVersion : 2.0
    Description : This is a PowerShell snap-in that includes cmdlets.

    by i255d at 2013-01-28 13:05:36

    I am still hoping someone can share with me how to use implicit remoting with Citrix snapins.

    by DonJ at 2013-01-28 13:11:49

    Ok. It's a bit trickier. I don't have these to test with, so you'll have to try and let me know.

    Assuming $citrix contains an open PSSession to the server, run:


    Import-PSSession -Session $citrix -Module Citrix.MachineIdentity.Admin.V1

    You will need to do that for each snap-in, or provide them as a comma-separated list. I don't believe the -Module parameter accepts wildcards (it isn't documented as doing so). Keep in mind that methods of objects won't work this way, because the methods get stripped off anything sent back to your computer for display.

    by i255d at 2013-01-28 13:38:58

    PS T:\> Import-PSSession -Session $citrix -Module Citrix.MachineIdentity.Admin.V1
    Import-PSSession : Running the Get-Command command in a remote session returned no results.
    At line:1 char:1
    + Import-PSSession -Session $citrix -Module Citrix.MachineIdentity.Admin.V1
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidResult: (:) [Import-PSSession], ArgumentException
    + FullyQualifiedErrorId : ErrorNoResultsFromRemoteEnd,Microsoft.PowerShell.Commands.ImportPSS
    essionCommand

    by DonJ at 2013-01-28 13:41:43

    Oh, wait, sorry – before that:


    Invoke-Command -Session $citrix -Script { Add-PSSnapin }

    Sorry, you had that in your earlier e-mail and I just forgot to add it into mine. So... start session, tell session to add snapin, import the snapin from the session.

    by powerschill at 2013-01-28 14:11:54

    Here is the code I just used on my environment. You can use wildcards for the module parameter. I also used the Prefix parameter to add "XD" to the cmdlets so that Get-BrokerSite becomes Get-XDBrokerSite. It makes it a lot easier to interact with the cmdlets.

    $XDCSession = New-PSSession -ComputerName
    Invoke-Command -ScriptBlock { Add-PSSnapin Citrix* } -Session $XDCSession
    Import-PSSession -Session $XDCSession -Module Citrix* -Prefix XD

    by i255d at 2013-01-29 05:16:02

    I think we are getting very close. It seems only a few commands have imported. What is -Prefix XD? It apears that Add-PSSnapin should be Citrix.*

    PS C:\> $Citrix = New-PSSession -ComputerName
    PS C:\> Invoke-Command -ScriptBlock { Add-PSSnapin Citrix.* } -Session $citrix
    PS C:\> Import-PSSession -Session $Citrix -Module Citrix* -Prefix XD

    ModuleType Name ExportedCommands
    ———- —- —————-
    Script tmp_1c420d51-3d00-401d... {Get-ProvTask, New-BrokerIcon, Get-PvsVmDBConnection, New-ConfigAdminist...

    PS C:\> Get-BrokerDesktop -AssociatedUserName dom\user
    The term 'Get-BrokerDesktop' is not recognized as the name of a cmdlet, function, script file, or operable program. Che
    ck the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:18
    + Get-BrokerDesktop < <<< -AssociatedUserName vsi\diverso
    + CategoryInfo : ObjectNotFound: (Get-BrokerDesktop:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    PS C:\> Get-Command -Module Citrix*
    Nothing comes back after this.

    If you look at the list of exported commands, it aprears to only be a few. I thought we had it :(.

    by powerschill at 2013-01-29 05:22:39

    In my example because I used the -Prefix XD you would have to type Get-XDBrokerDesktop. You can either do that or drop the -Prefix option from Import-PSSession.

    by i255d at 2013-01-29 06:06:14

    That was it. I must be the only person on the planet that wants this to work. I thought sense Citrix came out with their cmdlets so long ago, that there would be a lot more resources on how to use them.

    I tried with and without the prefix and got these errors both ways. I was hoping I could eventualy write some functions for my Help Desk for common problems.

    PS C:\> Get-BrokerDesktop
    Exception of type 'System.OutOfMemoryException' was thrown.
    + CategoryInfo : NotSpecified: (:) [Get-BrokerDesktop], SdkOperationException
    + FullyQualifiedErrorId : Citrix.XDPowerShell.Broker.UnexpectedException,Citrix.Broker.Admin.SDK.GetBrokerDesktopC
    ommand

    PS C:\> Get-BrokerDesktop
    Processing data for a remote command failed with the following error message: The WSMan provider host process did not r
    eturn a proper response. A provider in the host process may have behaved improperly. For more information, see the abo
    ut_Remote_Troubleshooting Help topic.
    + CategoryInfo : OperationStopped: (System.Manageme...pressionSyncJob:PSInvokeExpressionSyncJob) [], PSRe
    motingTransportException
    + FullyQualifiedErrorId : JobFailure

    by i255d at 2013-01-29 06:14:38

    It also seems the connection brakes fairly quickly even when I am just remoting into the DDC and running commands:
    PS C:\> $citrix

    Id Name ComputerName State ConfigurationName Availability
    — —- ———— —– —————– ————
    3 Session3 mpls21ddc321 Broken Microsoft.PowerShell None

    by DonJ at 2013-01-29 07:32:32

    PowerShell v2 is a little fragile. That's improved in v3.

You must be logged in to reply to this topic.