Script directory for a PowerShell profile. https://blog.lksz.me/keeping-track-of-everything/#-mypsscriptroot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
857 B

  1. # PowerShell Cookbook has a lot of code there, I'm only interested in
  2. # the Add-ObjectCollector which adds an overloaded Out-Default version,
  3. # which stores a history of output objects.
  4. # One major problem with loading this from the module, is that when the
  5. # module is removed the shell BREAKS.
  6. #
  7. # The code below, makes sure the module is removed, and then imports
  8. # only the Add-ObjectCollector code from it.
  9. # All I really want is the Out-Default function created by
  10. # Add-ObjectCollector, and so, I'll also remove the function once done.
  11. if( Get-Module PowerShellCookbook ) {
  12. Remove-Module PowerShellCookbook
  13. Import-Module PowerShellCookbook -Cmdlet Add-ObjectCollector
  14. }
  15. #
  16. . Get-Command Add-ObjectCollector -ErrorAction SilentlyContinue | ForEach-Object {
  17. Add-ObjectCollector
  18. Get-Item function:/Add-ObjectCollector | Remove-Item
  19. }