Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Export-Counter cmdlet.
What can I do with it?
Take performance objects generated from the Get-Counter or Import-Counter cmdlets and export them as log files. Note: this cmdlet requires Windows 7 or Windows Server 2008 R2 or later.
Examples:
Retrieve some memory performance data from the local machine and export it to the standard Performance Monitor output file BLG.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Test-ComputerSecureChannel cmdlet.
What can I do with it?
Test the secure channel between the local computer and the domain and optionally fix if necessary.
Example:
Test the secure channel on the current computer
Test-ComputerSecureChannel
Note: this will return a Boolean value of True or False as seen below; if you wish for more detailed information use the -Verbose parameter.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the New-WebServiceProxy cmdlet.
What can I do with it?
Make use of an available web service.
Examples:
The website http://www.webservicex.net has a number of available web services which you can use with the New-WebServiceProxy cmdlet.
Find the current weather for Southampton, UK.
$weather = New-WebServiceProxy -uri “http://www.webservicex.net/globalweather.asmx?wsdl" $weather.GetWeather(‘Southampton’, ‘United Kingdom’)
Note: to find what cities were available within the UK to query I used the GetCitiesByCountry method.
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.
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.