The Multifunctioning DBA

Oct 22 2008   4:25PM GMT

Why Powershell?

Colin Smith Colin Smith Profile: Colin Smith

In my first few posts here I have done a lot of things in Windows Powershell. Some of you may be asking why Powershell and I am busy asking why not Powershell. Since being introduced to Powershell any time I hear a request to do just about anything in Windows I think about how I can script that using Powershell. My team thinks that I should get compensation from Microsoft since I bring it up so much. We all laugh about it but I really think that if you want to continue to grow with Microsoft products then you need to learn Powershell.

If you do not already know, Powershell is Microsoft’s new Shell Scripting Language. It is object oriented and has a pipe. The pipe is a great tool that UNIX users have enjoyed forever and now we all get to enjoy the power of the pipe. Powershell is made up of commandlets. These are the commands that you will use to do things with objects. They use a standard verb-noun syntax so it is easy to understand. An example of one of the commandlets is as follows. This is a very useful command as it will tell you what other commands are available to you.


PowerShellPlus 1.0.4.7
(C) 2007-2008 Scriptinternals. All Rights Reserved.

PowerTab version 0.99 Beta 2 PowerShell TabExpansion library
/\/\o\/\/ 2007 http://thePowerShellGuy.com
PowerTab Tabexpansion additions enabled : True
PS C:\Documents and Settings\smithc> Get-Command

CommandType     Name                                                                  Definition
———–     —-                                                                  ———-
Cmdlet          Add-Content                                                           Add-Content [-Path] <String[]> [-Value] <Object[]> [-PassThru] [-...
Cmdlet          Add-History                                                           Add-History [[-InputObject] <PSObject[]>] [-Passthru] [-Verbose] …
Cmdlet          Add-Member                                                            Add-Member [-MemberType] <PSMemberTypes> [-Name] <String> [[-Valu...
Cmdlet          Add-PSSnapin                                                          Add-PSSnapin [-Name] <String[]> [-PassThru] [-Verbose] [-Debug] [...
Cmdlet          Clear-Content                                                         Clear-Content [-Path] <String[]> [-Filter <String>] [-Include <St...
Cmdlet          Clear-Item                                                            Clear-Item [-Path] <String[]> [-Force] [-Filter <String>] [-Inclu...
Cmdlet          Clear-ItemProperty                                                    Clear-ItemProperty [-Path] <String[]> [-Name] <String> [-PassThru...
Cmdlet          Clear-Variable                                                        Clear-Variable [-Name] <String[]> [-Include <String[]>] [-Exclude...
Cmdlet          Compare-Object                                                        Compare-Object [-ReferenceObject] <PSObject[]> [-DifferenceObject...
Cmdlet          ConvertFrom-SecureString                                              ConvertFrom-SecureString [-SecureString] <SecureString> [[-Secure...
Cmdlet          Convert-Path                                                          Convert-Path [-Path] <String[]> [-Verbose] [-Debug] [-ErrorAction...
Cmdlet          ConvertTo-Html                                                        ConvertTo-Html [[-Property] <Object[]>] [-InputObject <PSObject>]…
Cmdlet          ConvertTo-SecureString                                                ConvertTo-SecureString [-String] <String> [[-SecureKey] <SecureSt…
Cmdlet          Copy-Item                                                             Copy-Item [-Path] <String[]> [[-Destination] <String>] [-Containe...
Cmdlet          Copy-ItemProperty                                                     Copy-ItemProperty [-Path] <String[]> [-Destination] <String> [-Na...
Cmdlet          Export-Alias                                                          Export-Alias [-Path] <String> [[-Name] <String[]>] [-PassThru] [-...
Cmdlet          Export-Clixml                                                         Export-Clixml [-Path] <String> [-Depth <Int32>] -InputObject <PSO…
Cmdlet          Export-Console                                                        Export-Console [[-Path] <String>] [-Force] [-NoClobber] [-Verbose...
Cmdlet          Export-Csv                                                            Export-Csv [-Path] <String> -InputObject <PSObject> [-Force] [-No...
Cmdlet          ForEach-Object                                                        ForEach-Object [-Process] <ScriptBlock[]> [-InputObject <PSObject...
Cmdlet          Format-Custom                                                         Format-Custom [[-Property] <Object[]>] [-Depth <Int32>] [-GroupBy...
Cmdlet          Format-List                                                           Format-List [[-Property] <Object[]>] [-GroupBy <Object>] [-View <...
Cmdlet          Format-Table                                                          Format-Table [[-Property] <Object[]>] [-AutoSize] [-HideTableHead...
Cmdlet          Format-Wide                                                           Format-Wide [[-Property] <Object>] [-AutoSize] [-Column <Int32>] …
Cmdlet          Get-Acl                                                               Get-Acl [[-Path] <String[]>] [-Audit] [-Filter <String>] [-Includ...
Cmdlet          Get-Alias                                                             Get-Alias [[-Name] <String[]>] [-Exclude <String[]>] [-Scope <Str...
Cmdlet          Get-AuthenticodeSignature                                             Get-AuthenticodeSignature [-FilePath] <String[]> [-Verbose] [-Deb...
Cmdlet          Get-ChildItem                                                         Get-ChildItem [[-Path] <String[]>] [[-Filter] <String>] [-Include...
Cmdlet          Get-Command                                                           Get-Command [[-ArgumentList] <Object[]>] [-Verb <String[]>] [-Nou...
Cmdlet          Get-Content                                                           Get-Content [-Path] <String[]> [-ReadCount <Int64>] [-TotalCount ...
Cmdlet          Get-Credential                                                        Get-Credential [-Credential] <PSCredential> [-Verbose] [-Debug] [...
Cmdlet          Get-Culture                                                           Get-Culture [-Verbose] [-Debug] [-ErrorAction <ActionPreference>]…
Cmdlet          Get-Date                                                              Get-Date [[-Date] <DateTime>] [-Year <Int32>] [-Month <Int32>] [-...
Cmdlet          Get-EventLog                                                          Get-EventLog [-LogName] <String> [-Newest <Int32>] [-Verbose] [-D...
Cmdlet          Get-ExecutionPolicy                                                   Get-ExecutionPolicy [-Verbose] [-Debug] [-ErrorAction <ActionPref...
Cmdlet          Get-Help                                                              Get-Help [[-Name] <String>] [-Category <String[]>] [-Component <S...
Cmdlet          Get-History                                                           Get-History [[-Id] <Int64[]>] [[-Count] <Int32>] [-Verbose] [-Deb...
Cmdlet          Get-Host                                                              Get-Host [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-...
Cmdlet          Get-Item                                                              Get-Item [-Path] <String[]> [-Filter <String>] [-Include <String[...
Cmdlet          Get-ItemProperty                                                      Get-ItemProperty [-Path] <String[]> [[-Name] <String[]>] [-Filter...
Cmdlet          Get-Location                                                          Get-Location [-PSProvider <String[]>] [-PSDrive <String[]>] [-Ver...
Cmdlet          Get-Member                                                            Get-Member [[-Name] <String[]>] [-InputObject <PSObject>] [-Membe...
Cmdlet          Get-PfxCertificate                                                    Get-PfxCertificate [-FilePath] <String[]> [-Verbose] [-Debug] [-E...
Cmdlet          Get-Process                                                           Get-Process [[-Name] <String[]>] [-Verbose] [-Debug] [-ErrorActio...
Cmdlet          Get-PSDrive                                                           Get-PSDrive [[-Name] <String[]>] [-Scope <String>] [-PSProvider <...
Cmdlet          Get-PSProvider                                                        Get-PSProvider [[-PSProvider] <String[]>] [-Verbose] [-Debug] [-E...
Cmdlet          Get-PSSnapin                                                          Get-PSSnapin [[-Name] <String[]>] [-Registered] [-Verbose] [-Debu...
Cmdlet          Get-Service                                                           Get-Service [[-Name] <String[]>] [-Include <String[]>] [-Exclude ...
Cmdlet          Get-TraceSource                                                       Get-TraceSource [[-Name] <String[]>] [-Verbose] [-Debug] [-ErrorA...
Cmdlet          Get-UICulture                                                         Get-UICulture [-Verbose] [-Debug] [-ErrorAction <ActionPreference...
Cmdlet          Get-Unique                                                            Get-Unique [-InputObject <PSObject>] [-AsString] [-Verbose] [-Deb...
Cmdlet          Get-Variable                                                          Get-Variable [[-Name] <String[]>] [-ValueOnly] [-Include <String[...
Cmdlet          Get-WmiObject                                                         Get-WmiObject [-Class] <String> [[-Property] <String[]>] [-Filter...
Cmdlet          Group-Object                                                          Group-Object [[-Property] <Object[]>] [-NoElement] [-InputObject ...
Cmdlet          Import-Alias                                                          Import-Alias [-Path] <String> [-Scope <String>] [-PassThru] [-For...
Cmdlet          Import-Clixml                                                         Import-Clixml [-Path] <String[]> [-Verbose] [-Debug] [-ErrorActio...
Cmdlet          Import-Csv                                                            Import-Csv [-Path] <String[]> [-Verbose] [-Debug] [-ErrorAction <...
Cmdlet          Invoke-Expression                                                     Invoke-Expression [-Command] <String> [-Verbose] [-Debug] [-Error...
Cmdlet          Invoke-History                                                        Invoke-History [[-Id] <String>] [-Verbose] [-Debug] [-ErrorAction...
Cmdlet          Invoke-Item                                                           Invoke-Item [-Path] <String[]> [-Filter <String>] [-Include <Stri...
Cmdlet          Join-Path                                                             Join-Path [-Path] <String[]> [-ChildPath] <String> [-Resolve] [-C...
Cmdlet          Measure-Command                                                       Measure-Command [-Expression] <ScriptBlock> [-InputObject <PSObje...
Cmdlet          Measure-Object                                                        Measure-Object [[-Property] <String[]>] [-InputObject <PSObject>]…
Cmdlet          Move-Item                                                             Move-Item [-Path] <String[]> [[-Destination] <String>] [-Force] [...
Cmdlet          Move-ItemProperty                                                     Move-ItemProperty [-Path] <String[]> [-Destination] <String> [-Na...
Cmdlet          New-Alias                                                             New-Alias [-Name] <String> [-Value] <String> [-Description <Strin...
Cmdlet          New-Item                                                              New-Item [-Path] <String[]> [-ItemType <String>] [-Value <Object>...
Cmdlet          New-ItemProperty                                                      New-ItemProperty [-Path] <String[]> [-Name] <String> [-PropertyTy...
Cmdlet          New-Object                                                            New-Object [-TypeName] <String> [[-ArgumentList] <Object[]>] [-Ve...
Cmdlet          New-PSDrive                                                           New-PSDrive [-Name] <String> [-PSProvider] <String> [-Root] <Stri…
Cmdlet          New-Service                                                           New-Service [-Name] <String> [-BinaryPathName] <String> [-Display...
Cmdlet          New-TimeSpan                                                          New-TimeSpan [[-Start] <DateTime>] [[-End] <DateTime>] [-Verbose]…
Cmdlet          New-Variable                                                          New-Variable [-Name] <String> [[-Value] <Object>] [-Description <...
Cmdlet          Out-Default                                                           Out-Default [-InputObject <PSObject>] [-Verbose] [-Debug] [-Error...
Cmdlet          Out-File                                                              Out-File [-FilePath] <String> [[-Encoding] <String>] [-Append] [-...
Cmdlet          Out-Host                                                              Out-Host [-Paging] [-InputObject <PSObject>] [-Verbose] [-Debug] …
Cmdlet          Out-Null                                                              Out-Null [-InputObject <PSObject>] [-Verbose] [-Debug] [-ErrorAct...
Cmdlet          Out-Printer                                                           Out-Printer [[-Name] <String>] [-InputObject <PSObject>] [-Verbos...
Cmdlet          Out-String                                                            Out-String [-Stream] [-Width <Int32>] [-InputObject <PSObject>] [...
Cmdlet          Pop-Location                                                          Pop-Location [-PassThru] [-StackName <String>] [-Verbose] [-Debug...
Cmdlet          Push-Location                                                         Push-Location [[-Path] <String>] [-PassThru] [-StackName <String>...
Cmdlet          Read-Host                                                             Read-Host [[-Prompt] <Object>] [-AsSecureString] [-Verbose] [-Deb...
Cmdlet          Remove-Item                                                           Remove-Item [-Path] <String[]> [-Filter <String>] [-Include <Stri...
Cmdlet          Remove-ItemProperty                                                   Remove-ItemProperty [-Path] <String[]> [-Name] <String[]> [-Force...
Cmdlet          Remove-PSDrive                                                        Remove-PSDrive [-Name] <String[]> [-PSProvider <String[]>] [-Scop...
Cmdlet          Remove-PSSnapin                                                       Remove-PSSnapin [-Name] <String[]> [-PassThru] [-Verbose] [-Debug...
Cmdlet          Remove-Variable                                                       Remove-Variable [-Name] <String[]> [-Include <String[]>] [-Exclud...
Cmdlet          Rename-Item                                                           Rename-Item [-Path] <String> [-NewName] <String> [-Force] [-PassT...
Cmdlet          Rename-ItemProperty                                                   Rename-ItemProperty [-Path] <String> [-Name] <String> [-NewName] …
Cmdlet          Resolve-Path                                                          Resolve-Path [-Path] <String[]> [-Credential <PSCredential>] [-Ve...
Cmdlet          Restart-Service                                                       Restart-Service [-Name] <String[]> [-Force] [-PassThru] [-Include...
Cmdlet          Resume-Service                                                        Resume-Service [-Name] <String[]> [-PassThru] [-Include <String[]…
Cmdlet          Select-Object                                                         Select-Object [[-Property] <Object[]>] [-InputObject <PSObject>] …
Cmdlet          Select-String                                                         Select-String [-Pattern] <String[]> -InputObject <PSObject> [-Sim...
Cmdlet          Set-Acl                                                               Set-Acl [-Path] <String[]> [-AclObject] <ObjectSecurity> [-Passth...
Cmdlet          Set-Alias                                                             Set-Alias [-Name] <String> [-Value] <String> [-Description <Strin...
Cmdlet          Set-AuthenticodeSignature                                             Set-AuthenticodeSignature [-FilePath] <String[]> [-Certificate] <…
Cmdlet          Set-Content                                                           Set-Content [-Path] <String[]> [-Value] <Object[]> [-PassThru] [-...
Cmdlet          Set-Date                                                              Set-Date [-Date] <DateTime> [-DisplayHint <DisplayHintType>] [-Ve...
Cmdlet          Set-ExecutionPolicy                                                   Set-ExecutionPolicy [-ExecutionPolicy] <ExecutionPolicy> [-Verbos...
Cmdlet          Set-Item                                                              Set-Item [-Path] <String[]> [[-Value] <Object>] [-Force] [-PassTh...
Cmdlet          Set-ItemProperty                                                      Set-ItemProperty [-Path] <String[]> [-Name] <String> [-Value] <Ob…
Cmdlet          Set-Location                                                          Set-Location [[-Path] <String>] [-PassThru] [-Verbose] [-Debug] [...
Cmdlet          Set-PSDebug                                                           Set-PSDebug [-Trace <Int32>] [-Step] [-Strict] [-Verbose] [-Debug...
Cmdlet          Set-Service                                                           Set-Service [-Name] <String> [-DisplayName <String>] [-Descriptio...
Cmdlet          Set-TraceSource                                                       Set-TraceSource [-Name] <String[]> [[-Option] <PSTraceSourceOptio…
Cmdlet          Set-Variable                                                          Set-Variable [-Name] <String[]> [[-Value] <Object>] [-Include <St...
Cmdlet          Sort-Object                                                           Sort-Object [[-Property] <Object[]>] [-Descending] [-Unique] [-In...
Cmdlet          Split-Path                                                            Split-Path [-Path] <String[]> [-LiteralPath <String[]>] [-Parent]…
Cmdlet          Start-Service                                                         Start-Service [-Name] <String[]> [-PassThru] [-Include <String[]>…
Cmdlet          Start-Sleep                                                           Start-Sleep [-Seconds] <Int32> [-Verbose] [-Debug] [-ErrorAction ...
Cmdlet          Start-Transcript                                                      Start-Transcript [[-Path] <String>] [-Append] [-Force] [-NoClobbe...
Cmdlet          Stop-Process                                                          Stop-Process [-Id] <Int32[]> [-PassThru] [-Verbose] [-Debug] [-Er...
Cmdlet          Stop-Service                                                          Stop-Service [-Name] <String[]> [-Force] [-PassThru] [-Include <S...
Cmdlet          Stop-Transcript                                                       Stop-Transcript [-Verbose] [-Debug] [-ErrorAction <ActionPreferen...
Cmdlet          Suspend-Service                                                       Suspend-Service [-Name] <String[]> [-PassThru] [-Include <String[...
Cmdlet          Tee-Object                                                            Tee-Object [-FilePath] <String> [-InputObject <PSObject>] [-Verbo...
Cmdlet          Test-Path                                                             Test-Path [-Path] <String[]> [-Filter <String>] [-Include <String...
Cmdlet          Trace-Command                                                         Trace-Command [-Name] <String[]> [-Expression] <ScriptBlock> [[-O...
Cmdlet          Update-FormatData                                                     Update-FormatData [[-AppendPath] <String[]>] [-PrependPath <Strin...
Cmdlet          Update-TypeData                                                       Update-TypeData [[-AppendPath] <String[]>] [-PrependPath <String[...
Cmdlet          Where-Object                                                          Where-Object [-FilterScript] <ScriptBlock> [-InputObject <PSObjec...
Cmdlet          Write-Debug                                                           Write-Debug [-Message] <String> [-Verbose] [-Debug] [-ErrorAction...
Cmdlet          Write-Error                                                           Write-Error [-Message] <String> [-Category <ErrorCategory>] [-Err...
Cmdlet          Write-Host                                                            Write-Host [[-Object] <Object>] [-NoNewline] [-Separator <Object>...
Cmdlet          Write-Output                                                          Write-Output [-InputObject] <PSObject[]> [-Verbose] [-Debug] [-Er...
Cmdlet          Write-Progress                                                        Write-Progress [-Activity] <String> [-Status] <String> [[-Id] <In…
Cmdlet          Write-Verbose                                                         Write-Verbose [-Message] <String> [-Verbose] [-Debug] [-ErrorActi...
Cmdlet          Write-Warning                                                         Write-Warning [-Message] <String> [-Verbose] [-Debug] [-ErrorActi…

PS C:\Documents and Settings\smithc>


As you can see you have a lot of tools already built in after you install Powershell. Powershell is available from Microsoft as KB926139. I recommend going out and getting it and start learning how to use it.

Microsoft already has Powershell support built in to Exchange 2007, and SQL Server 2008. With Powershell you, as an administrator, can do more things using Powershell than you can with the GUI. Who would have ever thought that Microsoft would allow us to use a command line tool so efficiently? Since Microsoft has done this with these products I am sure that they will be continuing down this path. In fact with Server 2008 they have a core version that does not even have a GUI. I love it. Finally a light weight and very powerful OS and a great scripting tool to go along with it. In the future I expect to see more development of Powershell, version 2.0 is on the way, from Microsoft as well as third parties in order to get it to interface with other applications. Please take some time to explore and learn more about this great tool and I will have more on this topic in the future.

Thanks for reading this and I hope you learned something and I hope you are excited about Powershell like I am. Let me know if you have any questions by leaving a comment or go to sysadminsmith.com to drop me an email.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: