cmdlet-series

PowerShell 2.0: One Cmdlet at a Time 78 Start-Transaction

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Start-Transaction cmdlet. What can I do with it? PowerShell 2.0 introduces new functionality in the form of transactions. By grouping together a set of commands to form a transaction they can either all be committed or all rolled back depending on success. Both cmdlets and providers can support transactions, cmdlets will have a UseTransaction parameter.

PowerShell 2.0: One Cmdlet at a Time 77 Remove-Computer

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Remove-Computer cmdlet. What can I do with it? Remove the local computer from a workgroup or domain. Example: Remove the local computer from the current domain, then reboot to make the change take effect using the Restart-Computer cmdlet. Remove-Computer ; Restart-Computer How could I have done this in PowerShell 1.0? You could have used the Win32_ComputerSystem WMIClass and the UnjoinDomainorWorkgroup method.

PowerShell 2.0: One Cmdlet at a Time 76 Stop-Computer

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Stop-Computer cmdlet. What can I do with it? Shutdown a local or remote computer Example: Immediately shutdown the computer Server01. Stop-Computer -ComputerName Server01 -Force How could I have done this in PowerShell 1.0? You could have used the Win32_OperatingSystem WMI Class and the Win32Shutdown method. (Get-WmiObject -Class Win32_OperatingSystem -ComputerName Server01).Win32Shutdown(5) Alternatively the Systinternals tool PSShutdown could be used to shutdown a local or remote computer.

PowerShell 2.0: One Cmdlet at a Time 75 Remove-Module

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Remove-Module cmdlet. What can I do with it? PowerShell 2.0 introduces the concept of modules; essentially they are the evolution of snapins from PowerShell 1.0. Remove-Module enables you to remove a module previously imported with Import-Module. Example: Check currently available modules with Get-Module and remove the PSDiagnosticsModule. Get-Module Remove-Module PSDiagnostics How could I have done this in PowerShell 1.

PowerShell 2.0: One Cmdlet at a Time 74 Test-ModuleManifest

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Test-ModuleManifest cmdlet. What can I do with it? PowerShell 2.0 introduces the concept of modules; essentially they are the evolution of snapins from PowerShell 1.0. A module creator could use Test-Module to ensure that files listed in a *.psd1 file, possibly created by New-ModuleManifest , are valid. Example: Test that the C:\Users\User1\Documents\WindowsPowerShell\Modules\Logfile-Module\Logfile-Module.psd1 (created in the New-ModuleManifest example) is valid.

PowerShell 2.0: One Cmdlet at a Time 73 New-ModuleManifest

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the New-ModuleManifest cmdlet. What can I do with it? PowerShell 2.0 introduces the concept of modules; essentially they are the evolution of snapins from PowerShell 1.0. Creators of Modules can use the New-ModuleManifest cmdlet to create a module manifest *.psd1 file which can be used to enhance to processes around a module, such as any prerequisites.

PowerShell 2.0: One Cmdlet at a Time 72 Export-ModuleMember

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Export-ModuleMember cmdlet. What can I do with it? PowerShell 2.0 introduces the concept of modules; essentially they are the evolution of snapins from PowerShell 1.0. Export-ModuleMember specifies elements from a module, like functions or variables, which can be exported. Note: This cmdlet can only be used within a *.psm1 script module file or a dynamic module created with New-Module.

PowerShell 2.0: One Cmdlet at a Time 71 New-Module

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the New-Module cmdlet. What can I do with it? PowerShell 2.0 introduces the concept of modules; essentially they are the evolution of snapins from PowerShell 1.0. New-Module enables you to create a dynamic module from a script block that is available in the current session. Note: New-Module does not create a module on disk available for use at a later date!

PowerShell 2.0: One Cmdlet at a Time 70 Import-Module

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Import-Module cmdlet. What can I do with it? PowerShell 2.0 introduces the concept of modules; essentially they are the evolution of snapins from PowerShell 1.0. Import-Module enables you to add one or more modules to your current session. Examples: Import the PSDiagnostics module and examine the newly available commands in the session from that module by using Get-Module.

PowerShell 2.0: One Cmdlet at a Time 69 Get-WinEvent

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Get-WinEvent cmdlet. What can I do with it? Retrieve items from Event Logs including event logs generated by the Windows Event Log technology, new since Windows Vista / 2008 Server, in addition to the classic System, Security and Application Logs. Note: it requires .NET Framework 3.5 or later installed. Examples: Retrieve events from the Setup Event Log.