powershell

PowerShell 2.0: One Cmdlet at a Time 19 Stop-Job

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Stop-Job cmdlet. What can I do with it? Stop background jobs which are running in the current session. Examples: Stop job with id 13. Stop-Job -id 13 Retrieve all current jobs and stop them all. Get-Job | Stop-Job How could I have done this in PowerShell 1.0? The concept of jobs did not exist in PowerShell 1.

PowerShell 2.0: One Cmdlet at a Time 17 Receive-Job

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Receive-Job cmdlet. What can I do with it? Retrieve the results of a background job which has already been run. Example: Retrieve the results for the job with ID 1 and keep them available for retrieval again. (The default is to remove them) Receive-Job -Id 1 -Keep How could I have done this in PowerShell 1.

PowerShell 2.0: One Cmdlet at a Time 18 Remove-Job

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Remove-Job cmdlet. What can I do with it? Remove existing background jobs from the current session. Examples: Remove the job with ID 1. Remove-Job -Id 1 Use the Get-Job cmdlet to retrieve all jobs and pipe it through to Remove-Job to remove them all. Get-Job | Remove-Job How could I have done this in PowerShell 1.

PowerShell 2.0: One Cmdlet at a Time 16 Get-Job

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Get-Job cmdlet. What can I do with it? Get background jobs from the current session as objects. Examples: Get background jobs from the current session. Get-Job Get background jobs from the current session which contain the Get-WMIObject cmdlet. Get-Job -Command “Get-WMIObject” Store a job in a variable and examine it’s methods and properties.

PowerShell 2.0: One Cmdlet at a Time 15 Start-Job

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Start-Job cmdlet. What can I do with it? Start a background job on the local computer. This allows you to take back your console session whilst you wait for the job to complete. Examples: Start a background job to run Get-Service on the local computer. Start-Job -ScriptBlock {Get-Service} This will display the status of this job in your current session and allow you to continue working in the session - then retrieve the results at a later time.

PowerShell 2.0: One Cmdlet at a Time 14 Start-Process

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Start-Process cmdlet. What can I do with it? Start a process on the local computer. Examples: Start an instance of Notepad Start-Process Notepad Open the file Test.txt using its associated application Notepad Start-Process C:\Scripts\Test.txt How could I have done this in PowerShell 1.0? You could have used the .NET System.Diagnostics.Process class and the Start method.

PowerShell 2.0: One Cmdlet at a Time 13 Clear-EventLog

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Clear-Eventlog cmdlet. What can I do with it? Clear the Event Log on a local or remote computer. Example: Clear the Application Event Log on the remote computer Server01 Clear-EventLog -LogName Application -ComputerName Server01 How could I have done this in PowerShell 1.0? You could have used the Get-EventLog cmdlet and the Clear method of the System.

Get-Scripting Episode 14 - Clash of the Titans

One of the things I most enjoy about Christmas Day is after all the chaos of the morning has died down and everyone has fallen asleep after their big lunch I would tune it to Talksport and listen to their pre-recorded Clash of the Titans show whilst working through the mountain of washing up. This show would pit together four of their most expressive presenters in a 3 hour debate about topics of current issue or that which had been significant during the year.

PowerShell 2.0: One Cmdlet at a Time 12 Write-EventLog

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Write-EventLog cmdlet. What can I do with it? Write an event in a Windows Event Log on a local or remote machine. Example: Write an Error event into the Application log on Server01 with source CustomApp1, EventID 8750 and Error Message. Write-EventLog -computername Server01 -logname Application -source CustomApp1 -eventID 8750 -entrytype Error -message “CustomApp1 has experienced Error 9875”

Windows PowerShell v.1 TFM eBook - Free Download

One of the best books I purchased when I was first learning PowerShell was Windows PowerShell v.1 TFM from Sapien Press by Don Jones and Jeff Hicks. It was great for making that jump from initial exposure to PowerShell to firming up fundamentals and being confident in writing your own scripts. They have recently released an updated version to cover PowerShell 2.0, but as a great gesture have released the original version as a free e-book download.