PowerShell Summary

PowerShell is a powerful scripting tool that you can use to automate system administration and application management tasks from the command-line. Using PowerShell, you can create scripts to manage the Windows operating system and applications that run on Windows. PowerShell commands enable you to perform certain tasks, especially those involving a number of objects, much faster than the graphical user interface (GUI). Some tasks can only be done through PowerShell.

The following terms are used with PowerShell:

Term Definition
Command line The command line refers to the command-line interface (CLI) used to interact with a computer program. Commands are entered at the command prompt. The command-line interface:

  • Is text based.
  • Uses a simple command construction, also referred to as the command syntax.
  • Uses flags, also referred to as switches, to specify an option in the command.
Cmdlets Cmdlets are commands that an administrator enters at the PowerShell prompt to perform system management tasks. The PowerShell command-line interface uses simple command construction, typically in the form of:

[verb] -[noun] -[adverb]

When using PowerShell cmdlets, keep in mind the following:

    • The cmdlets are generally not case sensitive.
    • The adverbs are typically referred to as switches and are not case sensitive.
    • If you are using PowerShell to turn on features, use the same case used in the cmdlet help system.
    • Common cmdlets include:
      • new, add, and install are used when working with a new object.
      • get is used to retrieve information about an existing object.
      • set is used to make a change to an existing object.
      • get-help [cmdletname] is used to get help for a particular cmdlet.
    • PowerShell cmdlets are designed to be lightweight, easy to recognize, and easy to use.
    • If you type a PowerShell verb followed by a hyphen (for example new –) and press the TAB key, you can cycle through the available options.

PowerShell 3.0 has IntelliSense capabilities that allow you to auto-complete commands by pressing the TAB key.

  • The PowerShell icon on the taskbar opens the generic version of PowerShell.
  • Installing services and features on Windows Server creates new versions of PowerShell that contain modules with the cmdlets for the added services and features.
    • There is a separate icon to launch the new instance of PowerShell.
    • When you write a script that requires the cmdlets from an added module, you can add the cmdlets by entering: Import-Module [modulename]
Providers Windows PowerShell providers allow you to access data stores, such as the registry and certificate store, in a way similar to accessing the file system.

Some new features in Windows PowerShell 3.0 included with Windows Server 2012 are:

  • The Deployment Image Servicing and Management (DISM) module Get-WindowsOptionalFeature -Online cmdlet allows an administrator to view features installed on a remote computer. Administrators can then add or remove cmdlets from the remote computer using the Add-WindowsFeature and Remove-WindowsFeature cmdlets.
  • Remote Windows PowerShell connections have been improved to attempt to maintain a connection even when network connectivity is lost. Previous versions of PowerShell easily dropped the remote connection when network connectivity problems were encountered. PowerShell 3.0 allows you to reconnect from a different computer if the connection is lost.
  • Windows PowerShell Workflows are sequences of multicomputer management activities. Windows PowerShell Workflows allow workflows written in XAML or the PowerShell scripting language to be run as a cmdlet.

Windows Server 2012 R2 introduces PowerShell Desired State Configuration (DSC) which allows administrators to manage the configuration and environment of computers and devices connected through a cloud infrastructure. With DSC, the administrator uses declarative scripting to specify and manage configuration. DSC resources include the following:

  • Management Object Format (MOF) files are used to specify management tasks to be performed. Administrators can create MOF files in a variety of ways, including PowerShell v4 declarative syntax extensions or third-party tools. PowerShell v4 has built-in resources to facilitate MOF creation. These resources include:
    • WindowsFeature identifies the role, such as Web server.
    • File identifies and manages files and directories.
    • Group identifies and manages local Windows groups.
  • PowerShell keyword configuration is used to create MOF files.
  • The creation of custom resources using PowerShell v4 or third-party tools is supported.
  • DSC Local Configuration Manager runs on all target nodes and calls the necessary configuration resources.
  • The option to use a push or pull implementation.
    • In the Pull Model, DSC data and custom providers are kept on an IIS Web server. The target contacts the IIS Web server to obtain the configuration instructions.
    • In the Push Model, the configuration instructions and custom providers are pushed to the target system.
Coaching
© Data Coincide, LLC 2010-2019