String Theory

Mastering the laws of physics with Windows PowerShell

Date:

09/01/2010 (Wednesday)
Time: 11:00AM – 1:30PM EDT

Description:
The User Group
meetings provide members with an opportunity to share and learn about
common issues and utilization of Server Based Computing technology.
Additional segments include troubleshooting tips, best practices,
enterprise solutions, technology trends, vendor presentations and
upcoming activities of interest.

Agenda:
11:00am: Registration
11:15am: Opening Remarks and Organization News
11:30am: Citrix Announcements – Product Updates, Beta Announcements & Tech Releases
11:45am: Lunch
12:00pm: Citrix XenDesktop – Jonathan O’Brien, Citrix Systems
1:00pm: Open Discussion

Location:
Microsoft Southeast Regional Office – Alpharetta
1125 Sanctuary Pkwy., Suite 300
Alpharetta, GA 30009
Phone: (678) 629-5700

Registration: http://www.acug.org/index.php?view=details&id=2%3Aseptember-atlanta-citrix-user-group-meeting&option=com_eventlist&Itemid=53

Spread the word:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • Add to favorites
  • email
  • FriendFeed
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • NewsVine
  • PDF
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

If you are a XenApp administrator you have no doubt utilized "qfarm.exe /load" to display the load on your Citrix XenApp Servers. These load values can identify issues with your servers in addition to determining which server is the least/most loaded in your farm. The one key component missing in this display is determining the reason for the load evaluator value.

 

image

This is where Windows PowerShell comes into play. If you haven’t already, you need to download the Citrix XenApp Commands Technology Preview (v2). You must be running XenApp 5 on either W2k3 or W2k8.

Note: XenApp 6 comes with this PSSnapin preinstalled as part of the core software. However as you will soon see the features are not the same.

Once you have installed the Citrix PSSnapin, power up PowerShell and run the following commands:

Add-PSSnapin Citrix.XenApp.Commands
Get-XAZone | Get-XAServer -onlineonly | Get-XAServerLoad | format-table -auto

The first line imports the XenApp commands. “Get-XaZone | Get-XAServer –onlineonly” is included to only return servers that are currently online. If the Get-XAServerLoad cmdlet is run and encounters a server that is offline, it will error out and stop the whole process. (Not the way I would have it handled, but that is for another day. ). Once it is run you will get a display similar to below.

image

As you can see you not only got the Load value, but you also got the value for each component that made up the rule.  In the first example you can see that the memory is at 11% which is contributing to the load of 1100. This information has been invaluable in a couple of different instances; one where the box was responding, but the Load Throttling was keeping the server from taking connections, and another where I discovered that Page Swaps were hammering one of the servers.

DISCLAIMER: The Get-XAServerLoad that is included with the PSSnapin in XenApp 6 does NOT include the Rules property. I discovered this fact while working on this blog post. I have no clue why it was removed, but I will try and find out.

Spread the word:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • Add to favorites
  • email
  • FriendFeed
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • NewsVine
  • PDF
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

As I was doing my daily RSS feed review I came across this great post @ http://nickapedia.com/2010/07/12/show-and-tell-first-vsphere-plugin-for-wordpress/ where he describes his vSphere WordPress plugin.  This excellent plugin allows you to display the stats for your vSphere/ESX environment and I knew this was a must have after completing my lab setup. You can see the plugin in action on the right hand bottom-most widget on my blog.

Spread the word:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • Add to favorites
  • email
  • FriendFeed
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • NewsVine
  • PDF
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

My Home Lab

No comments

I have been wanting to set up my own home lab for a very long time. Unfortunately home projects and such have always been higher on the priority list so I hadn’t much luck getting it started. Thankfully I have been able to build my home lab with many thanks to my wife for delaying some projects. Smile

The purpose of my lab is really simple. I want the ability to simulate many different environments for whatever project I am working on. I don’t need to support full sized production environments, such small base environments to operate against. For example one of my first projects will be setting up a XenApp server to develop some scripts against.

The obvious choice for the environment is for it to go virtual. I had toyed with the idea of using XenServer for my hypervisor since that is what I work with at work, but honestly having to pay for the memory optimization took it out of consideration. Memory is probably going to be the limiting factor in my environment. Thin Provisioning for local disks was another huge factor in my decision.

So now it was on to the hardware. I thought about buying a premade system, but decided I could get more bang for my buck by building my own and honestly a whole lot more fun.  It started with the case and power supply which I found on NewEgg on sale. The rest of the components I purchased from Micro Center.  It was the 4th of July and once I got started I didn’t want to have to wait to get building.

I overlooked the NIC card and realized after building it that the onboard NIC card wasn’t supported by ESXi so I ordered one from NewEgg and completed my system.

Currently I have a DC/DNS/DHCP server, a SQL server, a WSUS server, and a file server which serves as my lab infrastructure.

If you are interested here is the list of components in my Lab server and pictures from the building.

Component Manufacturer Model
Case Antec 902
Power Supply Antec EarthWatts EA750
Processor Intel I7-930
Motherboard Gigabyte GA-X58A-UD3R
Video Card BFG Tech 8400 GS
DVDROM Samsung OEM
Hard Drives Hitachi HD31000
Memory OCZ Technology Gold Edition 8GB (2 x 4GB) DDR3-1333 (PC3-10666) Dual Channel Desktop Memory
NIC Intel 1000 GT

P1000274P1000275P1000276P1000277P1000278P1000279P1000280P1000283P1000285P1000286

Spread the word:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • Add to favorites
  • email
  • FriendFeed
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • NewsVine
  • PDF
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

Today at work  it was brought to my attention that XenServer 5.6 dropped support for Windows XP 64 bit. I had only just recently started work with XenServer on a new project. This is a big deal for us because one of our VDI XenDesktop pilots is for a statistical application running on Windows XP 64 bit on XenServer 5.5.

Today at the end of the day the project manager was mentioning that that was a bad decision and even mentioned utilizing VMware as our backend for that environment.  So this evening I started doing some research and came to realize something interesting. XenServer 5.5 didn’t support 64 bit either.  So XenServer 5.6 doesn’t support 64 bit XP, but neither does 5.5.

Interestingly enough we have been having some problems with these images so now we have to wonder if it is because there is a reason Citrix doesn’t support it. If you are running Windows XP 64 bit images on your XenServers I would love to hear from you.

Spread the word:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • Add to favorites
  • email
  • FriendFeed
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • NewsVine
  • PDF
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

For this month’s meeting of the Atlanta PowerShell User Group I demoed my Windows PowerShell profile and I promised I would post it online. So here it is.


 

 

<#=============================================================================
Script Name:     Universal Profile
Created On:      05/22/2009
Author:          Mark E. Schill
File:            profile.ps1
Usage:           PS> . profile.ps1
Version:         1.2
Purpose:         Serves as a PowerShell Profile that can be used on multiple systems
Requirements:    <NONE>
Last Updated:    06/05/2010
History:
         1.2 06/05/2010 - Many Numerous changes.
                 1.1 10/11/2009 - Converted to strictly 2.0 and updated layout
              1.0 05/22/2009 - Initial Revision

         ** Licensed under a Creative Commons Attribution 3.0 License **
=============================================================================#>

<# This must be configured on systems where this script is run
 New-PSDrive -name Scripts -psprovider FileSystem -root <Location of Scripts Folder> -Description "Scripts Folder"
 . Scripts:\Profiles\profile.ps1
#>

# Main Function is just like the C# Main function. I use it to be be able to put functions last.
function Main
{

  # Grab some system Information to be displayed
  $PSVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$PSHome\Powershell.exe").FileVersion
  $IPAddress = @( Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object { $_.DefaultIpGateway } )[0].IPAddress[0]
  $Cert = Get-ChildItem -Path Cert:\CurrentUser\my -CodeSigningCert

    # Set up general aliases
  New-Alias -Name "Edit" -Value "edit-file" -force

  # Add to Module path so I can just do "ipmo Module"
  if ( !($Env:PSModulepath.Contains($(Convert-Path Scripts:\Core\Modules\Manual)) ))
  {    $env:PSMODULEPATH += ";" + $(Convert-Path Scripts:\Core\Modules\Manual) }

  # Import my auto modules.
  Get-ChildItem $(Convert-Path Scripts:\Core\Modules\Auto) | Where-Object {$_.PsIsContainer} | %{ Import-Module $($_.FullName) -Force }

  ## We also want to add our scripts directory to the path
  $ENV:PATH += Get-Item Scripts:\Core\Functions | ? { $_.PsIsContainer } | % {";$($_.FullName)" }
  $ENV:PATH += Get-ChildItem Scripts:\Core\Functions\* | ? { $_.PsIsContainer } | % {";$($_.FullName)" }

  # Machine Based Rules
  switch -regex ( $env:COMPUTERNAME)
  {
    ".+"
    {    }
    "L186404"
    {      Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue }
    "EINSTEIN"
    {
      Add-PSSnapin "NetCmdlets" -ErrorAction SilentlyContinue
      Add-PSSnapin "PowerGadgets" -ErrorAction SilentlyContinue
    }
  }

  # Host based rules
  switch ( $Host.Name )
  {
    "PowerShellPlus Host"
    {
      $Color_Label = "Cyan"
      $Color_Value_1 = "Green"
      $Color_Value_2 = "Yellow"
      $HostWidth = $Host.UI.RawUI.WindowSize.Width
    }
    'Windows PowerShell ISE Host'
    {
      $Color_Label = "DarkCyan"
      $Color_Value_1 = "Magenta"
      $Color_Value_2 = "DarkGreen"
      $HostWidth = 80

            Import-Module ISEPack 

            $PSISE.options.FontName = "Consolas"

      # watch for changes to the Files collection of the current Tab
      register-objectevent $psise.CurrentPowerShellTab.Files collectionchanged -action {
        # iterate ISEFile objects
        $event.sender | % {
          # set private field which holds default encoding to ASCII
          $_.gettype().getfield("encoding","nonpublic,instance").setvalue($_, [text.encoding]::ascii)
        }
      } | Out-null
    }
    default
    {
      $Color_Label = "Cyan"
      $Color_Value_1 = "Green"
      $Color_Value_2 = "Yellow"
      $HostWidth = $Host.UI.RawUI.WindowSize.Width

      if ( $env:PROCESSOR_ARCHITECTURE -eq 'AMD64')
      {        $NPP = "${env:ProgramFiles(x86)}\Notepad++\Notepad++.exe" }
      else
      {        $NPP = "$env:ProgramFiles\Notepad++\Notepad++.exe" }
      if (Test-Path $NPP) { Set-Alias -Name Edit-File -Value $NPP -Force } 

      # Initialize PowerTab
      & $(Convert-Path scripts:\Core\Includes\PowerTab\Init-TabExpansion.ps1) -ConfigurationLocation $(Convert-Path scripts:\Core\Includes\PowerTab)
    }

  }

  Record-Session # Start Session Recording
  Clear-Host

    $PreviousColor = $Host.UI.RawUI.ForegroundColor

  # Display relevant information
  Write-Host "ComputerName:`t`t" -ForegroundColor $Color_Label -nonewline
  Write-Host "$($env:COMPUTERNAME)" -ForegroundColor $Color_Value_2
  Write-Host "IP Address:`t`t" -ForeGroundColor $Color_Label -nonewline
  Write-Host $IPAddress -ForeGroundColor $Color_Value_2
  Write-Host "UserName:`t`t" -ForegroundColor $Color_Label -nonewline
  Write-Host "$env:UserDomain\$env:UserName" -ForegroundColor $Color_Value_2
  Write-Host "PowerShell Version:`t" -ForegroundColor $Color_Label -nonewline
  Write-Host $PSVersion -ForegroundColor $Color_Value_2
  Write-Host "Code Signing Cert:`t" -ForegroundColor $Color_Label -nonewline
  Write-Host $Cert.FriendlyName -ForegroundColor $Color_Value_2

  Write-Host "Snapins:`t`t" -ForegroundColor $Color_Label -NoNewline
  $StartingPosition = $Host.UI.RawUI.CursorPosition.X
  Write-Host "".PadRight(30,"-") -ForegroundColor $Color_Label
  Get-PSSnapin | Format-Wide -autosize | Out-String -Width $( $HostWidth -$StartingPosition -1 ) -stream | Where-Object {$_} | %{ Write-Host $($(" "*$StartingPosition) + $_) -foregroundColor $Color_Value_1} 

  Write-Host "Modules:`t`t" -foregroundcolor $Color_Label -noNewLine
  $StartingPosition = $Host.UI.RawUI.CursorPosition.X
  Write-Host "".PadRight(30,"-") -ForegroundColor $Color_Label

  Get-Module | Format-Wide -AutoSize | Out-String -Width $( $HostWidth -$StartingPosition -1 ) -stream | Where-Object {$_} |  %{ Write-Host $($(" "*$StartingPosition) + $_) -foregroundColor $Color_Value_1}
  Get-Module -ListAvailable | Format-Wide -Column 3 | Out-String -Width $( $HostWidth -$StartingPosition -1 ) -stream | Where-Object {$_} |  %{ Write-Host $($(" "*$StartingPosition) + $_) -foregroundColor $Color_Value_2} 

  Write-Host "Functions:`t`t" -foregroundcolor $Color_Label -noNewLine
  $StartingPosition = $Host.UI.RawUI.CursorPosition.X
  Write-Host "".PadRight(30,"-") -ForegroundColor $Color_Label
  Get-ChildItem Scripts:\Core\Functions\* -Recurse | Select-Object Name | Format-Wide -AutoSize | Out-String -Width $( $HostWidth -$StartingPosition -1 ) -stream | Where-Object {$_} |  %{ Write-Host $($(" "*$StartingPosition) + $_) -foregroundColor $Color_Value_1}  

  $Host.UI.RawUI.ForegroundColor =$PreviousColor
  Write-Host ""
  Write-Host ""

  # This should go OUTSIDE the prompt function, it doesn't need re-evaluation
    # We're going to calculate a prefix for the window title
  if(!$global:WindowTitlePrefix) {
    $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
    $p = New-Object System.Security.Principal.WindowsPrincipal($id)
    if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))
    {
      $global:WindowTitlePrefix = "PoSh (ADMIN) -"
    } else {
      $global:WindowTitlePrefix = "PoSh - "
    }
  }

  $LogicalDisk = @()
  gwmi Win32_LogicalDisk -filter "DriveType='3'" | % {
    $LogicalDisk += @($_ | Select @{n="Name";e={$_.Caption}},
    @{n="Volume Label";e={$_.VolumeName}},
    @{n="Used (GB)";e={"{0:N2}" -f ( ($_.Size/1GB) - ($_.FreeSpace/1GB) )}},
    @{n="Free (GB)";e={"{0:N2}" -f ($_.FreeSpace/1GB)}},
    @{n="Size (GB)";e={"{0:N2}" -f ($_.Size/1GB)}},
    @{n="Free (%)";e={if($_.Size) { "{0:N2}" -f ( ($_.FreeSpace/1GB) / ($_.Size/1GB) * 100 )}else{"NAN"} }} )
  } 

  $Host.UI.RawUI.ForegroundColor = $Color_Value_2
  $LogicalDisk | format-table -AutoSize | out-string
  $Host.UI.RawUI.ForegroundColor = $PreviousColor

  Get-SystemUptime
  Write-Host

  cd scripts:\

}

#Record all Powershell activities
function Record-Session
 {
  $MyPath = "$((Get-PSDrive Scripts).Root)\_Transcripts"
  if ( ! (Test-Path $MyPath ) ) { mkdir $MyPath > $null }
  $ComputerName = $env:ComputerName
  $Date = Get-Date -Format "yyyy-MM-dd"
  switch ( $Host.Name )
  {
    "PowerShellPlus Host"
    {      Start-Transcript -path "$MyPath\$ComputerName-$Date.log" -ea silentlycontinue }
    'Windows PowerShell ISE Host'
        {
            # PowerShell ISE does not support transcription
        }
        default
    {      Start-Transcript -path "$MyPath\$ComputerName-$Date.log" -append -ea silentlycontinue }

  }
}

function prompt
{

  Write-Host "$([char]0x0A7) " -NoNewline -ForegroundColor $Color_Label
  Write-Host ([net.Dns]::GetHostName()) -NoNewline -ForegroundColor $Color_Value_1
  Write-Host ' {' -NoNewline -ForegroundColor "Red"
  Write-Host (shorten-path (pwd).path) -NoNewline -ForegroundColor $Color_Label
  Write-Host '}' -NoNewline -ForegroundColor "Red"
  return ' '
}


function shorten-path([string] $path) {
  $loc = $path.Replace($HOME, '~')
  # remove prefix for UNC paths
  $loc = $loc -replace '^[^:]+::', ''
  # make path shorter like tabs in Vim,
    # handle paths starting with \\ and . correctly
  return ($loc -replace '\\(\.?)([^\\]{3})[^\\]*(?=\\)','\$1$2')
} 

function Get-SystemUptime ($computer = "$env:computername") {
  $lastboot = [System.Management.ManagementDateTimeconverter]::ToDateTime("$((gwmi  Win32_OperatingSystem -computername $computer).LastBootUpTime)")
  $uptime = (Get-Date) - $lastboot
  Write-Host "System Uptime for $computer is: " -NoNewline -ForegroundColor $Color_Value_2
  Write-Host $uptime.days -NoNewline -ForegroundColor $Color_Label
  Write-Host " days " -NoNewline -ForegroundColor $Color_Value_2
  Write-Host $uptime.hours -NoNewline -ForegroundColor $Color_Label
  Write-Host " hours " -NoNewline -ForegroundColor $Color_Value_2
  Write-Host $uptime.minutes -NoNewline -ForegroundColor $Color_Label
  Write-Host " minutes " -NoNewline -ForegroundColor $Color_Value_2
  Write-Host $uptime.seconds -NoNewline -ForegroundColor $Color_Label
  Write-Host " seconds" -ForegroundColor $Color_Value_2
}

# Call "Main" Function
. Main

# SIG # Begin signature block
# MIISBgYJKoZIhvcNAQcCoIIR9zCCEfMCAQExCzAJBgUrDgMCGgUA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20gQ2xhc3MgMiBQcmltYXJ5IEludGVybWVk
# aWF0ZSBPYmplY3QgQ0ECAgFLMAkGBSsOAwIaBQCgeDAYBgorBgEEAYI3AgEMMQow
# CKACgAChAoAAMBkGCSqGSIb3DQEJAzEMBgorBgEEAYI3AgEEMBwGCisGAQQBgjcC
# AQsxDjAMBgorBgEEAYI3AgEWMCMGCSqGSIb3DQEJBDEWBBTENjuc9oIG5MhJ4eyJ
# qiHgILA3KzANBgkqhkiG9w0BAQEFAASCAgAgghC7ISokY6Z/AfLAcMEstbuuA9wk
# b4lG7UKi/q9iFVbiBsSEN8eMbTjMScBzicb/CR9M46qFjEr7lgcUHNgcCikszrXT
# +stOHnF1UoaXWRkMYllY6sbExqyPGsJNjEOwqgOcD+FnEntacbqTTvA8pAw5V45i
# 9jDGHjZJv/XWFkhzxZxqTCXz44ZjhHvjJtNHlT5cbE0CxvE2WW9cnWw/S5zw+s1Y
# WbNn2W9gRqQJtwZXxCCakxRN2bzHHVAY1HHj6c7JkF1Pehx5rMIiMVWVDmCgNjgd
# VsOE7KhPY1hFMqfBEA44qGrW7NOWhaqeOjslaeMdv4u8qXrk1vOnOnDOUJUSSEgQ
# sj/qCxNPhFt1rKPw62yPmz4drUGDwhpMiNFu/8TgYY4DVWA8KIsQYHbM69KJo+i7
# Vt/p0SoMTCDL6EDnwvia4cwuKlVaxmYJ9wiIlE+5xoPn1x6QjoTVELaJTSNre3pB
# 05dCGUAS2h8Xc+DOBLCe24K3mD3HdBTkpFPe13ojeOkFqJScYLr4998lcCFk/U8j
# /Fl9CorlpWwgoVCCxHW757dv7THLviuK1t2oI6jpfgQzwTurXkGeiziEWYBiPnUM
# KXmD0ADxQehIEOF6m3PANy1sxlt5rG/Mg4YhB7MbfjBGrfsh7Vtgsgdk+oaqRao3
# OCh/9C4/oNBKpw==
# SIG # End signature block


Spread the word:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • Add to favorites
  • email
  • FriendFeed
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • NewsVine
  • PDF
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

I recently gave a presentation on the Citrix XenApp cmdlets for the Atlanta Citrix User Group.  For the presentation I wanted to show a real world example of the cmdlets in use. I decided to take a script that I wrote in July of 2007 ,which is still in use today, and convert it to use the new XenApp PowerShell cmdlets.  Shown below is the original script.

The purpose of the script is to automatically create a published desktop for our XenApp servers as they are built.  It uses MFCOM to perform the work.  One of the pain points in this script is that I had to actually copy the icon from an existing published desktop. This is a problem that I don’t have with the cmdlets.

#=============================================================================
#= Script Name:      Citrix Admin Desktop Publishing Script
#= Created On:       07/11/2007
#= Author:           Mark E. Schill
#= File:             Publish-Desktop.ps1
#= Usage:
#= Version:          1.0
#= Purpose:          Publishes an Admin Desktop on the server it is run from.
#= Requirements:       Must be run on a Citrix server in the same farm
#= Last Updated:     07/11/2007
#= History:
#=                   07/11/2007 1.0 - Initial Revision
#=
#=                        Copyright (C) 2007 Mark E. Schill
#==============================================================================

function Publish-Desktop( [string]$ServerName)
{
    $CPSReferenceApp = New-Object -comOBject MetaFrameCOM.MetaFrameApplication
    $CPSReferenceApp.Initialize(3, "Applications/Admin/Desktops/WMT13-CTX-DC1 Desktop")
    $CPSReferenceApp.LoadData($true)
    $CPSReferenceIcon = $CPSReferenceApp.WinAppObject.IconObject

    $ServerName = $ServerName.ToUpper()
    $CPSFarm = New-Object -ComObject MetaFrameCOM.MetaFrameFarm
    $CPSFarm.Initialize(1)
    $CPSApp = $CPSFarm.AddApplication(3)
    $CPSApp.AppName = "$ServerName Desktop"
    $CPSApp.Description = "Admin Desktop for Remote Administration"
    $CPSApp.ParentFolderDN = "Applications/Admin/Desktops"
    $CPSApp.PNFolder = "Admin\Desktops"
    $CPSApp.WinAppObject.DefaultInitProg = ""
    $CPSApp.WinAppObject.DefaultWorkDir = ""
    $CPSApp.WinAppObject.DefaultWindowColor = 4 # 32 Bit
    $CPSApp.WinAppObject.DefaultWindowType = 6 # MFWINWindowPercent
    $CPSApp.WinAppObject.DefaultWindowScale = 95 # 95%

    $CPSApp.WinAppObject.PNAttributes = 8
    $CPSApp.WinAppObject.SetIconBitmaps( $CPSReferenceIcon.IconMaskSize, $CPSReferenceIcon.IconMaskBitmap, $CPSReferenceIcon.IconDataSize, $CPSReferenceIcon.IconDataBitmap)
    $CPSApp.AddUser( 1, "CDC", 4, "CTX-Admins")
    $CPSApp.AddUser( 1, "CDC", 4, "CTX-Support")
    $CPSApp.SaveData()
    $CPSAppBinding = New-Object -ComObject MetaFrameCOM.MetaFrameAppSrvBinding
    $CPSAppBinding.Initialize(6,$ServerName,$CPSApp.DistinguishedName)
    if ($CPSAppBinding)
    {
        Write-Host "Publishing"$CPSApp.BrowserName"on $ServerName" -foregroundcolor Green
        $CPSApp.AddServer($CPSAppBinding)
        $CPSApp.SaveData()

    }
    else
    {
        Write-Host "Unable to create App Binding" -foregroundcolor red
    }

}

Publish-Desktop("$env:COMPUTERNAME")

Shown below is the new “script”. As you can see it is actually a one-liner if you take out the function stuff. Also I don’t have the icon issue because it automatically creates the correct icon.

function Publish-Desktop( [string]$ServerName)
{
	New-XAApplication -ApplicationType ServerDesktop -DisplayName "$ServerName Desktop" -FolderPath "Applications/Admin/Desktops" -Description "Admin Desktop for Remote Administration" -ClientFolder "Admin\Desktops" -WindowType "95%" -ColorDepth TrueColor -Accounts "$ServerName\Administrators" -Servernames $Servername
}
Spread the word:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • Add to favorites
  • email
  • FriendFeed
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • NewsVine
  • PDF
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

I am one of the guest judges for the Scripting Games 2010 occurring right now at http://2010sg.poshcode.org and http://blogs.technet.com/heyscriptingguy/. I am currently working on the Beginner Event 4 which asks the user to read the Environment Variables to get the number of processors in the machine.

This evening I am finding myself in constant conflict with my own principals as I grade these entries. In accordance with the spirit of the Scripting Games, I am grading the entries based on those guidelines including “Anything that goes beyond the bare minimum requirements of the scenario”, but it is taking all of my strength not to give them one star and write, “Dude, you know you can do that with one line.” These are games after all, so maybe I can convince the Scripting Guys next year to do the “2011 Scripting Reality Challenges”. What do you think?

Yours truly,

Mark

Spread the word:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • Add to favorites
  • email
  • FriendFeed
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • NewsVine
  • PDF
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

As promised here is my PowerPoint presentation and demo code for the presentation I gave at the Atlanta Citrix User Group titled “Managing XenApp with Windows PowerShell”

Presentation: Managing XenApp with Windows PowerShell

Demo Code: Demo.ps1

Spread the word:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • Add to favorites
  • email
  • FriendFeed
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • NewsVine
  • PDF
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

 Atlanta Citrix User Group – www.acug.org
Tuesday, April 27th

Topics of Discussion

Mark Schill, User Group Member, - Powershell Scripting XenApp

Mark is the WebMaster for the ACUG.org website and Charter Member of the current rendition of the Atlanta Citrix User Group.  Mark has been implementing and supporting Citrix Products in the Atlanta area for years and is a prolific PowerShell scripter.  MFCOM is out and Powershell is in, so come listen to Mark give the User Group a foundation of PowerShell scripting on XenApp.

Marcia Orea, Citrix Systems Senior SE – Whats new with XenApp 6.0 – Overview, Demo, and Q&A

Marcia Orea is a Senior Southeast SE for Citrix Systems and this will be her first presentation at an ACUG meeting.  Come hear Marcia tell the User Group whats new in XenApp 6.0!

The User Group meetings provide members with an opportunity to share and learn about common issues and utilization of Server Based Computing  technology.  Additional segments include troubleshooting tips, best practices, enterprise solutions, technology trends, vendor presentations and upcoming activities of interest. 

When: Tuesday,  April 27, 2010
          11:00am – 1:30 pm
          Lunch will be provided (BBQ) and sponsored by Citrix Systems, inc

Where: Citrix Systems Support Office
           2001 Westside Pkwy
           Suite 260
           Alpharetta, GA 30004

Registration:  Our ACUG Website is down so to register for this event please send an e-mail to events@ACUG.org or simply reply to this message.  Registration enables us get a count of who will be attending so we can get an accurate food and drink order in.

A successful User Group is a partnership between all members

Spread the word:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • Add to favorites
  • email
  • FriendFeed
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • NewsVine
  • PDF
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter
Powered by WordPress Web Design by SRS Solutions © 2010 String Theory Design by SRS Solutions