Free PowerShell Commands for Active Directory
Only recently I stumble over Quest “ActiveRoles Management Shell for Active Directory”, a free cmdlets for scripting with AD as a source (and destination). For example, all you need to spool users with their descriptions from AD into csv file is this one liner:
[PS] E:\>Get-QADUser -sizeLimit 0 | select name, Description | Export-Csv ADusers.csv
In addition to “ActiveRoles Management Shell for Active Directory”, you’ll need to install PowerShell itself and Microsoft Core XML Services – if they’re not already installed on your machine (Quest installer will prompt you if that’s is the case).
In “Quest Software” program directory you’ll find link named “ActiveRoles Management Shell for Active Directory” which starts PowerShell.
One problem that I could not find a solution for, is related to spooled file encoding which will loose all non-ASCII characters in my environment (CP1250 for GUI, CP852 for command prompt), even after specifying UTF8 encoding like this:
[PS] E:\>Get-QADUser -sizeLimit 0 | select name, Description | Export-Csv ADusers.csv [PS] E:\>$OutputEncoding BodyName : utf-8 EncodingName : Unicode (UTF-8) HeaderName : utf-8 WebName : utf-8 WindowsCodePage : 1200 IsBrowserDisplay : True IsBrowserSave : True IsMailNewsDisplay : True IsMailNewsSave : True IsSingleByte : False EncoderFallback : System.Text.EncoderReplacementFallback DecoderFallback : System.Text.DecoderReplacementFallback IsReadOnly : True CodePage : 65001
I also tried with console encoding:
[PS] E:\>$OutputEncoding = [console]::OutputEncoding [PS] E:\>$OutputEncoding IsSingleByte : True BodyName : ibm852 EncodingName : Central European (DOS) HeaderName : ibm852 WebName : ibm852 WindowsCodePage : 1250 IsBrowserDisplay : True IsBrowserSave : True IsMailNewsDisplay : False IsMailNewsSave : False EncoderFallback : System.Text.InternalEncoderBestFitFallback DecoderFallback : System.Text.InternalDecoderBestFitFallback IsReadOnly : True CodePage : 852
No luck – in .csv file all “special” characters are lost.
Posted on 30.07.2008, in Scripting and tagged powershell, Scripting. Bookmark the permalink. Comments Off on Free PowerShell Commands for Active Directory.