Citrix XD5 Power Shell Basics

Preview:

Citation preview

XenDesktop PowerShell SDK

Christian Gehring Principal Systems Engineer Citrix Systems, Germany

AUDIO:

• Hörbar über den Lautsprecher Ihres PCs

• oder über Telefoneinwahl: Österreich: +43 72 08 81 053

Deutschland +49 89 87 80 66 470

Schweiz: +41 22 53 31 127

Access Code und Audio PIN: in der Webinar-Konsole unter

Audio (“Use Telephone”) - Eingaben jeweils mit # abschliessen

Your host today …

Christian Gehring

Principal System Engineer

Jürgen Langfeld

System Engineer

• PowerShell Basics

• PowerShell Support for Citrix Products

• Managing XenDesktop with PowerShell

• Q&A

Agenda

PowerShell Basics

What is PowerShell?

PowerShell is an AUTOMATION

technology

Interactive Shell & Scripting Language

Build on top of .NET

Structured Commands (Cmdlets in Verb-Noun)

Pipeline Support

Real Objects instead of text

output

Command Completion

Security – Signing Script

• Set-ExecutionPolicy

• Restricted

• AllSigned

• RemoteSigned

• Unrestricted

• Bypass (v2)

Security - Group Policy

8

PowerShell Commands

Pronounced command-let

Verb-Noun Naming Structure as:

• Start-Service

• Get-Service

• Stop-Service

• Start-Transcript

• Get-Process

Cmdlet Parameters

Positional Parameter

Get-Eventlog –logname Application

Get-Eventlog Application

Prompting

Get-EventLog

Enough Characters to distinguish it

Get-Eventlog Application –newest 10

Get-Eventlog Application –new 10

Useful during interactive shell experience

Common Core Parameters

• Prompts user before taking any action that modifies the system

-Confirm

PS C:\> Stop-Service BITS -Confirm

Are you sure you want to perform this action?

Performing operation "Stop-Service" on Target "Background Intelligent Transfer

Service (BITS)".

[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):

Common Core Parameters

• Provides detailed information about the operation if the Cmdlet supports it.

-Verbose

PS C:\> Clear-Content c:\temp\temp.txt –verbose

VERBOSE: Performing operation "Clear Content" on

Target "Item: C:\temp\temp.txt".

Common Core Parameters

• Provides information about the changes that would occur, but does not make those changes

-WhatIf

PS C:\> Stop-Service BITS –WhatIf

What if: Performing operation "Stop-Service" on Target

"Background Intelligent Transfer Service (BITS)".

PowerShell Expressions

• Returns “Hello World” which is a string object “Hello World”

• Use it as your command line Calculator

((215/25) + 2) * 5

• Calculating how many CDs are required to backup my 12GB of data 12GB/640MB

Variables

Variables begin with $ sign

• $age = 30

• $Tag = “PowerShell Rocks!”

• $StringValue = [string]

No need to declare variables

Get-Variable show you currently available variables

Automatic Variables

Predefined Variables

Get-Variable

Set as soon as a PowerShell session is opened

Examples

• $home Full path to the home directory

• $LastExitCode Exit code of the last command

• $? Execution status of the last operation.

• $_ Contains the current pipeline object

Get-Help

• Including

• parameter information

• Usage

• Examples

• Descriptions of what the cmdlet does

Allows you to get help on any

Cmdlet

• Get-Help about*

• Get-Help about_foreach

To see all of the conceptual topics available

Get-command

• Includes

• Built-in CmdLets

• Functions

• Other cmdlets or functions added to the shell since it was started

Lists all the commands available

in the current PowerShell instance.

• List of all cmdlets that allow you to “get” something, you could enter:

• get-command –verb get

• Get-Command Stop-service -syntax

Allow filtering by noun or verb.

Get-member

Discover the different methods and properties available on an object in PowerShell

Can pass any item to this cmdlet

• Lists the members on the item

• Can filter the results to only get methods

• To get you the members on the Service objects

• Get-Service | get-member

Formatting

• get-process | format-list -property name, basepriority, priorityclass Format-list

• get-childitem | format-wide -column 3 Format-Wide

• get-service | format-table -property Name, DependentServices Format-Table

• Step 1 Create a Custom View in XML

• Step 2 Call the View from a command

• E.g. get-Process | format-custom -view MyView Format-Custom

Exporting

• Exports the output to CSV format

• E.g. Get-Service | Export-CSV MyServices.CSV

Export-CSV

• Exports the output to XML format

• E.g. Get-Service | Export-CliXML MyServices.XML

Export-CliXML

• Converts the output to HTML format

• E.g. Get-Service | ConvertTo-HTML | Out-File MyServices.html

ConvertTo-HTML

Editors for Scripting

• PowerGUI, a free graphical user interface and script editor for Microsoft Windows PowerShell! • http://www.powergui.org

• Windows PowerShell Integrated Scripting Environment (ISE). • Windows PowerShell ISE is a graphical user interface for Windows PowerShell

that lets you run commands, and write, edit, run, test, and debug scripts in the same window. It offers up to eight independent execution environments and includes a built-in debugger, multiline editing, selective execution, syntax colors, line and column numbers, and context-sensitive Help.

PowerShell - Editors

PowerShell - Editors

PowerShell Support for Citrix Products

• TechPreview available

• Will work on XA5 für W2k8 and Win2003 and CPS 4.5 with HRP03 on Win2003

• Covers most MFOM functionality

• Community Support only

PowerShell Support for XA5

• Full XA6 PowerShell SDK

• Eliminates the need of MFCOM

• Limitation • Access Filters were not provided

PowerShell Support for XA6

• XDCommands for XD4 • Very limited in functionality and stability

• Create, Manage Desktop groups

• XD5 full PowerShell Support • Heavy loaded and complex functionalities

• Not easy to use for Basic Admins

PowerShell Support for XD

• PowerShell Snapin comes with Console Installation

• Manual assembly registration required

• We recommend to use the MAPI instead of the cmdlet. Developers can access PVS via SOAP API.

PowerShell Support for PVS

• PowerShell Snapin covers all XenApi functionality

• Weak documentation and examples available

PowerShell Support for XenServer

Managing XenDesktop with PowerShell

• Start Windows PowerShell on your DDC

• Load all Citrix SnapIn„s • Add-PSSnapin Citrix*

• Verify all loaded Citrix SnapIn„s • Get-PSSnapin Citrix*

• List all Citrix commands • Get-Command -Module *citrix*

Preparing your environment

• Getting help for PowerShell Cmdlet„s • Get-Help <Cmdlet-Name>

• To get help for the Get-BrokerCatalog CmdLet type: • get-help Get-BrokerCatalog

• Displaying examples • get-help Get-BrokerCatalog –examples

• XD5 Command Reference • http://support.citrix.com/static/kc/CTX127254/help/index.htm

Working with PowerShell Help (get-help)

• Get-BrokerCatalog retrieves all Catalogs and their information's within the site.

Get-BrokerCatalog

• No time to learn PowerShell in-depth

• Too many thing‟s around

• Customer won‟t pay any scripting activities

• No budget to buy an automation Suite • For example: Matrix42.com

Admin‘s Challange

• Citrix Desktop Studio is the console for creating and managing Desktops

• The console is based on the PowerShell SDK

• Every action within the console is recorded as a PowerShell Script

• Easy Cut&Paste

Generate Code with Desktop Studio

• Ed York„s PowerShell Blog • http://community.citrix.com/blogs/citrite/edy

• XD5 Command Reference • http://support.citrix.com/static/kc/CTX127254/help/index.htm

Links

Recommended