Don’t miss the opportunity to meet part of the genuine Vmware PowerCLI team live!
Two parts session focuses on PowerCLI and Onyx.
More than 230 PowerShell cmdlets, along with documentation and samples in version 4.1.
Tips and tricks - the art of being efficient managing vSphere.
Hands-on lab: VMware vSphere™ PowerCLI
Bright new Onyx version with tons of fresh, cool features. For those who don’t know, Onyx is a standalone application that serves as a proxy between the vSphere Client and the vCenter Server. It monitors the network communication between them and translates it into an executable PowerShell code. You will be the first to see it before even its official release!
Yes, Everyone is welcome to our next PowerShell meeting – “Topic: Working with Functions”
Topic: Working with Functions…
Location:
New Horizons of South Florida
Ft. Lauderdale Office
100 S. Pine Island Rd
Plantation, FL 33324
954-572-8600
or register on our website:
http://www.flpsug.com/
Meeting starts at 6:30PM
I realised a few hours after posting my last entry about a PowerShell ISE profile script, that I failed to describe to people new to the ISE environment, how to include the script as part of their ISE profile so it is always available.
Simply explaining how to determine the path of your ISE profile by checking the value of the $Profile variable from within the ISE would be boring, so instead I wrote another script to automatically download the first script from GitHub, and add it to your profile.
This new script can simply be copied and pasted into the ISE’s Command Pane (Ctrl+D) and your profile will be opened and updated, ready to be saved. Once saved, you can either restart the ISE or simply run ” . $profile ” (without quotes) from the Command Pane.
You will hopefully notice in this new script, that my usual attention to neatness and verbosity has been replaced with terseness due to the purpose of this script being a use once and throw away item. I had considered writing it as a single line but quickly regained my senses.
I work with a lot of PowerShell scripts, it’s the fun part of my job. I do most of my editing using the PowerShell ISE, primarily because it is the default, but also because it has great syntax highlighting, tab completion, and debug support. Additionally, all of my scripts are in source control: sometimes Mercurial, occasionally Git, but mostly Team Foundation Server (TFS).
The way TFS works though, is that all files in your local workspace are marked as read-only until you Check-Out for editing. When working on TFS-managed files in Visual Studio, the check-out is done automatically as soon as you begin typing in the editor. The PowerShell ISE however has no idea about TFS and will let you edit to your heart’s content until you eventually try to save your changes and it fails due to the read-only flag.
But I’ve developed a solution…
I’ve written a PowerShell ISE-specific profile script that performs a few simple things:
The end result is the same TFS workflow experience from within the PowerShell ISE as Visual Studio provides.
Today we released a public beta of our upcoming PowerGUI 2.2 release. This beta includes a very significant change to our debugger as well as compatibility support with version 1.4 of the Quest AD cmdlets. Here are a few of the improvements that come with the new debugger:
This is the first public beta that we have had in a while, so I want to make sure everyone interested knows how the beta works. It’s a pretty straightforward process, as follows:
That’s pretty much it. I should also note that auto-update from the beta version of PowerGUI 2.2 to the RTM version of PowerGUI 2.2 will be supported.
We’re looking forward to your feedback, so please download the beta and let us know what you think!
Kirk out.
Technorati Tags: PowerShell,PoSh,Poshoholic,PowerGUI,beta
Jay Dave, Program Manager at Microsoft about UAC and AppLocker
NewsExecute commands and scripts from anywhere including the office and remote locations, as well as from a Web browser or smart phone with PowerGUI Pro from Quest Software. With the MobileShell feature, administrators can quickly run commands to troubleshoot problems or make changes, even when away from your desk! This gives teams more flexibility to work remotely while traveling, and to leverage admins from other offices in case of an emergency.
· Execute queries remotely to determine if services or processes are running
· Restart services, processes, or entire servers
· Check mailbox settings
· Unlock user accounts
· Reset passwords
· Run custom scripts
Visit quest.com/powerguipro and see why PowerShell and Quest PowerGUI are the ultimate Windows management tools.
This segment is brought to you by ConcentratedTech.com.
This segment is brought to you by Serverfault.com!
MSDN Webcast: geekSpeak: PowerShell for .NET Developers with Doug Finke (Level 200)
In this episode of geekSpeak, Microsoft Most Valuable Professional (MVP) Doug Finke takes us on a deep dive into PowerShell from a developer’s point of view. Doug shows techniques for integrating/debugging PowerShell from and to C# code as well as using PowerShell with a Windows Presentation Foundation (WPF) application. He also addresses using reflection at the command line, object pipelining, and PowerShell’s REPL. This geekSpeak is hosted by Glen Gordon andRachel Appel.
The geekSpeak webcast series brings you industry experts in a "talk-radio" format hosted by developer evangelists from Microsoft. These experts share their knowledge and experience about a particular developer technology and are ready to answer your questions in real time during the webcast.
If you’ve ever had a Powershell conversation with me the chances are high that you’ve heard my agenda around modules. I think that the 2.0 module cmdlets were exactly what Powershell needed. I come from the land of Perl where modules are an integral part of the community. Well-formed reusable code is something Perl developers take a lot of pride in. Unfortunately, the Powershell community has been very delinquent in picking up the Microsoft implementation of modules. This is mainly due to the lack of a well-designed Internet repository that users can easily install and import from. While this is a difficult task that we have yet to take on in the Powershell community, it is a much easier task to take on in a corporate environment.
Unfortunately, I can’t disclose the name of the company I work for, but I can tell you it is very large with about 100,000 users and plenty of IT folks to support it. When I started there three months ago I was extremely surprised at how amazing their Perl repository and documentation was complete with wiki sites, in-house modules, and distribution of those modules through a globally distributed file system. This was a fountain of information to drink from. Then I went to the Powershell site: ugh – a well of cyanide! The home page still referred to it as Monad! The snapins that were installed to the distributed file system were versions behind, and the documentation really needed an overhaul that reflected the usage of both Powershell 1.0 and 2.0 together.
It was a daunting task, but I quickly volunteered to take it on. Sweating nights and weekends I not only redesigned the documentation, but I put together a module repository that I am extremely proud of. Here’s what I did:
Gathered RequirementsI first spoke with users of Powershell in the company to understand how it’s used, and to understand what ways a module repository could be helpful. I came up with the following requirements:
I had one additional requirement that came from me: Use the built-in cmdlets for modules i.e. Import-Module and Get-Module
Leveraged Existing InfrastructureThe distributed file system they use is extremely custom and is AFS based. While my design could use any CIFS share it was nice to have something with such strict control. I can publish to a \dev workspace for testing. Users only have access to DEV if they have their machines configured to use it via the registry. After testing and development is complete I can lock the DEV instance of a module and publish the files to a read-only file system accessible by all users and servers in the company around the world. The read-only piece is key. If you wind up configuring your in-house module repository using my method I highly recommend making the repository read-only with only a few key accounts having access to publish.
For the remainder of this article we will call the published read-only share: \\powertoe\modulerepo\
Configure the Code Access Security PolicyThis is the only piece that requires administrator privileges. Because the distributed file system we use is already leveraged heavily by other .NET groups within the company this part was already in place in our desktop and server builds. In order to allow .NET to trust a share so it can load .DLLs from it you need to modify the policy with caspol.exe. Caspol.exe can be found in your .NET directory, and documentation about it’s usage can be viewed here.
Here’s a quick batch script that will determine the proper directory to run caspol.exe from, and then call caspol.exe with the proper parameters to configure our system to trust the \\powertoe\modulerepo share:
@echo off setlocal for /f %%a in ('dir %windir%\Microsoft.Net\Framework\v* /b') do @call :caspol %windir%\Microsoft.Net\Framework %%a for /f %%a in ('dir %windir%\Microsoft.NET\Framework64\v* /b') do @call :caspol %windir%\Microsoft.Net\Framework64 %%a endlocal goto :EOF :caspol set sc_dotnetpath=%1 set sc_dotnetversion=%2 %sc_dotnetpath%\%sc_dotnetversion%\caspol -polchgprompt off %sc_dotnetpath%\%sc_dotnetversion%\caspol -m -ag 1 -URL "file://///powertoe/modulerepo/*" FullTrust %sc_dotnetpath%\%sc_dotnetversion%\caspol -polchgprompt on goto :EOFThis step is only necessary if you are either using snapins that you will convert to modules or if your modules load dlls of any kind.
Design the Folder StructureThis was a big hurdle to overcome. Because I needed to nail the versioning of modules for many different purposes I spent a lot of time toying with using the -version parameter of Import-Module. What a dead end that was! The -version parameter seems to have been an afterthought to versions: Documentation that doesn’t work and a backwards method of selecting the highest version of a module frustrated me to no end. You can read a little more of this digression here.
After throwing away “Import-Module -version” I came up with an elegant solution to the problem. I decided I could script the user’s $env:PSModulePath. If you are not aware of how modules become available to the built-in cmdlets Import-Module and Get-Module you should read:
Get-Help about_modulesTo summarize the relevant parts: the environment variable PSModulePath holds the file paths that the built-in cmdlets look in to find modules that are available. For example if the PSModulepath is set to c:\modules and you have a directory in that path called ToeISE with a ToeISE.psm1 or ToeISE.psd1 file it will be an available module when you run:
Get-Module -ListAvailableIf it is in that list you can then load the module with the following:
Import-Module modulenameAs I mentioned I did struggle with trying to use a folder structure like \\powertoe\modulerepo\modulename\version or even \\powertoe\modulerepo\modulename\version\modulename with the $env:PSModulePath pointing to \\powertoe\modulerepo, but nothing worked quite the way I needed it to. In the end I used the following configuration:
\\powertoe\modulerepo\modulename\version\modulename
Design the ProfileTo fix the PSModulePath to point to the latest version of every module in the repository I added the path of the latest module to $env:PSModulePath through a quick one-line script:
Get-ChildItem \\powertoe\modulerepo\|where{$_.psiscontainer}|foreach {Get-ChildItem $_.fullname|Where{$_.psiscontainer}|sort -Descending|select -First 1}|foreach {$env:PSModulePath += ";" + $_.fullname}or for better readability:
Get-ChildItem \\powertoe\modulerepo\|where{$_.psiscontainer}|foreach { Get-ChildItem $_.fullname|Where{$_.psiscontainer}|sort -Descending|select -First 1 }|foreach { $env:PSModulePath += ";" + $_.fullname }In the end, however, I wrapped this one line in a script and published it to \\powertoe\modulerepo\modulerepo.ps1. I documented that users should dot (.) source this script in their profile. It’s a similar copy/paste operation, but it allows me to control the profile of our users if anything in the module repository ever needed to change.
. \\powertoe\modulerepo\modulerepo.ps1There is one small problem with my method: It may not scale very well. As the module repository grows it is possible that the script that loads PSModulePath will be too cumbersome. If that ever happens I can modify modulerepo.ps1 to include the full path for each module. It would then be a part of the controlled distribution process of any module to update this script with the new version of the module uploaded. Rather than introducing a manual point of failure I decided to tackle this problem if the module repository ever grew large enough where it would impact performance. There is also the question of whether performance will ever be hindered by a PSModulePath that becomes too large. Again, a problem I am resolved to tackling down the road if it ever manifests. In the meantime, the above solution gives our users a nice way to use get-module -listavailable and import-module modulename to use the central repository. This works for the latest version of any module, but it doesn’t handle how to specify a version to use.
Controlling Versions in ScriptsThe solution is really a no-brainer. Import-module supports the usage of paths with the -name parameter. So simply users are instructed to use the full path to the .psd1 in their scripts:
Import-Module -name \\powertoe\modulerepo\PowerCLI\4.1.0\PowerCLI.psd1Because we control what gets distributed to the module repository we can enforce standards e.g. Must have a psd1 file, must have inline help with specific fields filled out, must use proper namespaces, etc. Perhaps I will share that bit of information at a later date with you, but I know that there’s something that will interest you much more than an article about best practices. If you read the above example for Import-Module you’ll see that I’m using it on a .psd1 file for PowerCLI – Wait a minute – Does that exist? Does that work? Can anyone guess what I will writing about in a future article?
RecapThey are a cool powerful way of sharing your well-formed code. It is a great way to promote best-practices internally and enforce your policy on reusable code. They are also an amazing utility that lets you quickly browse and install other people’s code. I strongly suggest you start using them. Next stop, let’s do this on the Internet people – a real CPAN-like module repository!
In part 2 we will look at the developer guidelines I created for in-house modules in order to make them suitable for publishing in the repository.
In an article on the Windows IT Pro site - http://www.windowsitpro.com/article/commentary/Bridging-the-Developer-Admin-Gap.aspx – Paul Thurrott states
But the problem with PowerShell is that it's so powerful its indecipherable to admins. PowerShell is arguably a full-blown development environment. It consists of a command-line shell, a .NET-based, object-oriented scripting language, and a runtime engine that can optionally be embedded in other applications. For the typically overworked admins and IT pros, PowerShell might be a godsend if they could actually use it. But I was of the mind in 2002—as I am today—that most admins and IT pros have a completely different set of skills and are overworked as it is. To really take advantage of PowerShell, you need to be a developer or learn those skills too. And finding people who have credible administrative and developer skills is quite a trick. If you're such a person, maybe it's time to ask for a raise.
Now I disagree totally with the crux of this paragraph for a number of reasons:
In 2006/2007 when PowerShell was just getting started I might of agreed that starting with PowerShell could be viewed as a steep learning curve. Four years later I think it is a lot easier – again Windows IT Pro have published a number of articles on PowerShell – with much more information available.
I would turn this on its head and state that if you are a Windows administrator that isn’t using PowerShell you are making your life more difficult that it needs to be.