Blog posts tagged with 'powershell'


09 Jul 2008 11:51 AM EDT

In a previous post about use cases for IT Process Automation and Workflow Studio I mentioned building a workflow to facilitate a "Green Data Center". Workflow Studio can help with this by managing the workloads on your servers and turning servers off when they are not needed. In this post I will show you 2 ways that you can shutdown a windows server from a workflow (these are native to Windows, if you are using 3rd party tools let me know in the comments.)

  1. "Launch Process" Task - Windows has a built-in utility (shutdown.exe) that can shutdown computers on your network remotely. Using the Workflow Studio "Launch Process" task allows you to call the shutdown command and pass it the arguments you want for your needs. You can see all the arguments by typing "shutdown /?" at your command line and there are several detailed write-ups on Microsoft's site (here and here for example).
  2. "PowerShell Command" Task - WMI has a class (Win32_OperatingSystem) that can be used to shutdown computers as well. Workflow Studio has a task called "Get WMI Info" that is designed to query WMI classes, but unfortunately it cannot call methods on the WMI classes. We will need to leverage a scripting environment like PowerShell to be able to call the method (or you could use VBScript.) Fortunately, in PowerShell we only need one line of code to achieve this:

(Get-WmiObject -Class Win32_OperatingSystem -ComputerName <computer name>).shutdown()

Add that line of code to your "PowerShell Command" task and replace the <computer name> with the name of the computer you would like to shutdown.

In this post I looked at shutting down a Windows Server, but in future posts I will expand this and look at how to use Wake On LAN to power machines back on, how you can manage power on a XenServer host machine, and how you can integrate this with logic to monitor when to shut down and start up your servers.
 
Power management is an area that we are working diligently on internally to build out a robust set of tasks for you. Have you tried automating server shutdown processes in your data center? What issues do you face? What kinds of inputs do you want to be able to leverage to determine when to shutdown a server?

07 Jul 2008 01:14 PM EDT

The PowerScripting podcast including the interview with myself on Workflow Studio and PowerShell has been posted:

 http://powerscripting.wordpress.com/2008/07/07/episode-32-citrix-does-powershell/

The interview with me starts at 15:30 in.

Enjoy!

01 Jul 2008 10:13 PM EDT

In previous posts I discussed how to build a new workflow from a template we included in the tech preview (see Building Your First Workflow) and how to output objects to an XML file for debugging so you can understand the workflow (see Debugging Your Workflow). In this post I will answer the question posed in that first post of how you could modify the sample workflow to only show services that are set with a Startup Type of something other than Disabled. The answer to this question takes you into one of the areas where you can extend Workflow Studio to do things that aren't "built-in" to the product.

There are 3 main ways that Workflow Studio can be extended:

  1. Build templates and share with others - This is the easiest way for you to extend Workflow Studio, all you have to do is build a workflow and choose "File...Save As Template" and then share it with someone else. Citrix has a site set up for you to upload and share the templates you build. Upload Your Workflow Templates
  2. Create new Task Libraries - The left side of Workflow Studio is a set of libraries that we include with the product to integrate with Citrix products, Virtual Machine Manager, and Windows in general. There will be tools available for anyone interested to build their own integration to other products. These tools are not available publically yet, so if anyone is interested in building task libraries on top of Workflow Studio please contact me.
  3. Leverage support for 'extensible' tasks - Workflow Studio has native support for you to embed PowerShell scripts, call VBScript, and run WMI queries as tasks as well as run Windows applications and command files.

This last area is the topic for this post. Here is a screenshot with these extensible tasks highlighted:

 

From top to bottom in the picture we have:

  • Command Script - allows you to run a Windows command (or specify a .bat or .cmd file), optionally specify parameters and get back the text of the command session
  • Get WMI Info - allows you to run WMI queries and get back the results
  • Launch Process - allows you to run a Windows executable (there is also a Start Process that lets you schedule executables to be run)
  • Windows Script - allows you to run VBScript or JScript directly (or call a script file)
  • PowerShell Command - allows you to run a PowerShell cmdlet
  • PowerShell Script  - allows you to run PowerShell script directly (or call a script file)

As you can see there are lots of ways to leverage Workflow Studio to complete tasks beyond the obvious, included ones. This could allow an admin to document existing scripts by turning them into workflows providing a visual record of how the process flow is structured and making complex scripts more easy to update as the process flow changes later.

Alright, back to the original problem - how do we modify our sample workflow to hide services that are set to disabled? After some searching around we find that the WMI query Win32_Service provides us with the same basic object, but with additional info like the Startup Type. By modifying our workflow to replace the "Get-Service" task with a "Get WMI Info" task and setting its "WMI Class" property to "Win32_Service" we now have an object that provides everything we need. One thing to note - the "Status" property that we were using on Get-Service is called "State" on the WMI object so we need to change our "Where-Object" to reflect that. The new Where-Object filter would be:$.State -eq "Stopped" -and $.StartMode -ne "Disabled"

The syntax for this filter follows PowerShell syntax so any PowerShell guide will help you with the syntax. Play around with this - hook up an "Export To XML" task to the WMI result so you can see all the properties and let me know what you think.
 

01 Jul 2008 03:18 PM EDT

I met Hal Rottenberg at TechEd this year and found out about his podcast on PowerShell (among the many other things he works on.) He mentioned Workflow Studio on episode 30 (at about 22:50 in):

http://powerscripting.wordpress.com/2008/06/22/episode-30-teched-report/

I am going to do an interview with Hal on Workflow Studio for an upcoming show so stay tuned...

12 May 2008 03:46 PM EDT

If you are attending IT professionals TechMentor event this week in Orlando then I would recommend you go and check out Bradon Shell's session on "Automating Citrix Server Administration with Windows PowerShell"

"In this session you'll learn how to use Powershell to make Citrix server management easier. We'll also walk through the Citrix road map and how Powershell fits in. We will cover several different common administrative tasks and show how Powershell can make these tasks faster and easier to perform, including publishing applications, unpublishing applications, getting application information, and getting servers online. We'll look at using the PowerShell pipeline, and see how to make your scripts output information that can be piped to other scripts. Finally, you'll learn how to use MFCOM, get information from it, and look at some of the gotchas you'll need to be aware of when dealing with it"

Brandon and I have recently done a webinar on PowerShell and Citrix MFCOM. You can view the Webinar at this URL
https://www1.gotomeeting.com/register/114744868

UPDATE:
I have got several emails asking me if there will be any session on PowerShell and MFCOM during Citrix Synergy event . There is no specific session on PowerShell and MFCOM but we have speakers giving advance classes on MFCOM SDK and Hands on training with MFCOM SDK during Synergy. If you still have questions regarding PowerShell and MFCOM then come by during my Geek Speak session and I will try my best to answer them

30 Apr 2008 04:08 PM EDT

I want to thanks everyone who attended the webinar yesterday. If you missed the webinar then you can watch the recording at the following URL https://www1.gotomeeting.com/register/114744868

You can also download the slide deck here Dowload link
If you are interested in learning PowerShell then subscribe to Brandon Shell rss feed. I totally love the way he explains PowerShell concepts.

I am going to send out a more detailed survey to everyone who attended the webinar. Your feedback will help us determine future webinars and chats.

Would you like to see an advance PowerShell and MFCOM webinar? Choose
Yes
No
How would you rate yesterday's webinar on a scale to 1 to 5 with 5 being Awesome? Choose
1 Totally sucked
2 Just OK
3 Good stuff
4 Great.
5 Awesome

Please let me know via comments what SDK and technology webinar you would like to see in future. I will try my best to get the experts do it for CDN members.

21 Apr 2008 11:24 AM EDT

Brandon Shell (http://bsonposh.com) and I are going to do a free webinar on PowerShell and Citrix

UPDATE : Tuesday 29th April 1PM - 2PM EST.

UPDATE 28th April : International direct dial + 1 617 801 6700

We are targeting audiences with following skill.
Basic Powershell, Basic Citrix Admin Skills and Basic MFCOM experience in VB script.

Here is the rough agenda for the webinar

Powershell Basics (about 20 mins)

Object Based
Self Teaching Get-Help , Get-Command, Get-Member

  • Properties
  • Methods
    New-Object
  • ComObject
  • .NET Class

Managing Citrix Servers via PowerShell and MFCOM (about 20 mins)

Most Properties Return Objects (like Servers, Applications, Sessions)
Creating MFCOM object in Powershell
$variable = New-Object -com <MFCOM COM Name>
Examples
$mfobject = New-object -com 'MetaframeCOM.MetaFrameFarm'
$mfobject.Initialize(<int parameters>)
With just these two lines you can start exploring you Citrix Environment
$mfFarm = New-object -com 'MetaframeCOM.MetaFrameFarm'
$mfFarm.Initialize(1)
Getting Key Info To get From Farm Object
$mfFarm | Get-Member -MemberType Property # Gets just Properties
Admins
Applications
FarmName
Servers
Sessions
LicenseServer
Printers
Zones

Space is limited
Reserve your Webinar seat now at:
https://www1.gotomeeting.com/register/114744868

20 Apr 2008 03:11 PM EDT

Citrix Workflow Studio unlocks the potential in Microsoft PowerShell and the Windows Workflow Foundation by providing an easy to use, graphical interface for workflow composition that virtually eliminates scripting. Citrix WFS can now leverage the use of PowerShell to manage IIS7 7.0 through the use of the IIS 7.0 PowerShell Provider.

If you want to use the IIS 7.0 PowerShell Provider in an existing PowerShell command window you have to register the IIS snap-in manually. You can do this by simply executing the IISConsole.PSC1 file located in the "$env:programfiles\IIS\PowerShellProvider" directory:

PS C:\> & "$env:programfiles\IIS\PowerShellProvider\iisConsole.psc1"


The IIS 7.0 PowerShell Provider is a PowerShell Snap-In that allows you to manage IIS7 configuration and run-time data. It gives easy access to Web-Sites, Application Pools, Web Applications, Virtual Directories, request in flight, Worker Processes and .NET Application Domains within Worker Processes.


• Create Web-Sites, Web Applications, Virtual Directories and Application Pools
• Change Simple Configuration Properties on Web-Sites, Application Pools, Web Applications and Virtual Directories
• Add and Change Complex Configuration Settings
• Query Run-time Data (Web-Site State, Application Pool State, Currently Executing Requests)
• Execute Advanced Configuration Tasks, Scripting, Integration with other PowerShell Snap-Ins and features
• Search and Discover Configuration Settings

You can use the IIS 7.0 PowerShell Provider in Citrix Workflow Studio through the use of the built in task support for Windows PowerShell. The "Add-PSSnapin", "PowerShell Command", and "PowerShell Script" tasks are provided as out of the box tasks for the use of interacting with Windows Powershell in Citrix Workflow Studio.



Download at Source:

PowerShell Provider for IIS 7.0 (x86)
PowerShell Provider for IIS 7.0 (x64)






14 Apr 2008 03:52 PM EDT

Citrix SDK guru's have converted more top downloaded MFCOM VB scripts to PowerShell-MFCOM Scripts. Bradon Shell has created 3 more PowerShell Scripts which are really useful.

*Get-CitrixApplication.ps1 (Powershell)
Returns Citrix Application Objects for AppName passed or RegEx

*Set-CitrixServerLogon.ps1 (Powershell)
Sets the Server to Enable or Disable Logons

*Get-CitrixAppServer.ps1 (Powershell)
Gets All the Servers for Specific App

If you are learning PowerShell then I highly recommend subscribing to his blog at http://bsonposh.com/.

Jason Conger one of the Citrix SDK guru's has also contributed a really cool MFCOM-PowerShell script.

Find-App.ps1

Here is a description of the script
"If you have a lot of published applications in several nested folders, it can be a challenge to locate exactly which particular folder contains a particular application. This script takes a parameter as a search pattern. The script then searches the published application directory structure and returns the full path to all applications that match the search pattern parameter. This saves time clicking through all the folders trying to find a published application."

If you are a Citrix SDK guru then feel free to contact me via comments or email. I would love to hear your experiences with our SDKs.

Vishal G
http://community.citrix.com/cdn/script-exchange/

10 Apr 2008 03:49 PM EDT
posted by Rich Crusco

I have put together a list of posts on Windows PowerShell resources that I have been collecting, that I use to help start people in the right direction when diving into Windows PowerShell. I hope you find the following list of reference material as useful as I have.

Windows PowerShell 1.0 - Installation Files
Windows PowerShell 1.0 - Documentation Pack
Windows PowerShell 1.0 - Quick Reference
Windows PowerShell 1.0 - Graphical Help File
Windows PowerShell 1.0 - How it Works
Windows PowerShell 1.0 - In Action
Windows PowerShell 1.0 - Converting VBScript Commands
Windows PowerShell 1.0 - Cmdlets and PSCmdlets
Windows PowerShell 1.0 - How to Create a Cmdlet
Windows PowerShell 1.0 - Snap-ins
Windows PowerShell 1.0 - How to Register Cmdlets, Providers, and Host Applications
Windows PowerShell 1.0 - Cmdlet Development



Here is a link to the Windows PowerShell 1.0 collection based on the Tag:

Windows PowerShell 1.0 - The Reference Collection  



Page: 1 2  Next >>