February 2019
Intermediate to advanced
626 pages
15h 51m
English
In some cases, it is desirable to mock commands that are not available on the test system. One possible approach in these circumstances is to create a function that reflects the command first, then mock the function.
For example, consider a function that creates and configures a DNS zone with a predefined set of parameter values:
function New-DnsZone { [CmdletBinding()] param ( [Parameter(Mandatory)] [String]$Name ) $params = @{ Name = $Name DynamicUpdate = 'Secure' ReplicationScope = 'Domain' } if (-not (Get-DnsServerZone $Name -ErrorAction SilentlyContinue)) { Add-DnsServerPrimaryZone @params }}
It may not be desirable to install the DNS module on a development system when testing the script. To mock and verify ...
Read now
Unlock full access