Archive for July, 2010

Locating obsolete users and computers

Just got easier (and faster!) in AD cmdlets 1.4! Before this release you still could manually filter user or computer records by pwdLastSet or LastLogonTimestamp – now user and computer retrieval by a bunch of attributes with an easy command like:

Get-QADUser -Inactive


Get-QADComputer -Inactive

This -Inactive parameter retrieves all accounts which have been in expired state, not used for logon, or with with password not being changed beyond the thresholds set by the  Set-QADInactiveAccountsPolicy cmdlet. Like this:

Set-QADInactiveAccountsPolicy -AccountExpiredPeriod 0 -AccountNotLoggedOnPeriod 30 -PasswordNotChangedPeriod 120

You can get the current settings in your environment by executing Get-QADInactiveAccountsPolicy.

In addition to -Inactive, there are other related parameters, such as -InactiveFor – which lets you specify the number of days the account has been in the inactive state:

Get-QADComputer -InactiveFor 30

Or you can go more granular and just use:

NotLoggedOnFor – to specify the number of days since last time the account was used to log on (note that LastLogonTimestamp parameter is used, which means that it is replicated between DCs and the retrieval is fast and works with any domain controller, but it requires 2003 or later AD schema and is only replicated every 9-14 days (so please don’t specify values less than 14):

Get-QADUser -NotLoggedOnFor 60

Get-QADComputer -NotLoggedOnFor 60

PasswordNotChangedFor – days since the account last changed password (computer accounts also have passwords which they are automatically rolling over):

Get-QADUser -PasswordNotChangedFor 180

Get-QADComputer -PasswordNotChangedFor 90

ExpiredFor – just for Get-QADUser – the number of days since the account expired:

Get-QADUser -ExpiredFor 30

You can also use a combination of Inactive/InactiveFor and ExpiredFor/NotLoggedOnFor/PasswordNotChangedFor – in which case the more specific parameters override the default inactivity criteria you set.

Read more about these cmdlets and their parameters in our online reference:

Custom script header and other snippets

Check out the snippets for PowerGUI Script Editor that Bhargav Shukla just shared here. They offer nice templates which you can re-use when working on your scripts.

I downloaded and extracted the files to the snippets folder:

Started PowerGUI Script Editor, pressed Ctrl-I and could see the new snippets:

Here is what – for example – Custom_Script.Header gave me – very handy!

Check out these snippets here. And obviously if you have you own custom snippets that you created and are using – please consider sharing them with the community. 🙂

Creating your first PowerGUI Script Editor Add-On

We’ve published a step by step tutorial on creating add-ons for PowerGUI Script Editor. It takes you from the obligatory ‘Hello World’ example (I am sure you have always wanted PowerGUI Editor to show this at start-up! :)) all the way through creating a useful add-on (actually the Clear Console add-on we have) with menu item, proper clean up code, and so on.

We also made available full add-on SDK which documents all the APIs we expose.

These are more powerful than ISE extensibility points. Giving you the ability to redefine (or intercept and ammend) any standard functionality in PowerGUI Script Editor, add your own menu and toolbar items (anywhere), event-handlers, and even custom dockable panes within the editor. With the SDK we provide, the sky is really the limit.

PowerGUI Script Editor is one of the richest PowerShell IDEs out there and add-ons take it to the next level. We already have some really useful add-ons – and hopefully the tutorial and SDK can help you add whatever functionality you were missing.

Give them a try and let us know what you think!

Visual Studio PowerShell Add-On live interview today

[UPDATE] If you missed the live interview, the recording is available here.

At 9:30 pm EST/6:30 pm PST join PowerScripting podcast hosts and Adam Driscoll to learn more about how you can have rich PowerShell scripting environment right in Visual Studio.

While I personally mostly use PowerGUI Script Editor and think that this is the best tools for IT professionals, software developers use and love Visual Studio and it is great that they can now develop PowerShell parts of their projects without ever leaving their favorite tool. 🙂

So tonight at 9:30 pm EST/6:30 pm PST join the live interview & chat, hear what others are saying and ask questions on your own!

PowerGUI Editor 2.1.1 and AD cmdlets 1.4 compatibility issue

[UPDATE] This issue got fixed in PowerGUI 2.2.

We have found that in some cases when you are using version 1.4.0 of QAD cmdlets inside PowerGUI Script Editor 2.1.1, and invoke a script with the cmdlets for the second time you may get the error: “Object reference not set to an instance of an object.

This is obviously very unfortunate and we are working on fixing the issue. In the meantime there are a couple of workarounds you can use:

A. Run Script Editor in MTA mode (if you don’t know what STA/MTA mean – this means that you would likely not notice any difference – but as a side-effect it might affect some script editor add-ons or your scripts using WPF)

To do this, just modify the PowerGUI Script Editor shortcut:

and add the -MTA switch to the command line:

B. Alternatively, you can set PowerGUI Script Editor to reset PowerShell runspace each time you start debugging:

1. In PowerGUI Script Editor, on the Tools menu, click Options,

2. In Debug Options, select Reset PowerShell runspace each time debugging is started.

Again, we appologise for the inconvenience and are working on a perminent fix.

What’s New in AD cmdlets 1.4

Don’t get confused by the version number – this is a major update to the free QAD cmdlets adding significant new functionality and making Active Directory management from PowerShell easier than ever before.

Here is a quick list of what is new in this release.

You can read more about each cmdlet and parameter by following the corresponding links – or waiting till I blog about all the new functionality throughout the coming weeks.

32 new cmdlets!

Certificate and Public Key Infrastructure (PKI) management

Email address management

Auxiliary cmdlets for Progress Bar and Inactive Account Reporting

20 New Parameters

Parameters Added for Cmdlets

































ResolveForeignSecurityPrincipals Get-QADObject
Control Add-QADGroupMember











































SearchRoot parameter now accepting arrays

This lets you retrieve objects from multiple containers with one call. The change affects the following cmdlets:

  • Get-QADComputer
  • Get-QADGroup
  • Get-QADObject
  • Get-QADPasswordSettingsObject
  • Get-QADUser
  • Get-QARSAccessTemplate
  • Get-QARSAccessTemplateLink
  • Get-QARSWorkflowDefinition
  • Summary

    To get full list of all QAD cmdlets please see AD cmdlets online reference.

    Download AD cmdlets 1.4 here and let us know what you think.

    Top 7 Script Editor Add-Ons

    Here is the run down of the most popular add-ons available for the PowerGUI Script Editor which can make your PowerShell scripting and debugging experience even more exciting:

    1. PowerShell Script Signing – by far the number one add-on which already had more than 300 downloads.

    • Digitally sign any signable PowerShell file
    • Test the signature on any signed PowerShell file and view its details
    • Select a default script signing certificate from a list of valid code signing certificates
    • Automatically save files when you sign them
    • Configure which certificates to include in the signatures that are applied to files you sign
    • Optionally specify a timestamp server to be used when signing your files (recommended)

    2. Believe it or not add-on changing the interactive PowerShell Console pane to familiar white on blue color scheme is number 2 in the charts with 165 downloads at this very moment.

    • Use a theme similar to the native Blue PowerShell Console right from inside the PowerGUI Script Editor

    3. Clear PowerShell Console – 131 download so far:

    • Clear your embedded PowerShell Console by pressing Ctrl+R or selecting ViewClear PowerShell Console

    4. Transcription Support has 108 downloads:

    • Full support for Start-Transcript and Stop-Transcript in the embedded PowerShell Console

    5. Expand Alias – 86 downloads:

    • Expand aliases in the code pane to the full cmdlet name by pressing Ctrl+E or selecting Tools | ExpandAlias

    6. Smart Execute Selection / Debug switcher – 68 downloads:

    • This Script Editor Add-on assigns the same shortcut key (F5) to run all code (Start Debugging) or selected code (Execute Selection). It also adds a new menu item ‘Run Code’ under the Tools menu.
    • Allows to run all code or selected code with one keyboard shortcut, F5.

    7. Publish PowerShell Scripts Online – 53 downloads:

    • Allows you to publish any file you have open in the Script Editor on
    • Preserves configuration for individual files so that you don’t have to re-enter the same information when publishing updates.

    I love all of these and I highly recommend checking them out. Keep your eye on the PowerGUI Script Editor add-ons library – there is more great stuff coming.

    More handy Script Editor Add-Ons

    Ctrl-R can clear PowerShell Console, F5 will execute code selection if you have anything selected or start regular debugging session – if you don’t.

    These are just another couple of very handy add-ons for PowerGUI Script Editor published recently by Kirk and Shay.

    Visit PowerGUI library to find a complete list of Script Editor add-ons – they will make your life easier and more exciting. You can also subscribe to its RSS feed or set email alerts (by setting watch on the library) to get notified on any new add-ons published.

    And, if you come up with any add-ons of your own – please consider sharing those as well. 🙂

    Something blue

    Now you can change the color of the interactive PowerShell Console pane in PowerGUI Script Editor with this add-on posted by Kirk.

    PowerShell Console pane has always been my favorite feature of the script editor. It is extremely handy to be able to easily go from regular debugging to interactive PowerShell and back – and the fact that they are sharing the same PowerShell runspace so you can inspect your variables and environment and even change them right inside a debugging session is making debugging so much easier.

    The only drawback the PowerShell Console had was its color. 🙂 Or to be precise inability to change it. Black on white is very readable and inline with Windows guidelines but if you are a hardcore PowerShell geek – chances are you might want it blue. Now all you need to do is use this add-on:

    The add-on is actually just a PowerShell script module so you can edit it to change to whatever other fancy color scheme you might want your PowerShell to be. 😉

    Download and install the Blue Console add-on and let us know what you think!

    Automatic alias expansion in Script Editor

    This add-on just posted by Shay to adds a nifty Expand Alias menu item to the PowerGUI Script Editor:

    Which then let you turn a script like this:

    Into something way more readable like that:

    Very handy when you are trying to figure out what exactly this script you got from the internet is doing. 🙂

    Download the add-on here.

    My Recent Tweets


    The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my employer - WSO2 or anyone else for that matter. All trademarks acknowledged.

    © 2007-2014 Dmitry Sotnikov

    July 2010
    M T W T F S S

    %d bloggers like this: