PowerShell: A first-timer’s perspective of PowerCLI

This blog post is a description of my first experience playing around with PowerCLI, which is VMware’s PowerShell module for managing vSphere servers. I haven’t really dealt with VMware much in my past, other than VMware Workstation, so I thought it was exciting to get the chance to play around with PowerShell & VMware together!

I won’t bore you with the installation details, and I’ll get right to firing it up. There’s a shortcut to launch PowerCLI in the Start Menu, and it’s got a custom icon on it, which makes it easily recognizable on the Windows Taskbar.

Continue reading

PowerShell: Creating Active Directory Managed Service Accounts

Hey folks,

I’ve recently been trying to learn more about Active Directory Managed Service Accounts (MSAs), which are basically self-managing service accounts. You don’t have to manage the Service Principal Name (SPN) or password for MSAs, which makes them very good choices for running applications. You can read more about MSAs on Microsoft Technet at this URL.

Similar to MSAs are local “virtual accounts.” These do not have password to manage, and they can automatically manage their SPNs. These are not within the scope of discussion, however there are some links in the References section, which might help you to get more information about them.

Creating a Group Managed Service Account with PowerShell

I’ve been trying to create a MSA using PowerShell using the command below, but I kept getting an error. There is a Technet discussion forum post that addresses this same issue. In my scenario, I was running the command on a Windows Server 2012 domain controller.
Continue reading

PowerShell: Integrate Invocation of AutoIT Scripts

Although PowerShell is an incredibly powerful automation platform [primarily] for Microsoft Windows systems, it does have some gaps that other tools can fill. One of those tools is called AutoIT, which many of you are probably familiar with prior to reading this. AutoIT can handle GUI automation much more easily than PowerShell, and is therefore a desirable alternative. But, what if you need to combine PowerShell automation and some GUI automation with AutoIT? Wouldn’t it be nice to be able to simply call an AutoIT script from inside your PowerShell script, without having external dependencies to copy around alongside your PowerShell script?

Here is a simple helper function that will execute an AutoIT script in-line with your PowerShell code. I hope this makes it easier to integrate AutoIT with your existing and future PowerShell scripts. Although quite basic in its current form, this function could be enhanced to include support for firing off AutoIT scripts asynchronously, passing parameters into them, accepting output from AutoIT scripts, and so on.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<#
    .Synopsis
    This function will invoke an AutoIT script based on an input string.
   
    .Parameter $ScriptText
    The ScriptText parameter is the text of the AutoIT script file that
    will be executed by the function.
   
    .Outputs
    None (for now) :)
   
    .Link
    http://trevorsullivan.net
   
    .Author
    Trevor Sullivan
   
    .Date
    2012-05-25
#>

function Execute-AutoItScript {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string] $ScriptText
    )
   
    # Create a temporary file name
    $TempFileName = '{0}\{1}.au3' -f $env:TEMP, [Guid]::NewGuid().Guid.Replace('-',' ');
    # Write the script text to the AutoIT script file
    [IO.File]::WriteAllText($TempFileName, $ScriptText);
    # Get the path to AutoIT (this could be "dynamicized" :)
    $AutoIt = 'c:\Program Files (x86)\AutoIT3\AutoIT3.exe';
    # Invoke AutoIT with the script path
    Start-Process -FilePath $AutoIt -ArgumentList $TempFileName -Wait;
    # Remove the temporary AutoIT script file
    Remove-Item -Path $TempFileName;
}

# Define the AutoIT script in a PowerShell here-string
$Script = @"
    WinActivate("
XML Notepad")
"
@

# Invoke AutoIT script defined above
Execute-AutoItScript -ScriptText $Script;

PowerShell / ConfigMgr: Retrieve List of Client Names by Collection ID

Here’s a simple PowerShell script that you can use to retrieve a list of system names based off of a collection ID in Microsoft System Center Configuration Manager (SCCM / ConfigMgr) 2007. This has not been tested against collections that contain anything except system resources (computers objects in SCCM). Use at your own risk.

# Variables
$SiteCode = '123';
$SccmServer = 'sccmserver.mydomain.com';
$CollectionID = '12345678';

# Commands to retrieve client name list
$ClientList = Get-WmiObject -ComputerName $SccmServer `
    -Namespace "rootsmssite_$SiteCode" `
    -Class SMS_FullCollectionMembership `
    -Filter "CollectionID = '$CollectionID'" `
    -Property @('Name');
$ClientNames = $ClientList | Select-Object Name
$ClientNames

Office 2010 SP1: Silent Installation

Just the other day, Microsoft released Microsoft Office 2010 Service Pack 1 (SP1). To deploy the update via software distribution in System Center Configuration Manager (SCCM / ConfigMgr) 2007, or simply via script, you can use the following command line:

officesuite2010sp1-kb2460049-x86-fullfile-en-us.exe /quiet /norestart

As a best practice I always try to use any available logging parameters, however in this case, it didn’t work. I’ve had some challenges with other Microsoft update executables before, where they do not interpret the /log parameter correctly. This held true for the Internet Explorer 9 (IE9) installer as well.

image

Introduction to Google Music Beta

The Introductory E-mail

Hello Motorola XOOM user,
We’d like to tell you about some changes to the Music player on your tablet. The latest app update now supports Music Beta, a new service from Google. As a Verizon Motorola XOOM user, you’ve been extended an early invitation to beta test this service.
Music Beta lets you store your personal music collection online and access it instantly without the hassle of wires or syncing.

· Enjoy your music anywhere — listen on any web browser, your Motorola XOOM, or any other device running Android 2.2 or higher.

· Save your favorite albums, artists, and playlists on your smartphone or tablet so you can keep listening even when you’re not connected.

· Create your own custom playlists or build them automatically from a single song.

To get started, click the button below and sign in with your Google ID: yourgoogleaccount@gmail.com

Get Started

Regards,
The Android Team

©2011 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043

Music Beta is available by invitation only in the U.S. and is free for a limited time. You have received this mandatory email service announcement to update you about important changes to your Android OS.

Continue reading

VMware Workstation Error: Acquiring Memory

I’ve been getting this error message a lot lately – does anyone have any idea what might cause it? I’ve usually got plenty of free memory when I get the message. I think it usually comes up after coming out of sleep and/or hibernate on my Windows 7 host OS.

image

This virtual machine has encountered a problem acquiring the memory needed for it to run. Would you like to suspend the virtual machine to prevent data loss or allow it to continue running?

Here is a screenshot of the memory configuration I’m using. I don’t want a lot of swapping going on, even though I’ve got a SSD – I’ve got 8GB of DDR3 in my laptop (Dell Latitude E6410), so I’d prefer to reserve all the RAM necessary for each VM.

image

Microsoft Community Contributor Award

Hey folks,

I was recently presented with a Microsoft Community Contributor award for participation in various online IT communities. Thanks to the folks at Microsoft for this!

I genuinely hope that my contributions to the community have been helpful to my readers, and to anyone else that has sought help on topics that I’ve written about. This is something that I’m truly passionate about, so it’s very rewarding for me to find that others have found my content to be helpful.

For the rest of you out there … if you aren’t already, I strongly suggest that you start a blog, and participate in discussion forums, mailing lists, Twitter, and other forms of social media. There are lots of people out there that need help in their technical field(s), and I’m sure that your knowledge and experience would be quite beneficial to them!

MCC Certificate

Cheers,
Trevor

MSDN Ultimate Giveaway

Howdy folks,MSDN Logo

The other day, I helped out Rob Collie (@powerpivotpro) with something, and in return he provided me a MSDN Ultimate subscription. I don’t really have a need for this, however, as I have MSDN and Technet access already, so I’m giving it away to someone in the community. I can’t think of any super creative ways to choose a winner, so I’ll go with the old “pick a number” routine, somewhere between 1 and 2000. The number has some significance to me, though I wouldn’t expect anyone else to know why that is.

The main rule is that you can only submit one number per 24-hour interval, and if you post more than once in 24 hours, you will be disqualified. So go ahead … post your guesses in the comments section! Comments will be closed at 9 AM Central Time on Friday, January 28th, 2011. The person with the closest number at that time will win the subscription.