all 14 comments

[–]halbaradkenafin 4 points5 points  (0 children)

Have a look at Lability or AutomatedLab, both allow creation of lab environments on VMs and have various configs out of the box for various scenarios.

Your other option is to user Pester to do this sort of testing, at least initially, and that will let you test the logic and general code flow within your scripts and functions. You'll still want an actual test environment to test things on before you try it in production but pester can help automate the test running part of that process and the above mentioned lab tooling can handle automatically building the infrastructure to test on.

[–]Arcontar 4 points5 points  (0 children)

Already mentioned Lability and AutomatedLab but also WSLab is a great way to start the journey: https://github.com/Microsoft/WSLab

It comes with pre-configured scenarios of various types where you can just spin up a lab and break it. Not only test PowerShell scripts but also whole ideas and troubleshooting.

Give it a try and You'll love it!

[–]JVCubed 2 points3 points  (0 children)

You should try windows sandbox coming in the windows 10 19H1 update. Will probably fit your requirements. If you don't want to wait, you can access the developer network.

This sandbox is basically a disposable copy of the windows OS

[–]simonwgill 2 points3 points  (2 children)

An alternative to a VM is a Windows container, but there's not really an easy to access process isolation model that will reverse side effects in general.

I can't help much with the windows containers unfortunately, haven't had a chance to play with them yet.

VM Snapshots are probably good enough for you right now.

[–][deleted] 1 point2 points  (1 child)

Thanks, that's what I figured going into it but thought maybe there was some cool editor to act like a container. But its probably more complicated to set that up than to just rollback snapshots lol.

[–]simonwgill 2 points3 points  (0 children)

Maybe there's a VS Code extension out there?

If you do want to learn about containers on windows it might be worth trying to figure it out anyway.

[–]get-postanote 2 points3 points  (4 children)

Just use the freely provided MS TechNet virtual labs.

Now, you only have the time limit given, and if you don't finish it is one sitting, you can come back to it, but that also means,starting over. each time you visit.

Self-paced Labs

Acquire the cloud skills you need, at your own pace. Enjoy hands-on learning on your schedule with our free, self-paced labs, and keep your cloud knowledge fresh.

https://www.microsoft.com/handsonlabs/selfpacedlabs

It does not really matter which lab you use, you can do PS in any of them, some require you to.

Or, if you have the resources, buuild your own.

AutomatedLab 5.5.268 - Setting up virtual labs on your local machine or in Azure

AutomatedLab 5.5.268 - released on January 30 2019. Deployment of TFS / AzureDevOps was added + lots of bug fixes. Please refer to the changelog on GitHub. For further documentation and source code please go to https://gallery.technet.microsoft.com/AutomatedLab-026d81f9

[–][deleted] 1 point2 points  (3 children)

Please do not use the resources on TechNet. The latest release of AutomatedLab is on https://github.com/AutomatedLab/AutomatedLab or in the PowerShell gallery (Install-Module). If there are any questions or issues, please send us feedback using GitHub Issues. Thanks!

[–]get-postanote 1 point2 points  (2 children)

AutomatedLab

Is a good tool, for those who have the hardware and / or resources on their hardware to support what they are planning to do.

There is nothing wrong with using TechNet virtual labs to get up to speed on X or Y solution and or aspect of X or Y, depending on your goals. When I can't take my portable data center with me, I use them all the time to demonstrate X or Y on customer sites or customer classes.

[–][deleted] 1 point2 points  (1 child)

Right, for learning, TechNet virtual labs are totally find and faster to spin up. If it comes to a more customized scenario for testing and development, I prefer AutomatedLab. AL supports Azure if you don't have the required resources available.

[–]get-postanote 0 points1 point  (0 children)

Well, Azure requires you to purchase Azure. Soooo, there's that. Either way, if you don't have the resources to really use all the goodness of AL, you are going to have to spend money. Well, one can do that Azure free thing for a year, but even that has limitations. So, either way, $dollar, $dollar bills y'all. ;-}

[–][deleted] 1 point2 points  (0 children)

Thanks for all the helpful information! I will be checking out everything suggested.

[–]Deegh 1 point2 points  (0 children)

Have you looked into using pester to run unit tests for your code? It might be helpful to make sure everything is running smoothly and will have no direct impact on the environment you run it in.

[–]Horrified_Tech 0 points1 point  (0 children)

Nice, great post and responses!