Windows PowerShell Team Blog

  • New-Object PSObject –Property [HashTable]

    Let me start of by suggesting you take a few minutes and read Laerte Junior’s excellent blog entry Exceptional PowerShell DBA Pt1 Orphaned Users . Laerte does a great job describing the scenario, the approach he took to solving it and then he included the scripts! Really good stuff Laerte! When I looked at Laerte’s code, I recognized one of my least favorite PowerShell V1isms: $Object = New-Object...
  • Free PowerShell EBook

    PowerShell MVP and prodigious PowerShell blogger Keith Hill has converted his very popular Effective PowerShell blog series into a FREE Ebook.  You can download it HERE . Here is a taste of you'll you'll get: Table of Contents Introduction ......................................................................................................................................................
  • How to Create an Object in PowerShell

    Today someone in Xbox Live Operations (the folks that keep xBox Live alive and well) pinged me with a simple question about PowerShell with a complicated answer: “How do I create a class in PowerShell?” There’s two scenarios I find where people want classes.  The first (and most common) is familiarity: the person wants to make a class in PowerShell because they think of problems...
  • Reserving keywords

    A couple months ago we asked our MVPs how they felt about reserving keywords in V2. We received some excellent but mixed feedback, so we’d like to open the discussion up a bit wider. There are keywords we hope to use in a future version of PowerShell, but won’t be implemented in V2. “class”, “using”, and “new” are excellent candidates for additions to PowerShell, but we haven’t decided on the exact...
  • Out-GridView Revisited

    It has been more than one year since we updated Out-GridView feature with you. In case you are not familiar with Out-GridView yet, it is a unique PowerShell cmdlet that users can pipe command output to a separate window, and it enables users organize and analyze output data easily. The previous blog entry by Brent gave an overview of Out-GridView cmdlet. So, what’s new for Out-GridView in Windows PowerShell...
  • dir –a:d

    In cmd, listing files based on attributes was simple: only directories dir /a:d only files (no directories) dir /a:-d only hidden files dir /a:h In PowerShell, it’s not so easy: only directories dir | ? { $_.PSIsContainer } only files (no directories) dir | ? { !$_.PSIsContainer } only hidden files dir -force | ? { $_.Attributes –band [IO.FileAttributes]::Hidden } We have had requests to cover the...
  • Local Boy Makes Good

    Check it out:  http://www.microsoft.com/presspass/exec/de/snover/default.mspx One of the biggest Snoopy Dance moments of my life!   BTW - this is really a reflection of how important Microsoft views PowerShell. I'd love to say more but I've got some Snoopy Dancing to do.   Experiment! Enjoy! Engage! Jeffrey Snover [MSFT] Windows Management Partner Architect Visit the Windows...
  • Active Directory Powershell Blog

    AD team has started a new blog for their PowerShell Cmdlets.. In their own words "We are here to answer any questions about AD Powershell, share some tips and tricks, discuss the history behind certain decisions and features and hear your feedback on improving AD Powershell experience" Check this out http://blogs.msdn.com/adpowershell/ Osama Sajid Read More...
  • Get-ProgID

    The other day, a friend over in Microsoft Research wanted to figure out how to get out the width and height of an image in PowerShell.  There are many ways that you can approach this particular problem.  I knew three right off of the top of my head, but none of them had a really optimal experience. I could use Windows Desktop Search , but then I’d have to wade through shell properties and...
  • Tied Variables in PowerShell

    With Add-Type and $executioncontext you can add special varibles that have tied values. I made $random, and $now add-type @" using System; using System.Management.Automation; public class RandomVariable : PSVariable { Random r; public RandomVariable () : base("Random", 0, ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope) {r = new Random();} public override object Value { get Read...
  • Get closure with GetNewClosure

    Have you ever created scriptblocks on the fly, say in a foreach loop, and they totally mess up because they all have the same value? This is something sort of advanced, and typically used when you’re proxying an object. The most basic example would be, taken from ( http://www.powershellcommunity.org/Forums/tabid/54/aff/1/aft/2506/afv/topic/Default.aspx ) function add([int]$x) { return { param([int...
  • Image Manipulation in PowerShell

    The other week, I showed a Get-ProgID function that I used to help someone at Microsoft Research find a good object to talk to images. A few comments jumped to one of the possible solutions, which is to use the .NET Drawing assembly (which I have to load first). I wanted to be reasonably sure that the way to get at the image metadata was efficient and didn’t require loading up any assemblies PowerShell...
  • Active Directory Administrative Center for Windows Server 2008 R2 implemented using ADPowershell!

    Windows Server 2008 R2 doesn’t just add ADPowershell – it also adds Active Directory Administrative Center (or ADAC), a new GUI tool for AD administrators. Read about it on TechNet . What’s more, while you can’t tell just from looking at it, ADAC is implemented entirely over Windows PowerShell 2.0 and ADPowershell! Every read and write to AD goes through ADPowerShell. So, if you were wondering whether...
  • Many² ways you can set a variable value

    There are many ways to set a variable's value. I just learnt one more yesterday. If you have others, please add comments # Simple # $ gets the variable, and = will assign it $a = 1 # With Variable Scope # The prepend is the scope, and could be global, script, and others # Useful when you want to keep things in script scope, or share them out in global scope $global:a = 1 # Complex variable names...
  • Setting Network Location to Private

    The Network Location feature was introduced in Windows Vista. It provides an easy way to customize your firewall settings based on whether you trust or don’t trust the computers around you. There are three Network Location types - Private, Public and Domain. If your computer is a member of the domain then you won’t be able to change the Network Location type. If your computer is standalone or part...
1 2 3 4 5 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.