On Knowledge Factory, the company I work for, every one get’s their own lab-server. Nothing fancy, but it helps a lot when I want to test something in a controlled environment.
I’ve been playing around a bit with desired state configuration on my lab server lately. And especially with the great module VirtualEngineLab which I’ve been using to automatically build various scenarios. Each time I start a new build, the module uses the DSC resource xPendingReboot to check for pending reboots.
VBScript can feel like a thing of the past, but truth is a lot of companies have invested heavily in VBScript during many years. It all can’t be simply translated to PowerShell over a night. To get started with translating VBScripts to PowerShell, one way could be to break up the VBScripts into usable parts. This way we can start translating the Control Scripts to PowerShell and keep the using the VBScripts as is.
A PowerShell function can have different parameters depending on how it is called. This is called Parameter Sets. For example, Get-Process has a non mandatory parameter called Name which specifies which processes to Get by Name. But is also has a parameter called ID which also specifies which processes to get, this time by ID. Both parameters exists but are mutually exclusive, you cannot use them both at the same time, since they are defined in two different Parameter Sets.
I’ve previously written about how to generate a random password and how to output a password in phonetic alphabet. Today I’m going to put those two functions to use in a practical example.
Scenario: Carl is a helpdesk agent and today he is feeling a bit stressed out. There has been an outage on one of the business critical systems and the phones are constantly ringing. One of the calls is a user who forgot his password and Carl quickly asks the usual control questions to make sure that the user is who he claims to be, locates the user account and clicks on reset password.
Some times I need to configure specific settings that will apply every time I open PowerShell or load certain functions or variables. This can easily be achieved by using a PowerShell profile script.
A profile script could be described as a startup script and is a script that will be run in current scope every time I start PowerShell, perfect for loading custom functions, settings or variables. The location of a users profile script is stored in the variable $profile which contains a string.