Citrix XD5 Power Shell Basics

39
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

Transcript of Citrix XD5 Power Shell Basics

Page 1: Citrix XD5 Power Shell Basics

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

Page 2: Citrix XD5 Power Shell Basics

Your host today …

Christian Gehring

Principal System Engineer

Jürgen Langfeld

System Engineer

Page 3: Citrix XD5 Power Shell Basics

• PowerShell Basics

• PowerShell Support for Citrix Products

• Managing XenDesktop with PowerShell

• Q&A

Agenda

Page 4: Citrix XD5 Power Shell Basics

PowerShell Basics

Page 5: Citrix XD5 Power Shell 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

Page 6: Citrix XD5 Power Shell Basics

Command Completion

Page 7: Citrix XD5 Power Shell Basics

Security – Signing Script

• Set-ExecutionPolicy

• Restricted

• AllSigned

• RemoteSigned

• Unrestricted

• Bypass (v2)

Page 8: Citrix XD5 Power Shell Basics

Security - Group Policy

8

Page 9: Citrix XD5 Power Shell Basics

PowerShell Commands

Pronounced command-let

Verb-Noun Naming Structure as:

• Start-Service

• Get-Service

• Stop-Service

• Start-Transcript

• Get-Process

Page 10: Citrix XD5 Power Shell Basics

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

Page 11: Citrix XD5 Power Shell Basics

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"):

Page 12: Citrix XD5 Power Shell Basics

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".

Page 13: Citrix XD5 Power Shell Basics

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)".

Page 14: Citrix XD5 Power Shell Basics

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

Page 15: Citrix XD5 Power Shell Basics

Variables

Variables begin with $ sign

• $age = 30

• $Tag = “PowerShell Rocks!”

• $StringValue = [string]

No need to declare variables

Get-Variable show you currently available variables

Page 16: Citrix XD5 Power Shell Basics

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

Page 17: Citrix XD5 Power Shell Basics

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

Page 18: Citrix XD5 Power Shell Basics

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.

Page 19: Citrix XD5 Power Shell Basics

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

Page 20: Citrix XD5 Power Shell Basics

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

Page 21: Citrix XD5 Power Shell Basics

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

Page 22: Citrix XD5 Power Shell Basics

Editors for Scripting

Page 23: Citrix XD5 Power Shell Basics

• 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

Page 24: Citrix XD5 Power Shell Basics

PowerShell - Editors

Page 25: Citrix XD5 Power Shell Basics

PowerShell Support for Citrix Products

Page 26: Citrix XD5 Power Shell Basics
Page 27: Citrix XD5 Power Shell Basics

• 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

Page 28: Citrix XD5 Power Shell Basics

• Full XA6 PowerShell SDK

• Eliminates the need of MFCOM

• Limitation • Access Filters were not provided

PowerShell Support for XA6

Page 29: Citrix XD5 Power Shell Basics

• 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

Page 30: Citrix XD5 Power Shell Basics

• 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

Page 31: Citrix XD5 Power Shell Basics

• PowerShell Snapin covers all XenApi functionality

• Weak documentation and examples available

PowerShell Support for XenServer

Page 32: Citrix XD5 Power Shell Basics

Managing XenDesktop with PowerShell

Page 33: Citrix XD5 Power Shell Basics

• 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

Page 34: Citrix XD5 Power Shell Basics

• 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)

Page 35: Citrix XD5 Power Shell Basics

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

Get-BrokerCatalog

Page 36: Citrix XD5 Power Shell Basics

• 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

Page 37: Citrix XD5 Power Shell Basics

• 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

Page 38: Citrix XD5 Power Shell Basics

• 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

Page 39: Citrix XD5 Power Shell Basics