-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from PowerShell/dev
Release of version 3.11.0.0 of xPSDesiredStateConfiguration
- Loading branch information
Showing
92 changed files
with
14,260 additions
and
3,027 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DSCResource.Tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<# | ||
.SYNOPSIS | ||
Tests if the current machine is a Nano server. | ||
#> | ||
function Test-IsNanoServer | ||
{ | ||
[OutputType([Boolean])] | ||
[CmdletBinding()] | ||
param () | ||
|
||
return $PSVersionTable.PSEdition -ieq 'Core' | ||
} | ||
|
||
<# | ||
.SYNOPSIS | ||
Creates and throws an invalid argument exception | ||
.PARAMETER Message | ||
The message explaining why this error is being thrown | ||
.PARAMETER ArgumentName | ||
The name of the invalid argument that is causing this error to be thrown | ||
#> | ||
function New-InvalidArgumentException | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
[ValidateNotNullOrEmpty()] | ||
[String] | ||
$Message, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[ValidateNotNullOrEmpty()] | ||
[String] | ||
$ArgumentName | ||
) | ||
|
||
$argumentException = New-Object -TypeName 'ArgumentException' -ArgumentList @( $Message, $ArgumentName ) | ||
$errorRecord = New-Object -TypeName 'System.Management.Automation.ErrorRecord' -ArgumentList @( $argumentException, $ArgumentName, 'InvalidArgument', $null) | ||
|
||
throw $errorRecord | ||
} | ||
|
||
<# | ||
.SYNOPSIS | ||
Creates and throws an invalid operation exception | ||
.PARAMETER Message | ||
The message explaining why this error is being thrown | ||
.PARAMETER ErrorRecord | ||
The error record containing the exception that is causing this terminating error | ||
#> | ||
function New-InvalidOperationException | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[ValidateNotNullOrEmpty()] | ||
[String] | ||
$Message, | ||
|
||
[ValidateNotNull()] | ||
[System.Management.Automation.ErrorRecord] | ||
$ErrorRecord | ||
) | ||
|
||
if ($null -eq $Message) | ||
{ | ||
$invalidOperationException = New-Object -TypeName 'InvalidOperationException' | ||
} | ||
elseif ($null -eq $ErrorRecord) | ||
{ | ||
$invalidOperationException = New-Object -TypeName 'InvalidOperationException' -ArgumentList @( $Message ) | ||
} | ||
else | ||
{ | ||
$invalidOperationException = New-Object -TypeName 'InvalidOperationException' -ArgumentList @( $Message, $ErrorRecord.Exception) | ||
} | ||
|
||
$errorRecordToThrow = New-Object -TypeName 'System.Management.Automation.ErrorRecord' -ArgumentList @( $invalidOperationException.ToString(), 'MachineStateIncorrect', 'InvalidOperation' ,$null) | ||
throw $errorRecordToThrow | ||
} | ||
|
||
Export-ModuleMember -Function ` | ||
Test-IsNanoServer, ` | ||
Throw-InvalidArgumentException, ` | ||
Throw-TerminatingError |
Oops, something went wrong.