Posts RSS Comments RSS 253 Posts and 408 Comments till now

Hyper-V and PowerShell : VMName to OSName mapping

I have been working on creating a Hyper-V app for Splunk that will allow Splunk users to associate Hypervisor data with products like XenDesktop, XenApp, and Exchange. One of the challenges I came across is mapping the Hypervisor VM name to the OS FQDN.

Thanks to Artem

Function


function Get-VMDetails
{
    Param(
        [Parameter()]
        $ComputerName = $Env:ComputerName,

        [Parameter()]
        $VMName

    )

    # Creating HASH Table for object creation
    $MyObj = @{}

    # Getting VM Object
    $Vm = Get-WmiObject -Namespace root\virtualization -Query "Select * From Msvm_ComputerSystem Where ElementName=’$VMName’" -ComputerName $ComputerName

    # Getting VM Details
    $Kvp = Get-WmiObject -Namespace root\virtualization -Query "Associators of {$Vm} Where AssocClass=Msvm_SystemDevice ResultClass=Msvm_KvpExchangeComponent" -ComputerName $ComputerName

    # Converting XML to Object
    foreach($CimXml in $Kvp.GuestIntrinsicExchangeItems)
    {

        $XML = [xml+site:msdn.microsoft.com”>XML]$CimXml

        if($XML)
        {
            foreach ($CimProperty in $XML.SelectNodes("/INSTANCE/PROPERTY"))
            {
                switch -exact ($CimProperty.Name)
                {
                    "Data"      { $Value = $CimProperty.VALUE }
                    "Name"      { $Name  = $CimProperty.VALUE }
                }
            }
            $MyObj.add($Name,$Value)
        }
    }

    # Outputting Object
    New-Object -TypeName PSCustomObject -Property $MyObj
}

Output looks like


RDPAddressIPv6             :
OSName                     : Windows Server 2008 R2
EnterpriseOSMajorVersion   : 6
ServicePackMinor           : 0
ProductType                : 3
OSPlatformId               : 2
SuiteMask                  : 18
CSDVersion                 : Service Pack 1
OSVersion                  : 6.1.7601
FullyQualifiedDomainName   : bd-xa60-01.home.lab
OSMinorVersion             : 1
NetworkAddressIPv6         : fe80::78e4:e94b:b5c0:be0b%12
OSBuildNumber              : 7601
ProcessorArchitecture      : 9
RDPAddressIPv4             :
ServicePackMajor           : 1
NetworkAddressIPv4         : 192.168.0.105
OSEditionId                : 10
IntegrationServicesVersion : 6.1.7601.17514

PowerShell cmdlets for Splunk!

Project

https://github.com/splunk/splunk-reskit-powershell

Splunk PowerShell Resource Kit

The Splunk PowerShell Resource Kit enables IT administrators to manage their Splunk topology, configure Splunk internals, and engage the Splunk search engine from their PowerShell session.

Example Uses
PS > Get-Splunkd

ComputerName MgmtPort HTTPPort SessionTimeout MinFreeSpace EnableWeb EnableWebSSL Splunk_Home
———— ——– ——– ————– ———— ——— ———— ———–
YETICLIENT 8089 8000 1h 2000 True True C:\Program Files\Splunk

PS > Get-SplunkdUser

ComputerName UserName FullName Email Type DefaultApp Roles
———— ——– ——– —– —- ———- —–
127.0.0.1 admin Administrator changeme@example.com Splunk launcher admin

Here are a few of the tasks enabled by the Resource Kit:

  • Determine or change the status of Splunk services across a set of Splunk servers in parallel.
  • Force one or more Splunk servers to reload their configuration, in parallel.
  • Deploy multiple Splunk forwarders to all active hosts in a Windows domain.
  • Retrieve a list of Splunk server classes, optionally filtered by last deployment client connection time, associated applications, or matching patterns.
  • Issue a Splunk search and format the retrieved events as a table, a list, or in a windowed grid view.

Documentation
Most of the documentation leaves in the “Splunk PowerShell Resource Kit Cookbook”, which we highly recommend you read. You can find it here: Splunk PowerShell Resource Kit

Resources

You can find anything having to do with developing on Splunk at the Splunk developer portal:
You can also find full reference documentation of the REST API: API Reference

Community

Email: Stay connected with other developers building on Splunk: devinfo@splunk.com
Issues: https://github.com/splunk/splunk-reskit-powershell/issues
Answers: Check out this tag on Splunk answers for: http://splunk-base.splunk.com/tags/powershell/
Blog: http://blogs.splunk.com/dev/
Twitter: @splunkdev

Support

Resource Kits in Preview will not be Splunk supported. Once the PowerShell Resource Kit an Open Beta we will provide more detail on support.

Issues should be filed here: https://github.com/splunk/splunk-reskit-powershell/issues

Contact Us

You can reach the Dev Platform team at devinfo@splunk.com

License

The Splunk PowerShell Resource Kit is licensed under the Apache License 2.0. Details can be found in the file LICENSE.

 

The 2011 Scripting Games

The 2011 Scripting Games begin on April 4, 2011 and run through April 15, 2011. What is the Scripting Games, you may ask? Well simply put, the Scripting Games are the premier learning event of the year for IT Pro’s and others who wish to master Windows PowerShell. Comprising 10 events, a registered contestant has seven days to create a solution to a scenario driven problem and post their code to a MVP maintained script repository for evaluation by a panel of internationally recognized judges. Daily leaderboards and prize drawings help to maintain the suspense throughout the two-week international event.

 

During the 2011 Scripting Games hundreds of contestants will submit thousands of scripts that will be reviewed by dozens of judges. Hundreds of thousands of spectators from all around the world will view the games themselves. Last year, participants from more than 100 countries participated in the Scripting Games. With an emphasis on real world scripting scenarios and problems, the scripts will be of immediate value to both the participants and to the spectators.

 

Preparation for the 2011 Scripting Games is already underway, with a learning guide, step-by-step tutorials, videos and other resources being generated on a daily basis. The 2011 Scripting Games all in one page is the portal for the games themselves. The 2010 Scripting Games all in one page is still available, as are the events from the 2009 Scripting Games.

 

Its been awhile… what have you been up to?

Sorry I haven’t been blogging much. While I have been very busy at work my Powershell exploits have not been idle :)

Here are some updates :)

Anyway… I just wanted to give you a heads up on what was going on with me. Shortly I plan to have a weekly or monthly blog post covering my BSonPosh module which is up to ~140 cmdlets.

BriForum rocked!

As I am sitting here on my way back to NJ from BrForum I am thinking about the week. All I can say is awesome. The content was only matched by the company. People often underestimate the value in conferences and often it is not the actual sessions. In the case of BriForum there is significant value in both. If you have never been to BriForum and you are in the SBC (server based computing) world you are missing out.

p.s. @ShawnBass, @JasonConger, @LauraWhalen, @JimMoyle. You guys rock and I had an absolute blast.

BSonPosh v1 Powershell Module finally ships!

Thanks to 12 hours of time in an airplane I was able to put the finishing touches on my BSonPosh Module.

I have added help for all my cmdlets and created format files.

Download Here: BSonPosh V1

[Update]:: I had to post an updated zip file as I was missing some KMS cmdlets. Thanks Jason for pointing that out!

PowerScripting Podcast… Tonight!

Going to be a guest tonight on the PowerScripting pod cast. You can catch it live via the website or listen later.

Blogging from iPad

Trying out the new iPad app for WordPress. Typing is not perfect but it is not to bad either.

For those of you wondering I got an iPad because of the Citrix receiver. It make the device priceless. IMO… Everyone should have one.

Live Tweeting/Blogging Citrix Synergy!

Some really exciting news forth coming!

@BSonPosh #CitrixSynergy

Write-Log… What should it be?

Goal:

Write a Logging Script/Module with functionality similar to Log4Perl : Link to Log4Perl Info

If you have any ideas on what functionality it should have please let me know by leaving a comment.

Next Page »