Powershell Tutorial Online


Powershell 4.0 Released

Windows PowerShell 4.0 Released for Windows 7, Windows 2008 R2, and Windows Server 2012

I've read through TechNet forum threads where customers scoffed that somehow Microsoft would be able to make PowerShell 4.0 available in October 2013 – so soon after the release of Windows 8.1 and the R2 wave. But, it happened, and it's here.

PowerShell 4.0 comes preinstalled for Windows 8.1 and Windows Server 2012 R2, but there are those who still prefer Windows 7 and other earlier server operating systems. So, it's great to see that Microsoft has finally released PowerShell 4.0 as part of the Windows Management Framework (WMF) 4.0 release. The release supports Windows 7, Windows Embedded Standard 7, Windows Server 2008 R2, and Windows Server 2012.

WMF 4.0 actually includes a bunch more than just PowerShell 4.0, but most will be downloading this latest release specifically for the new cmdlets and functionality that PowerShell 4.0 offers. However, here's everything that is included in WMF 4.0:

WMF 4.0 actually includes a bunch more than just PowerShell 4.0, but most will be downloading this latest release specifically for the new cmdlets and functionality that PowerShell 4.0 offers. However, here's everything that is included in WMF 4.0:

  • Windows PowerShell
  • Windows PowerShell ISE
  • Windows PowerShell Web Services
  • Windows Remote Management (WinRM)
  • Windows Management Instrumentation (WMI)
  • Server Manager WMI provider
  • Windows PowerShell Desired State Configuration (DSC) Download WMF 4.0 here: Windows Management Framework 4.0 P.S. WMF 4.0 also requires Microsoft .NET 4.5 be installed first.

Now that Server 2012 R2 has been released, PowerShell 4.0 has also become available. Unfortunately it is not yet available as a standalone download, older operating systems will have to wait for the Windows Management Framework to become available as an optional download.
Some notable features that are available for PowerShell 4.0 are as follows:

  1. Desired State Configuration – This allows for configuration of a computer in a way that was previously not possible with PowerShell.
  2. Remote debugging – In PowerShell 4.0 it is now possible to set breakpoints for PSSessions, which allows for easier debugging of scripts that are running remotely
  3. Get-Process now supports User names – No more Get-WmiObject -Class Win32_Process!!
  4. Several language improvements and bug fixes.
    For a full list of all changes have a look a the corrosponding TechNet Article which is available here: what’s new in windows powershell

Powershell 3.0

What is new Powershell 3.0?

  • Language enhancements - improvements that came with PowerShell Version 3
  • Online help
  • New integrated scripting environment.
  • New features such as snippets and collapsible regions
  • Workflow support
  • PowerShell Web Access and Management OData Web Services
    • Language Enhancements
      Windows PowerShell 3.0 includes many features that are designed to make its language simpler, easier to use, and to avoid common errors. The Auto-complete feature saves typing time, and reduces my typos. As you begin to type a cmdlet so you see a pick-List of likely nouns to append to your verb.
      Property enumeration, count, length properties on scalar objects and New Core Cmdlets.
      Old: Where-Object { $_. }
      New: Where-Object
      sls -path c:\test.txt -pattern 'Hello'

    • Disconnected Sessions
      Persistent user-managed sessions ("PSSessions") that you create by using the New-PSSession cmdlet are saved on the remote computer. They are no long dependent on the session in which they were created.

      Note:The Disconnected Sessions feature is supported only when the computers at both the originating ("client") and terminating ("server") ends of the connection are running Windows PowerShell 3.0.

      Also supports Robust Session Connectivity means PowerShell 3.0 detects unexpected losses of connectivity between the client and server and attempts to reestablish connectivity and resume execution automatically.

    • The new ISE
      Integrated Scripting Environment (ISE) has many new features, including Intellisense, Show-Command window, a unified Console Pane, snippets, brace-matching etc.

    • Cmdlet and Provider Changes For New Parameters for Get-ChildItem
      -Directory [ ]
      -File [ ]
      -Attribute [ ]
      -Hidden, -ReadOnly, -System

      For Get-Command
      Adds by command capability (Unknown, Cmdlet, Script…)

      For Restart-Computer
      Delay, Timeout and For parameters

    • PS Enhancements
      Modules can now be autoloaded
      When a member of a known module is accessed, the module is automatically loaded into the PowerShell session.

    • PowerShell Web Access
      Windows Server 2012 feature that lets users run Windows PowerShell commands and scripts in a web-based console.


      Online Help
      Get-Help Get-Module -Online

      Updatable Help

    • Workflow

    • Management OData Web Services

    Microsoft Windows PowerShell 3.0 marks a significant advance for the Windows network administrator. It is combination of the power of a full-fledged scripting language with access to command-line utilities, Windows Management Instrumentation (WMI), and even VBScript.
    Windows PowerShell provides the power and ease of use that have been missing from the Windows platform since the beginning of time.
    Perhaps the biggest obstacle for a Windows network administrator in migrating to Windows PowerShell 3.0 is understanding what PowerShell actually is. In some respects, it is a replacement for the venerable CMD (command) shell.
    You can still use cd to change the working directory, and then use dir to produce a directory listing.
    PS C:\Users\Dev1> cd c:\
    PS C:\> dir
    Directory: C:\
    Mode LastWriteTime Length Name
    ---- ------------- ------ ----
    d---- 3/22/2012 4:03 AM PerfLogs
    d-r-- 3/22/2012 4:24 AM Program Files

    You can also combine traditional CMD interpreter commands with some of the newer utilities, such as fsutil.

    PS C:\> fsutil file createnew C:\test\myfirstfile.txt 1000
    test\myfirstfile.txt 1000
    File C:\test\myfirstfile.txt is created
    Above commands we used in an interactive manner. You can group them together like a batch file.

    What is cmdlets?
    In addition to using Windows console applications and built-in commands, you can also use the cmdlets (pronounced commandlets) that are built into Windows PowerShell
    Windows PowerShell 3.0 comes with about 1,000 cmdlets on Windows 8,
    e.g. Get-Help, Get-EventLog, or Get-Process
    e.g. Set-Service,
    Running ipconfig commands
    1. Start Windows PowerShell by choosing Start | Run | Windows PowerShell. The PowerShell prompt will open by default at the root of your Documents folder.
    2. Enter the command ipconfig /all. This is shown here:
    PS C:\> ipconfig /all
    3. Pipe the result of ipconfig /all to a text file. This is illustrated here:
    PS C:\> ipconfig /all >ipconfig.txt
    4. Open Notepad to view the contents of the text file, as follows:
    PS C:\> notepad ipconfig.txt

    Security issues with Windows PowerShell

    [PSCustomObject] {
    Name = "William"
    Age = 35