April, 2019

[PS] Restart Exchange Services (GUI) using out-gridview

Synopsis: Enumerates all Exchange Services, UI allows selection for restarting selected services, and reloads UI to ensure services are back running. Change Log 1.00: 3/17/2019 – Inital pre-flight version 3/18/2019 – Added GUI, selection process, and progress bar

[NET] Capture Network Trace

Capturing Network Trace Open elevated CMD Run: netsh trace start persistent=yes capture=yes tracefile=c:\temp\nettrace-boot.etl” Reproduce the issue Open elevated CMD Run: netsh trace stop Note: For boot issues, run step 1-2, reboot* and then continue. Converting ETL to Wireshark (.CAP) Download and install Microsoft Network Analyzer Open the ETL file Select Save as .CAP

[PS] Writing errors and output to a text file

Explained: tee (tee-object) cmdlet redirects output into two directions, stores in a file or var and sends down the pipeline. In our use, it sends to a file and also displays on console. 2>&1¬† construct, (stderr) 2> redirects the standard and appends the &1 (stderr to stdout) to a filename of results.txt. Other constructs.   →

[PS] Passing a string into a powershell script

Usage example: test.ps1 revert  

[PS] Parameter with validation

Master¬† powershell’s extensibility’s use of functions is key real life application of PS scripts. Parameters are primarily known as input functions, where information can be passed and validated. Below is an example of how of passing a parameter and setting static validation sets:

Reference: https://ss64.com/ps/syntax-args.html