powershell

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.

PowerShell 2.0: One Cmdlet at a Time 11 Add-Computer

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Add-Computer cmdlet. What can I do with it? Join a local computer to a domain or workgroup Example: Join the current computer to the Test domain, place the computer account in the Servers OU and use the Restart-Computer cmdlet to reboot the computer to complete the process. Add-Computer -domainname Test -OUPath ‘OU=Servers,DC=test,DC=local’; Restart-Computer

PowerShell 2.0: One Cmdlet at a Time 10 Restart-Computer

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Restart-Computer cmdlet. What can I do with it? Restart a local or remote computer Example: Immediately restart the computer Server01. Restart-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(2) Alternatively the Systinternals tool PSShutdown could be used to restart a local or remote computer.

PowerShell 2.0 - Where can I find it?

I’ve been fielding a number of queries from colleagues and geek friends about the recently released PowerShell 2.0 and one of the recurring themes seems to be “I’ve searched for PowerShell 2.0, but I’m having trouble finding it…..” As Jakul writes over on his blog this seems to be for a couple of reasons: A lot of people wrote a lot of blogposts about PowerShell 2.0 during its various CTP phases and searches for PowerShell 2.