header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Powershell and Citrix
Last Post 16 Jan 2012 05:43 AM by Pierre Lacroix. 13 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
SynJunkieUser is Offline
Basic Member
Basic Member
Posts:126
Avatar

--
13 Aug 2008 05:36 AM

    Hi,

    I'm attempting to use Powershell to pull some interesting information from my citrix farm.  I have been trying to do this from my workstation using Brandon Shells citrix scripts.  I have not had much luck at all and I'm wondering if anyone know whether I should be running these scripts in Powershell from a citrix server rather than from a workstation.

    Thanks

    Lee

     

     

    Brandon Shell [MVP]User is Offline
    Basic Member
    Basic Member
    Posts:396
    Avatar

    --
    13 Aug 2008 06:52 AM
    Brandon Shell
    ----------------
    Microsoft Powershell MVP
    https://mvp.support.microsoft.com/profile/Brandon
    Blog: http://www.bsonposh.com
    Brandon Shell [MVP]User is Offline
    Basic Member
    Basic Member
    Posts:396
    Avatar

    --
    13 Aug 2008 06:53 AM
    As long as that is setup properly you can do either local or remote.
    Brandon Shell
    ----------------
    Microsoft Powershell MVP
    https://mvp.support.microsoft.com/profile/Brandon
    Blog: http://www.bsonposh.com
    Mark E. SchillUser is Offline
    New Member
    New Member
    Posts:32
    Avatar

    --
    13 Aug 2008 09:24 AM

    What are the issues that you are encountering?

     

    SynJunkieUser is Offline
    Basic Member
    Basic Member
    Posts:126
    Avatar

    --
    14 Aug 2008 07:26 AM

    Brandon,  I had read your article and checked impersonation on DCOM on a citrix server which was configured correctly.

     

    I copied your script into a file called ctx-run.ps1 and after running the error I got was:

    New-Object : Cannot load COM type MetaframeCOM.MetaFrameFarm.
    At C:\ctx-run.ps1:1 char:21
    + $mfFarm = New-object  <<<< -com "MetaframeCOM.MetaFrameFarm"
    You cannot call a method on a null-valued expression.
    At C:\ctx-run.ps1:2 char:19
    + $mfFarm.Initialize( <<<< 1)
    Get-Member : No object has been specified to get-member.
    At C:\ctx-run.ps1:4 char:13
    + $mfFarm | gm  <<<< # all the properties are there, but blank

     

    I'm guessing there is something very basic that I am doing wrong but I'm unsure what it is.

     

    Mark E. SchillUser is Offline
    New Member
    New Member
    Posts:32
    Avatar

    --
    14 Aug 2008 07:28 AM

    Did you install the Citrix Presentation Server SDK on your workstation?

    Mark

     

    SynJunkieUser is Offline
    Basic Member
    Basic Member
    Posts:126
    Avatar

    --
    14 Aug 2008 07:40 AM

    ahh..... now that looks better.

     

    Thanks for the help.

    Brandon Shell [MVP]User is Offline
    Basic Member
    Basic Member
    Posts:396
    Avatar

    --
    14 Aug 2008 07:59 AM
    The impersonation is a client thing not a server thing (unless you are using the server as the client)
    Brandon Shell
    ----------------
    Microsoft Powershell MVP
    https://mvp.support.microsoft.com/profile/Brandon
    Blog: http://www.bsonposh.com
    SynJunkieUser is Offline
    Basic Member
    Basic Member
    Posts:126
    Avatar

    --
    14 Aug 2008 08:32 AM

    Ok, that helps.  I can query a server in the farm that I specify when I installed the SDK but I never get anything back from querying the farm when i run scripts looking to list applications such as:

     

    # Farm Stuff

    $Farm = New-object -com "MetaframeCOM.MetaFrameFarm"
    $Farm.Initialize(1)

    $Farm.FarmName
    #$farm | Get-Member -type Properties
    $farm.Applications


    # Server Stuff

    $mfsrv = New-Object -ComObject MetaFrameCOM.MetaFrameServer
    $mfsrv.Initialize(6,$ENV:ComputerName)
    #$mfsrv | Get-Member -type Properties
    $mfsrv.Sessions | ft Servername,Username,AppName,ClientAddress -auto

     

    Maybe i'll reboot my PC after ammending the dcom settings as per your posts directions.

     

    Thanks

    SynJunkieUser is Offline
    Basic Member
    Basic Member
    Posts:126
    Avatar

    --
    21 Aug 2008 04:57 AM

    I didn't really get to much further into this but I did find that using PowerGUI allowed me to run scripts that interacted with my citrix farm well.  Maybe this is a layer 8 problem, i'll revisit it when I get a bit more of a handle on the basics.

     

    Thanks all for your help.

     

    Lee

    chrisUser is Offline
    New Member
    New Member
    Posts:1
    Avatar

    --
    11 Jan 2012 01:46 AM
    hello !
    I have a problem to create Policies Citrix with Powershell..

    I run this script:

    #Script To Create a New Citrix Policy

    Param($Server,$PolicyName,$PolicyDescription)
    if(!$PolicyDescription) {$PolicyDescription=$PolicyName}
    $type = [System.type]::GetTypeFromProgID("MetaframeCOM.MetaframeFarm",$Server)
    $mfarm = [System.Activator]::CreateInstance($type)
    $mfarm.Initialize(1)
    $NewPolicy = $mfarm.CreatePolicy(19,$PolicyName,$PolicyDescription)

    I get an error code:
    Exception calling "CreateInstance" with "2" argument(s)
    :"Value cannot be null.Parameter name:type"
    At X:\aidecitrix.ps1:8 char:44
    + $farm = [System.Activator] :: CreateInstance <<<< ($type)
    You cannot call a method on a null-valued expression.
    At X:\aidecitrix.ps1:9 char:18
    + $farm.Initialize <<<< (1)
    You cannot call a method on a null-valued expression.
    At X:\aidecitrix.ps1:10 char:33
    + $NewPolicy = $mfarm.CreatePolicy <<<< (19,$PolicyName,$PolicyDescription)


    And I copied your script :
    $mfFarm = New-object -com "MetaframeCOM.MetaFrameFarm"
    $mfFarm.Initialize(1)
    $mfFarm.FarmName # will return the Farm Name, but that is it.
    $mfFarm | gm # all the properties are there, but blank
    # But none of the properties provide any info
    $mfFarm.Admins # returns nothing

    I get an error code:
    New-Object : Cannot load COM type MetaframeCOM.MetaFrameFarm
    ...

    I have conducted your audit:
    http://support.citrix.com/article/CTX106303

    but still does not work ..

    I was wondering if should I install XenApp Server SDK and run Windows Powershell with Citrix or something else to do ...

    thank you for your answer
    christophe
    Marco Shaw (MVP)User is Offline
    Veteran Member
    Veteran Member
    Posts:1642
    Avatar

    --
    11 Jan 2012 02:54 AM
    Please start a new thread when you are bringing up something new.

    There aren't many Citrix/PowerShell users on this site. I would suggest you consult the Citrix communities:
    http://communities.citrix.com/

    I know they used to have a PowerShell forum, and likely still do.
    Marco

    *Microsoft MVP - Windows PowerShell
    https://mvp.support.microsoft.com/profile/Marco.Shaw
    *Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
    *Blog - http://marcoshaw.blogspot.com
    Mark E. SchillUser is Offline
    New Member
    New Member
    Posts:32
    Avatar

    --
    11 Jan 2012 02:17 PM
    What version is your Citrix farm?
    Pierre LacroixUser is Offline
    New Member
    New Member
    Posts:2
    Avatar

    --
    16 Jan 2012 05:43 AM
    Hello
    I have a problem for create a property to policies Citrix, i use Powershell ..
    I created a policies :

    
    $farm = new-Object -com “MetaframeCOM.MetaframeFarm”
    $farm.Initialize(1)
    $farm.FarmName
    $PolicyName= Read-Host "nom Strat&#233;gie"
    $PolicyDescription=$PolicyName
    $NewPolicy = $farm.CreatePolicy(19,$PolicyName,$PolicyDescription)
    $farm.$PolicyName
    


    But I can't have a group associated with this policies and to a printer session as this one ...
    thank you for your answer
    PIERRE
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer