Archive for the 'Downloads' Category

Windows PowerShell : Show-WmiClass

Jeffrey Snover of Microsoft posted this script to provide a simple way to show WMI Classes within PowerShell.

Here is a script that I use to show WMI classes. I think you’ll find it useful. There is an example after the script:

##############################
# Show-WmiClass - Show WMI classes
# Author: Microsoft
# Version: 1.0
# NOTE: Notice that this is uses the verb SHOW vs GET. That is because it
# combines a Getter with a format. SHOW was added as a new “official
# verb to deal with just this case.
#############################
param(
$Name = “.”,
$NameSpace = “root\cimv2″,
[Switch]$Refresh=$false
)
# Getting a list of classes can be expensive and the list changes infrequently.
# This makes it a good candidate for caching.
$CacheDir = Join-path $env:Temp “WMIClasses”
$CacheFile = Join-Path $CacheDir ($Namespace.Replace(”\”,”-”) + “.csv”)
if (!(Test-Path $CacheDir))
{
$null = New-Item -Type Directory -Force $CacheDir
}
if (!(Test-Path $CacheFile) -Or $Refresh)
{
Get-WmiObject -List -Namespace:$Namespace |
Sort -Property Name |
Select -Property Name |
Export-csv -Path $CacheFile -Force
}
Import-csv -Path $CacheFile |
where {$_.Name -match $Name} |
Format-Wide -AutoSize
###### EOF ###########

Example

PS> show-wmiclass account
MSFT_NetBadAccount Win32_Account Win32_AccountSID
Win32_SystemAccount Win32_UserAccount
PS> show-wmiclass account -namespace root\cimv2\terminalservices
Win32_TSAccount
PS> show-wmiclass -namespace root\cimv2\terminalservices
__AbsoluteTimerInstruction __ACE
__AggregateEvent __ClassCreationEvent
__ClassDeletionEvent __ClassModificationEvent
__ClassOperationEvent __ClassProviderRegistration
__ConsumerFailureEvent __Event
__EventConsumer __EventConsumerProviderRegistration
__EventDroppedEvent __EventFilter
__EventGenerator __EventProviderRegistration
__EventQueueOverflowEvent __ExtendedStatus
__ExtrinsicEvent __FilterToConsumerBinding
__IndicationRelated __InstanceCreationEvent
__InstanceDeletionEvent __InstanceModificationEvent
__InstanceOperationEvent __InstanceProviderRegistration
__IntervalTimerInstruction __MethodInvocationEvent
__MethodProviderRegistration __NAMESPACE
__NamespaceCreationEvent __NamespaceDeletionEvent
__NamespaceModificationEvent __NamespaceOperationEvent
__NotifyStatus __NTLMUser9X
__ObjectProviderRegistration __PARAMETERS
__PropertyProviderRegistration __Provider
__ProviderRegistration __QOSFailureEvent
__SecurityDescriptor __SecurityRelatedClass
__SystemClass __SystemEvent
__SystemSecurity __thisNAMESPACE
__TimerEvent __TimerInstruction
__TimerNextFiring __Trustee
__Win32Provider CIM_ElementSetting
CIM_LogicalElement CIM_ManagedSystemElement
CIM_Setting Win32_Terminal
Win32_TerminalError Win32_TerminalServiceSetting
Win32_TerminalServiceSettingError Win32_TerminalServiceToSetting
Win32_TerminalSetting Win32_TerminalTerminalSetting
Win32_TSAccount Win32_TSClientSetting
Win32_TSEnvironmentSetting Win32_TSGeneralSetting
Win32_TSLogonSetting Win32_TSNetworkAdapterListSetting
Win32_TSNetworkAdapterSetting Win32_TSPermissionsSetting
Win32_TSRemoteControlSetting Win32_TSSessionDirectory
Win32_TSSessionDirectorySetting Win32_TSSessionSetting
PS>

Windows PowerShell : Show-WmiClass

PowerShell Toolbox

Adam Bell has a detailed, growing list of PowerShell tools that are currently available.  Bookmark the page as new tools are added when available.

Here is a sample:

/N Software NetCmdlets
- a broad range of network management and messaging capabilities. The current release contains more than 30 Cmdlets providing access to network and host protocols such as SNMP, LDAP, DNS, Syslog, HTTP, WebDav, FTP, SMTP, POP, IMAP, Rexec/RShell, Telnet, and more. This is a commercial product.

Codeplex PoshConsole
- utilises WPF features to improve on the PS shell. This tool aims to be a more modern replacement for the default shell. This is an open source product.

Codeplex PowerShell Community Extensions
- working towards providing widely useful set of additional cmdlets, providers, aliases, filters, functions and scripts for PowerShell. This is an open source product.

Codeplex PSEventing
- Trap and respond to synchronous & asynchronous .NET events within your powershell scripts with an easy to use suite of cmdlets. This is an open source product.

Microsoft PowerShell SDK
- The Windows PowerShell SDK is written for command developers who require reference information about the APIs provided by Windows PowerShell. This is a free download from MSDN.

PowerGadgets
- data visualization product that creates gadgets for displaying output from your PS data in Windows. Very simple to create. This is a commercial product.

PowerLocker PowerPad
- a small editor to develop and test your function or script. This is a free product.

Quest ActiveRoles Management Shell for AD (aka Quest AD Cmdlets)
- perform administrative tasks like discovering the AD environment, changing user properties, modifying group membership, provisioning new user accounts, and performing multiple other tasks within Active Directory. This is a free product.

Quest PowerGUI
- an extensible graphical administrative console for managing systems based on Windows PowerShell. This is a free product.

SAPIEN PrimalScript 2007
- fully-customizable user interface with multiple tabs, dockable pane, IDE for use with PowerShell and other scripting languages. This is a commercial product.

You can view the entire list here

Lead, Follow, or Move ยป PowerShell Toolbox

Allowing scripts to be run via PowerShell

Running scripts via Powershell is disable by default.  There is a key to note that you can run commands or cmdlets from the PowerShell console, just not scripts.  To enable this feature you can do one of two things, however one trumps the other:

Via PowerShell

Modify your ExecutionPolicy via the Set-Execution cmdlet

First run Get-ExecutionPolicy to see what level you are at.  By default, this setting is set to Restricted. 

To see what settings are available for you to set, you can type

Get-Help Set-ExecutionPolicy

This output shows that we have four options:  Restricted, AllSigned, RemoteSigned, and Unrestricted.

To set your ExecutionPolicy to Unrestricted (not recommended for production) you would enter:

Set-ExecutionPolicy Unrestricted

To validate you settings after running the Set-ExecutionPolicy, run:

Get-ExecutionPolicy

From the command above, your ExecutionPolicy is now set to Unrestricted.  You can now run any scripts you like, signed or unsigned. (Bet your administrator is happy to hear that!)

Now for the other method for setting this policy

Via Group Policy

Seeing how the first method would be a nightmare to manage, Microsoft has released the ADM files for PowerShell that allow you to configure this setting via Group Policy.  Any settings made via Group Policy will overwrite those set manually via the PowerShell Console. 

powershellADM 

You can download the PowerShell ADM here

Evaluate the Windows Server 2008 Public Beta today

Download and install Windows Server 2008 Beta 3 and the check out the various step-by-step guides and scenarios located at:

https://windowsbeta.microsoft.com/server/intro.aspx

Evaluate the Windows Server 2008 Public Beta today