I’ll write this up at more length soon on blogs.splunk.com, but in the meantime, here’s a script that I just wrote that will help you to assign the permissions needed for Splunk for VMware.

Powershell

One of my most favoritest things about PowerShell v3 (which just hit release candidate) is the new Integrated Script Environment (ISE). Microsoft has come a long way, and while it’s not perfect (the 3rd party editors still have many advantages), this is the first version that I consider worthy enough to spend a significant portion of my time in. For me all they had to do is kill off the split-pane input/output design which I LOATHED and maybe add a feature or two. But Microsoft didn’t stop there. Here’s the list of new goodness ripped from the readme included when you hit F1:

 

New features in Windows PowerShell ISE for this release

Many new features and improvements have been added to Windows PowerShell ISE for Windows Server 2012.

Intellisense. Intellisense, an auto-completion assistance feature that is similar to that found in Visual Studio, is now part of Windows PowerShell ISE. Intellisense displays clickable menus of matching cmdlets, parameters, parameter values, files, or folders as you type.

Add-on tools. Windows PowerShell ISE now supports add-on tools, which are Windows Presentation Foundation (WPF) controls that are added by using the object model. Add-on tools can be displayed in the console by using either a vertical or a horizontal pane. Multiple add-on tools in a pane are displayed as a tabbed control. A maximum of 20 user-defined add-on tools are allowed. You can also add or remove add-on tools that are produced by third parties. For more information about how to import or remove add-on tools, see Windows PowerShell ISE operations content on the web.

Restart Manager and Auto-save. Windows PowerShell ISE now automatically saves your open scripts every two minutes. To change the automatic saving interval, run the following in the console pane: $psise.Options.AutoSaveMinuteInterval. If Windows PowerShell ISE stops working or if the operating system is restarted, when you restart Windows PowerShell ISE it recovers scripts that were open in the last session, even if the scripts were not saved.

Console pane. The separate command and output panes that were available in the first release of Windows PowerShell ISE have been combined into a single console pane. The console pane is similar in function and appearance to a typical Windows PowerShell console, but includes the following enhancements. Most of these are described in this topic.

Syntax coloring for input text (not output text)

Intellisense

Brace matching

Error indication

Full Unicode support

F1 context-sensitive Help

Ctrl+F1 context-sensitive Show-Command

Complex script and right-to-left support

Font support

Zoom

Line-select and block-select modes

Preservation of typed content at the command line when you press the Up arrow to view history in the console

Command-line switches. If you start Windows PowerShell ISE from the command line, (Powershell_ise.exe) you can now add the following new command-line switches.

-NoProfile: Starts Windows PowerShell ISE without running $profile.

-Help: Displays a Help window.

-mta: Starts Windows PowerShell ISE in multithreaded apartment mode. (The default is STA.)

Other Windows PowerShell ISE editing features adapted from Visual Studio:

Brace matching. Windows PowerShell ISE now includes brace matching and highlighting (for example, using the Go to Match command locates the closing brace, if you have an opening brace selected).

Outline view. The script pane now supports outlining, which allows collapsing or expanding sections of code by clicking plus or minus signs in the left margin. You can use either braces or #region and #endregion tags to mark the beginning or end of a collapsible section.

Parse error display. Parse errors are now indicated by using red underlines. When you hover over an indicated error, Tooltip text displays the problem that was found in the code.

Zoom. The zoom percentage of the console’s content can be set by using the zoom slider (in the lower right corner of the Windows PowerShell ISE window), or by entering the command $psise.options.Zoom in the console pane.

Rich text copy and paste. Now, copying to the clipboard in Windows PowerShell ISE preserves the font, size, and color information of the original selection.

Block selection. You can select a block of text by holding down the ALT key while selecting text in the script pane with your mouse, or by pressing Alt+Shift+Arrow.

New Help viewer window. If you press F1 when your caret is in a cmdlet, or you have part of a cmdlet highlighted, the new Help viewer opens context-sensitive Help about the highlighted cmdlet. To display Windows PowerShell About Help, type operators in the console pane, and then press F1. Before you use this feature, download the most current version of Windows PowerShell Help topics from the Microsoft website. The simplest method of doing this is to run the Update-Help cmdlet in the console pane.

Show-Command. Show-Command allows you to compose or run a cmdlet or function by filling out a GUI-based form. The form lets users work with Windows PowerShell in the graphical environment they are comfortable with. Show-Command also enables advanced scripters to create a quick Windows PowerShell-based GUI.

Powershell

Here’s a quick function to give you server (service profile) name and map it to NIC and VLAN using the Cisco UCS PowerTool:

The code: http://poshcode.org/3391

The output might look something like this:

Server          Vnic Vlan
------          ---- ----
bd-esx-01       eth0 BD-Net-01
bd-esx-01       eth1 BD-Net-01
bd-esx-01       eth2 Storage-NET
bd-esx-01       eth3 PVS-Net
bd-esx-02       eth0 BD-Net-01
bd-esx-02       eth1 BD-Net-01
bd-esx-02       eth2 Storage-NET
bd-esx-02       eth3 PVS-Net

The VMware vExpert program awards those who contribute “above and beyond” to the public body of knowledge about VMware virtualization. I’m not going to write a big speech here, but I did want to acknowledge that I’ve been re-awarded for the fourth year in a row, which is as long as the award has been in existence! It’s very cool to be recognized, and I’m proud to be among a great group of really smart folks.

I am very happy to announce that I’ve taken a new job with Splunk! I’m going to be a Solutions Architect working in their Business Development Partner Application Development team for my buddy Brandon Shell. As a part of my new role, I will be using Python (and PowerShell wherever I can fit it in) to help to create solutions around our areas of focus. There will be VMware stuff for sure, and some other cool technologies as well that I’m very interested in. More news as I figure out what they are. Smile

The job is 100% working from home, which is awesome. I’m glad to get back to that after several years of braving Atlanta traffic. (I had worked for HP from home for a while.) You know what else is great about this new job? I won’t be on call 24×7! Very glad to ditch the pager! (Not to say that I won’t return your calls, Brandon. Smile , just not while I am asleep.)

I’m all set to start Feb 13th!

Powershell

A workflow is a sequence of automated steps or activities that execute tasks on or retrieve data from one or more managed nodes (computers or devices). These activities can include individual commands or scripts. Windows PowerShell Workflow enables, IT pros and developers alike, to author sequences of multi-computer management activities — that are either long-running, repeatable, frequent, parallelizable, interruptible, stoppable, or restartable — as workflows. By design, workflows can be resumed from an intentional or accidental suspension or interruption, such as a network outage, a reboot or power loss.

I just had to paste this paragraph. It comes from the recently published “Getting Started with PowerShell Workflow” as announced in this post on the PowerShell team blog. You can grab the PDF from the WMF3 CTP2 download page.

Hot stuff! Go grab the 14 page doc so you can be ready for when v3 ships! There are a ton of examples so that you get started quickly.

Disclaimer: this is pre-release code and will definitely change

Powershell

So I’m sitting here building a bunch of virtual machines using PowerCLI. I decided to start with a spreadsheet into which I’ve collected many of the important things about a virtual machine:

SNAGHTML840494

Since I don’t actually build VMs every day, and I haven’t focused on a build process (like I should, I know!) yet, this spreadsheet was a first draft of a build process and it was made for humans, not machines. What does this mean? Well, obviously, by looking at the Memory column, any of you would guess that the unit of measurement is gigabytes. However, VMware happens to measure memory in megabytes.

Long story short, I wrote a quick one-liner in PowerShell to “spec out” the newly-cloned virtual machines using this spreadsheet. As I said, it’s not a build process yet, but it will be when I’m done. Baby steps. The one-liner looks like this ($t is the variable that holds the data obtained from the spreadsheet, using a simple Import-Csv cmdlet):

   1: $t | % { Set-VM -VM $_.name -NumCpu $_.cpu -MemoryMB $_.Memory }

Once I started that running, I quickly realized that 8MB VMs would do me no good. Smile So, I amended my script to this:

   1: $t | % { Set-VM -VM $_.name -NumCpu $_.cpu -MemoryMB ( $_.Memory * 1024 ) }

That’s when I got a really weird error:

Set-VM : Cannot bind parameter ‘MemoryMB’. Cannot convert value "888888888888888888888888888888888888888888888888888888

88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

888888888888888888" to type "System.Int64". Error: "Value was either too large or too small for an Int64."

Yuck! That one threw me for a loop for a moment until I realized the important lesson of the day. When you use a technique like Import-Csv, the resulting object is a bunch of strings! What happens when you multiply a string by a number in PowerShell? Yes, it’s effectively a concatenation. So in my case, the number 8 followed by one-thousand-and-twenty-three of the same. Nice, when that’s what you intended. That was not my intent this time!

So to round this post out with a fix, here’s the right way to get the intended result, which was to turn “8” into “8192”:

   1: $t | % { Set-VM -VM $_.name -NumCpu $_.cpu -MemoryMB ( [int]$_.Memory * 1024 ) }

Note the “[int]” there before the $_. That will convert the resulting property to an integer BEFORE performing the multiplication. That’s the key here, it has to happen before (in the order of precedence), otherwise I end up with a bunch of 8’s. Now, I happen to know the order of operator precedence in PowerShell well enough to know that the above would work without any doubt, but if you aren’t sure about a particular piece of code, you can always surround a portion of a statement with parentheses in order to ensure that you get the order that you need.

Powershell

Run, don’t walk to vmware.com/go/powercli to grab the latest version of the world’s best PowerShell snapin. That’s right, v5 is out and you can grab it now! And the coolest part is that while nobody will have vSphere 5 in production on day one (ok, there’s a couple of you out there), PowerCLI v5 is a client-based tool with no dependencies, and it’s downwards-compatible! There is literally no reason for you not to upgrade right this instant! I am using exclamations here, people!

I’ve had beta builds installed for some time, but I didn’t want to do blog posts based on pre-release builds for fear that things would change. Now that it’s out, I’ll start pushing out some posts about what’s new and all that, so stay tuned. For now, some quick stats and info:

There are now FOUR VMware snap-ins installed with PowerCLI v5:

PowerCLI U:\> Get-PSSnapin vmware*

Name        : VMware.VimAutomation.Core
PSVersion   : 2.0
Description : This Windows PowerShell snap-in contains Windows PowerShell cmdlets for managing vSphere.

Name        : VMware.VimAutomation.License
PSVersion   : 2.0
Description : This Windows Powershell snap-in contains cmdlets for managing License components.

Name        : VMware.DeployAutomation
PSVersion   : 2.0
Description : Cmdlets for Rule-Based-Deployment

Name        : VMware.ImageBuilder
PSVersion   : 2.0
Description : This Windows PowerShell snap-in contains VMware ESXi Image Builder cmdlets used to generate custom images.

There are 293 cmdlets in total across these snap-ins. Here they are, grouped by Noun and Verb:

PowerCLI U:\> $c = Get-Command -Module vmware*
PowerCLI U:\> $c.Length
293
PowerCLI U:\> $c | group verb

Count Name                      Group
—– —-                      —–
    6 Add                       {Add-DeployRule, Add-EsxSoftwareDepot, Add-E…
    3 Apply                     {Apply-DrsRecommendation, Apply-ESXImageProf…
    1 Compare                   {Compare-EsxImageProfile}
    1 Connect                   {Connect-VIServer}
    4 Copy                      {Copy-DatastoreItem, Copy-DeployRule, Copy-H…
    1 Disconnect                {Disconnect-VIServer}
    1 Dismount                  {Dismount-Tools}
    3 Export                    {Export-EsxImageProfile, Export-VApp, Export…
    1 Format                    {Format-VMHostDiskPartition}
   95 Get                       {Get-AdvancedSetting, Get-AlarmAction, Get-A…
    2 Import                    {Import-VApp, Import-VMHostProfile}
    1 Install                   {Install-VMHostPatch}
    1 Invoke                    {Invoke-VMScript}
    1 Mount                     {Mount-Tools}
    9 Move                      {Move-Cluster, Move-Datacenter, Move-Folder,…
   37 New                       {New-AdvancedSetting, New-AlarmAction, New-A…
   42 Remove                    {Remove-AdvancedSetting, Remove-AlarmAction,…
    2 Repair                    {Repair-DeployImageCache, Repair-DeployRuleS…
    4 Restart                   {Restart-VM, Restart-VMGuest, Restart-VMHost…
   58 Set                       {Set-AdvancedSetting, Set-AlarmDefinition, S…
    1 Shutdown                  {Shutdown-VMGuest}
    4 Start                     {Start-VApp, Start-VM, Start-VMHost, Start-V…
    5 Stop                      {Stop-Task, Stop-VApp, Stop-VM, Stop-VMHost…}
    3 Suspend                   {Suspend-VM, Suspend-VMGuest, Suspend-VMHost}
    1 Switch                    {Switch-ActiveDeployRuleSet}
    3 Test                      {Test-DeployRuleSetCompliance, Test-VMHostPr…
    1 Update                    {Update-Tools}
    2 Wait                      {Wait-Task, Wait-Tools}

PowerCLI U:\> $c | group noun

Count Name                      Group
—– —-                      —–
    6 DeployRule                {Add-DeployRule, Copy-DeployRule, Get-Deploy…
    2 EsxSoftwareDepot          {Add-EsxSoftwareDepot, Remove-EsxSoftwareDepot}
    3 EsxSoftwarePackage        {Add-EsxSoftwarePackage, Get-EsxSoftwarePack…
    3 PassthroughDevice         {Add-PassthroughDevice, Get-PassthroughDevic…
    9 VMHost                    {Add-VMHost, Get-VMHost, Move-VMHost, Remove…
    3 VmHostNtpServer           {Add-VmHostNtpServer, Get-VMHostNtpServer, R…
    2 DrsRecommendation         {Apply-DrsRecommendation, Get-DrsRecommendat…
    6 ESXImageProfile           {Apply-ESXImageProfile, Compare-EsxImageProf…
    7 VMHostProfile             {Apply-VMHostProfile, Export-VMHostProfile, …
    2 VIServer                  {Connect-VIServer, Disconnect-VIServer}
    1 DatastoreItem             {Copy-DatastoreItem}
    5 HardDisk                  {Copy-HardDisk, Get-HardDisk, New-HardDisk, …
    1 VMGuestFile               {Copy-VMGuestFile}
    4 Tools                     {Dismount-Tools, Mount-Tools, Update-Tools, …
    9 VApp                      {Export-VApp, Get-VApp, Import-VApp, Move-VA…
    2 VMHostDiskPartition       {Format-VMHostDiskPartition, Get-VMHostDiskP…
    4 AdvancedSetting           {Get-AdvancedSetting, New-AdvancedSetting, R…
    3 AlarmAction               {Get-AlarmAction, New-AlarmAction, Remove-Al…
    3 AlarmActionTrigger        {Get-AlarmActionTrigger, New-AlarmActionTrig…
    2 AlarmDefinition           {Get-AlarmDefinition, Set-AlarmDefinition}
    2 Annotation                {Get-Annotation, Set-Annotation}
    4 CDDrive                   {Get-CDDrive, New-CDDrive, Remove-CDDrive, S…
    5 Cluster                   {Get-Cluster, Move-Cluster, New-Cluster, Rem…
    4 CustomAttribute           {Get-CustomAttribute, New-CustomAttribute, R…
    5 Datacenter                {Get-Datacenter, Move-Datacenter, New-Datace…
    4 Datastore                 {Get-Datastore, New-Datastore, Remove-Datast…
    1 DatastoreCluster          {Get-DatastoreCluster}
    2 DeployRuleSet             {Get-DeployRuleSet, Set-DeployRuleSet}
    4 DrsRule                   {Get-DrsRule, New-DrsRule, Remove-DrsRule, S…
    1 ErrorReport               {Get-ErrorReport}
    1 EsxCli                    {Get-EsxCli}
    1 EsxSoftwareChannel        {Get-EsxSoftwareChannel}
    1 EsxTop                    {Get-EsxTop}
    4 FloppyDrive               {Get-FloppyDrive, New-FloppyDrive, Remove-Fl…
    5 Folder                    {Get-Folder, Move-Folder, New-Folder, Remove…
    1 HAPrimaryVMHost           {Get-HAPrimaryVMHost}
    3 Inventory                 {Get-Inventory, Move-Inventory, Remove-Inven…
    4 IScsiHbaTarget            {Get-IScsiHbaTarget, New-IScsiHbaTarget, Rem…
    1 LicenseDataManager        {Get-LicenseDataManager}
    1 Log                       {Get-Log}
    1 LogType                   {Get-LogType}
    4 NetworkAdapter            {Get-NetworkAdapter, New-NetworkAdapter, Rem…
    2 NicTeamingPolicy          {Get-NicTeamingPolicy, Set-NicTeamingPolicy}
    4 OSCustomizationNicMapping {Get-OSCustomizationNicMapping, New-OSCustom…
    4 OSCustomizationSpec       {Get-OSCustomizationSpec, New-OSCustomizatio…
    2 PowerCLIConfiguration     {Get-PowerCLIConfiguration, Set-PowerCLIConf…
    1 PowerCLIVersion           {Get-PowerCLIVersion}
    5 ResourcePool              {Get-ResourcePool, Move-ResourcePool, New-Re…
    3 ScsiController            {Get-ScsiController, New-ScsiController, Set…
    2 ScsiLun                   {Get-ScsiLun, Set-ScsiLun}
    2 ScsiLunPath               {Get-ScsiLunPath, Set-ScsiLunPath}
    4 Snapshot                  {Get-Snapshot, New-Snapshot, Remove-Snapshot…
    1 Stat                      {Get-Stat}
    4 StatInterval              {Get-StatInterval, New-StatInterval, Remove-…
    1 StatType                  {Get-StatType}
    3 Task                      {Get-Task, Stop-Task, Wait-Task}
    5 Template                  {Get-Template, Move-Template, New-Template, …
    2 UsbDevice                 {Get-UsbDevice, Remove-UsbDevice}
    1 VIAccount                 {Get-VIAccount}
    3 VICredentialStoreItem     {Get-VICredentialStoreItem, New-VICredential…
    1 VIEvent                   {Get-VIEvent}
    1 View                      {Get-View}
    1 VIObjectByVIView          {Get-VIObjectByVIView}
    4 VIPermission              {Get-VIPermission, New-VIPermission, Remove-…
    1 VIPrivilege               {Get-VIPrivilege}
    3 VIProperty                {Get-VIProperty, New-VIProperty, Remove-VIPr…
    4 VIRole                    {Get-VIRole, New-VIRole, Remove-VIRole, Set-…
    4 VirtualPortGroup          {Get-VirtualPortGroup, New-VirtualPortGroup,…
    4 VirtualSwitch             {Get-VirtualSwitch, New-VirtualSwitch, Remov…
    9 VM                        {Get-VM, Move-VM, New-VM, Remove-VM…}
    4 VMGuest                   {Get-VMGuest, Restart-VMGuest, Shutdown-VMGu…
    2 VMGuestNetworkInterface   {Get-VMGuestNetworkInterface, Set-VMGuestNet…
    3 VMGuestRoute              {Get-VMGuestRoute, New-VMGuestRoute, Remove-…
    4 VMHostAccount             {Get-VMHostAccount, New-VMHostAccount, Remov…
    2 VMHostAdvancedConfigur… {Get-VMHostAdvancedConfiguration, Set-VMHost…
    1 VMHostAttributes          {Get-VMHostAttributes}
    2 VMHostAuthentication      {Get-VMHostAuthentication, Set-VMHostAuthent…
    1 VMHostAvailableTimeZone   {Get-VMHostAvailableTimeZone}
    2 VMHostDiagnosticPartition {Get-VMHostDiagnosticPartition, Set-VMHostDi…
    1 VMHostDisk                {Get-VMHostDisk}
    2 VMHostFirewallDefaultP… {Get-VMHostFirewallDefaultPolicy, Set-VMHost…
    2 VMHostFirewallException   {Get-VMHostFirewallException, Set-VMHostFire…
    2 VMHostFirmware            {Get-VMHostFirmware, Set-VMHostFirmware}
    2 VMHostHba                 {Get-VMHostHba, Set-VMHostHba}
    1 VMHostImageProfile        {Get-VMHostImageProfile}
    1 VMHostMatchingRules       {Get-VMHostMatchingRules}
    2 VMHostModule              {Get-VMHostModule, Set-VMHostModule}
    2 VMHostNetwork             {Get-VMHostNetwork, Set-VMHostNetwork}
    4 VMHostNetworkAdapter      {Get-VMHostNetworkAdapter, New-VMHostNetwork…
    2 VMHostPatch               {Get-VMHostPatch, Install-VMHostPatch}
    1 VMHostProfileRequiredI… {Get-VMHostProfileRequiredInput}
    4 VMHostRoute               {Get-VMHostRoute, New-VMHostRoute, Remove-VM…
    5 VMHostService             {Get-VMHostService, Restart-VMHostService, S…
    3 VMHostSnmp                {Get-VMHostSnmp, Set-VMHostSnmp, Test-VMHost…
    2 VMHostStartPolicy         {Get-VMHostStartPolicy, Set-VMHostStartPolicy}
    2 VMHostStorage             {Get-VMHostStorage, Set-VMHostStorage}
    2 VMHostSysLogServer        {Get-VMHostSysLogServer, Set-VMHostSysLogSer…
    2 VMQuestion                {Get-VMQuestion, Set-VMQuestion}
    2 VMResourceConfiguration   {Get-VMResourceConfiguration, Set-VMResource…
    2 VMStartPolicy             {Get-VMStartPolicy, Set-VMStartPolicy}
    1 VMScript                  {Invoke-VMScript}
    3 CustomField               {New-CustomField, Remove-CustomField, Set-Cu…
    1 DeployImageCache          {Repair-DeployImageCache}
    2 DeployRuleSetCompliance   {Repair-DeployRuleSetCompliance, Test-Deploy…
    1 ActiveDeployRuleSet       {Switch-ActiveDeployRuleSet}
    1 VMHostProfileCompliance   {Test-VMHostProfileCompliance}

The Atlanta VMUG is gearing up for its huge annual event at the Georgia World Congress Center this October 24th! You can register for the one-day event at myvmug.org. They have not yet posted the agenda, but one thing that I know they will be have there is me talking about PowerCLI. Smile I haven’t yet come up with a topic, but you can assume that:

  • I’ll talk about PowerCLI
  • I won’t bore you

Beyond that is anyone’s guess, but suggestions are welcome. Leave your ideas in the comments below! I’m sure I’ll have a copy or two of some books or training videos to give away, so if nothing else, just show up for a chance at that. Smile

But seriously folks—this will be a huge event. The VMUG leaders are telling me to expect more than 1,000 attendees. Don’t miss it, register now!

Been using this for work email for over a week and I still really like it. Has a couple minor bugs, is missing a few features that I had in Touchdown. But overall, it is really very good. It is much better than the stock Android Exchange client, that is clear. It does folder management better than TD, and its GUI is a little more pleasing to my eyes. Does not do notes sync, and the task sync seems totally broken for me right now. But email is solid, or I never would have considered using a beta so long. Highly recommended, especially if you never shelled out $ for Touchdown and are only using a stock Froyo/Gingerbread or HTC Exchange client on your Android device.

VMware: VMware End User Computing: Introducing VMware Zimbra for Android – A New Fling from VMware Labs!

  • Microblog

  • Recent Posts

  • Recent Comments

  • meta

  • PowerShell Blogroll