powershell

PowerShell 2.0: One Cmdlet at a Time 83 ConvertTo-CSV

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.

PowerShell 2.0: One Cmdlet at a Time 82 Use-Transaction

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 .

PowerShell 2.0: One Cmdlet at a Time 81 Undo-Transaction

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.

PowerShell 2.0: One Cmdlet at a Time 80 Get-Transaction

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.

PowerShell 2.0: One Cmdlet at a Time 79 Complete-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.

PowerShell 2.0: One Cmdlet at a Time 78 Start-Transaction

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Start-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. Both cmdlets and providers can support transactions, cmdlets will have a UseTransaction parameter.

PowerShell 2.0: One Cmdlet at a Time 77 Remove-Computer

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Remove-Computer cmdlet. What can I do with it? Remove the local computer from a workgroup or domain. Example: Remove the local computer from the current domain, then reboot to make the change take effect using the Restart-Computer cmdlet. Remove-Computer ; Restart-Computer How could I have done this in PowerShell 1.0? You could have used the Win32_ComputerSystem WMIClass and the UnjoinDomainorWorkgroup method.

PowerShell 2.0: One Cmdlet at a Time 76 Stop-Computer

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

PowerShell 2.0: One Cmdlet at a Time 75 Remove-Module

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Remove-Module cmdlet. What can I do with it? PowerShell 2.0 introduces the concept of modules; essentially they are the evolution of snapins from PowerShell 1.0. Remove-Module enables you to remove a module previously imported with Import-Module. Example: Check currently available modules with Get-Module and remove the PSDiagnosticsModule. Get-Module Remove-Module PSDiagnostics How could I have done this in PowerShell 1.

Get-Scripting Episode 16 with Hey Scripting Guy Ed Wilson

One of the great things about producing a podcast is that you get to talk to and sometimes meet really interesting people. On the latest epsiode of the Get-Scripting podcast we were lucky enough to talk to Ed Wilson, the Scripting Guy over at Microsoft. I’ve often used and learnt loads from the Hey Scripting Guy series so it was great to talk to the guy who is currently writing them.