22 lines
877 B
PowerShell
22 lines
877 B
PowerShell
# PowerShell Cookbook has a lot of code there, I'm only interested in
|
|
# the Add-ObjectCollector which adds an overloaded Out-Default version,
|
|
# which stores a history of output objects.
|
|
# One major problem with loading this from the module, is that when the
|
|
# module is removed the shell BREAKS.
|
|
#
|
|
# The code below, makes sure the module is removed, and then imports
|
|
# only the Add-ObjectCollector code from it.
|
|
# All I really want is the Out-Default function created by
|
|
# Add-ObjectCollector, and so, I'll also remove the function once done.
|
|
|
|
if( Get-Module PowerShellCookbook ) {
|
|
Remove-Module PowerShellCookbook
|
|
|
|
Import-Module PowerShellCookbook -Cmdlet Add-ObjectCollector
|
|
}
|
|
#
|
|
. Get-Command -ListImported Add-ObjectCollector -ErrorAction SilentlyContinue | ForEach-Object {
|
|
Add-ObjectCollector
|
|
Get-Item function:/Add-ObjectCollector | Remove-Item
|
|
}
|