Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Restore-Computer cmdlet.
What can I do with it?
Run a system restore on the local machine.
Example:
Restore the local computer to restore point 101 and then use the Restart-Computer cmdlet to reboot it
Restore-Computer -RestorePoint 101 Restart-Computer
How could I have done this in PowerShell 1.0?
You could have used the SystemRestore WMI class and the Restore method.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Get-ComputerRestorePoint cmdlet.
What can I do with it?
List available System Restore points on the local machine.
Example:
List the available System Restore points on the current machine.
Get-ComputerRestorePoint
How could I have done this in PowerShell 1.0?
You could have used the Get-WMIObject cmdlet with the Root\Default namespace and the SystemRestore Class
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Enable-ComputerRestore cmdlet.
What can I do with it?
Enable the System Restore feature on the specified drive.
Example:
Enable System Restore on the local C drive.
Enable-ComputerRestore -drive “C:\”
How could I have done this in PowerShell 1.0?
You could have used the SystemRestore WMI class and the Enable method
$SystemRestore = [wmiclass]"\\.\root\default:systemrestore" $SystemRestore.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Disable-ComputerRestore cmdlet.
What can I do with it?
Disable the System Restore feature on the specified drive.
Example:
Disable System Restore on the local C drive.
Disable-ComputerRestore -drive “C:\”
How could I have done this in PowerShell 1.0?
You could have used the SystemRestore WMI class and the Disable method
$SystemRestore = [wmiclass]"\\.\root\default:systemrestore" $SystemRestore.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Select-XML cmdlet.
What can I do with it?
Search for text in an XML document using an XPath query.
Example:
Example.xml
From the file Example.XML search with the XPath query /shop/food
Select-XML -Path example.xml -XPath “/shop/food”
You’ll notice this hasn’t returned any actual data from the XML file rather details of the search carried out and two matches.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Wait-Job cmdlet.
What can I do with it?
Wait for a background job to complete in the current session before returning the prompt to the user.
Example:
Wait for jobs 37,39 and 41 to finish, but use the Any parameter to only wait for the first one. You can see when first initiated the cursor does not return to the prompt.
After installing the Windows Management Framework, a.k.a PowerShell 2.0, on my test Windows 2008 64 bit Server I fired up the new PowerShell ISE tool and was prompted with this error:
I already knew that PowerShell ISE had a higher dependency on .NET than PowerShell itself which only requires .NET 2.0, however I was curious about the statement in the above message which states:
“If you are running Windows Server 2008, you must use Server Manager to install or configure “.
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.
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.
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.