Did you ever erased a function from a file, but actually didnt mean to delete it. You still got you powershell prompt open ? No worries, your code is still there, and you wont need to rewrite it if you follow these few but very simple steps 😉

In my case, my function was called : “Get-SCCMFolder”

Since we are several persons working on the same module, something happens, and my function disapeared from the module.


But i could still use it in my PowerShell console.


Even if this function is quite small, rewriting it would have been doing twice the same job, and that is never really super funny (Especially for people who specialized in automation right ? ;))

So dont panic, and be sure NOT to close you powerShell console.

So i rembered that powerhsell had providers and especially that it had one called “functions”.


Looking into the ps provider, I see a possible solution, and hope invades my boday again.


Especially when i read this line 😉


Using DIR (alias for Get-ChildItem) allows use to walk through the psprovider, and get the information of our specefic function.


That “definition” property must contain some crusty information..


And it Does ! Now we only need to pipe this information to a new text file and we are able to get it back.


Et voila !! 🙂

We can simply copy and paste it back into our module (script) again 😀 (Do not forget to add the the Keyword “function” with the function name).

#Greetings from Switzerland 😀


By | 2016-10-19T21:00:19+00:00 December 17th, 2013|PowerShell, Sticky|0 Comments

About the Author:

Stéphane is a dynamic and passionate Cloud and datacenter Microsoft MVP since. He is the founder of the Basel PowerShell user Group (BPUG), the co-founder of the French Speaking PowerShell UserGroup (FRPSUG), author, blogger, and received the community award "PowerShell Hero" from PowerShell.org. Stéphane has implemented microsoft infrastructure solutions in various countries of Europe and is currently working in Basel / Switzerland. Stéphane help his clients to reduce their global infrastructure costs by implementing Microsft infrastructure solutions by combining great products such as System Center, Windows Server, with heavy automation using Windows PowerShell. Stéphane loves languages, Belgium beer, French cheese and French Wine. If any of these topics are of your interest, don't hesitate to come and say hi.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: