Creating Windows PowerShell Functions
This section is dedicated to creating our own PowerShell functions. I hope that you will find the outcomes as rewarding, and the learning journey as interesting, as I did.
My learning philosophy is to learn by doing. My teaching philosophy is to provide examples, each emphasising aspects of building functions. As a bonus each function has a real-life use. It would make my idea if my instructions are sufficient for you to adapt my scripts to your project.
Benefits of PowerShell Functions
Creating re-usable code
SolarWinds' Network Performance Monitor will help you discover what's happening on your network. This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.
What I like best is the way NPM suggests solutions to network problems. Its also has the ability to monitor the health of individual VMware virtual machines. If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.
Purpose: To find the machine holding the list of network shares.
Purpose: To calculate batting average.
Purpose: To check for unsigned device drivers.
Purpose: To discover which Windows services are running.
Purpose: To refine the built-in Ipconfig command.
Purpose: To interact with Outlook.
LEM will alert you to problems such as when a key application on a particular server is unavailable. It can also detect when services have stopped, or if there is a network latency problem. Perhaps this log and event management tool's most interesting ability is to take corrective action, for example by restarting services, or isolating the source of a maleware attack.
Yet perhaps the killer reason why people use LEM is for its compliance capability, with a little help from you, it will ensure that your organization complies with industry standards such as CISP or FERPA. LEM is a really smart application that can make correlations between data in different logs, then use its built-in logic to take corrective action, to restart services, or thwart potential security breaches - give LEM a whirl.
More Examples of PowerShell Functions
Purpose: To research WMI classes.
Purpose: To list Windows processes.
Purpose: To delete old files in the recycle bin.
Purpose to clean out the Windows eventlogs.
For further research try PowerShell's own About-Functions ... series of help files.
Note: Just remove the '#' to check the other 4 help files.
More Windows PowerShell Sections
If you like this page then please share it with your friends
See more Windows PowerShell sections
Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.