Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Export-FormatData cmdlet.
What can I do with it?
Take formatting data generated by Get-FormatData and export it to a *.ps1xml file.
Example:
Retrieve the formatting for the TypeName Microsoft.Win32.RegistryKey and export it to a *.ps1xml file.
Get-FormatData -TypeName Microsoft.Win32.RegistryKey | Export-FormatData -Path registryformat.ps1xml -IncludeScriptBlock
The contents of registryformat.ps1xml are shown below.
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 Get-FormatData cmdlet.
What can I do with it?
Retrive format data from the current session. Within a session formatting data could include formatting from *.ps1xml format files stored in the PowerShell installation directory, formatting from imported modules or snapins, or formatting from commands imported with Import-PSSession.
Example:
Retrieve the formatting for the TypeName Microsoft.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the ConvertTo-XML cmdlet.
What can I do with it?
Convert a .NET object into an XML-based representation of it.
Example:
Retrieve a list of services beginning with the letter b and convert the object into an XML-based respresentation. Use the available Save method of the XML object to save the data into an XML file.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the ConvertFrom-StringData cmdlet.
What can I do with it?
Converts a string which contains one or multiple key and valuepairs into a hash table. Input is typically from a here-string since each key and value must be on a separate line.
Example:
Create a here-string and store it in the variable $herestring. Convert it into a hash table.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the ConvertFrom-CSV cmdlet.
What can I do with it?
Convert a series of CSV style strings which have been generated by ConvertTo-CSV back into objects.
Example:
Retrieve a list of services beginning with the letter b and convert the object into CSV style strings, storing them into the variable $CSVStrings . Convert these back into objects.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the ConvertTo-CSV cmdlet.
What can I do with it?
Convert a .NET object into a series of CSV style strings.
Example:
Retrieve a list of services beginning with the letter b and convert the object into CSV style strings
Get-Service | Where-Object{$_.Name -like ‘b*’} | ConvertTo-CSV -NoTypeInformation
You will notice that the data returned from the services has been converted into strings separated by a comma.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Use-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.
Use-Transaction enables you to add a scriptblock to a transaction. Note: This only works with transaction-enabled .
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Undo-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.
Undo-Transaction rolls back the active transaction.
Example:
A good example of a possible use for transactions is within the registry.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Get-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.
Get-Transaction returns an object of a current transaction which has been kicked off with Start-Transaction.
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Complete-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.
Complete-Transaction commits a transaction which has been kicked off with Start-Transaction.