Skip to content

Commit 9e5f541

Browse files
authored
Fix issues found when merging into PowerShell repo (#34)
1 parent 8e63705 commit 9e5f541

File tree

3 files changed

+162
-140
lines changed

3 files changed

+162
-140
lines changed

src/PSDesiredStateConfiguration/PSDesiredStateConfiguration.psm1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ data LocalizedData
6565
NoModulesPresent=There are no modules present in the system with the given module specification.
6666
ImportDscResourceWarningForInbuiltResource=The configuration '{0}' is loading one or more built-in resources without explicitly importing associated modules. Add Import-DscResource -ModuleName 'PSDesiredStateConfiguration' to your configuration to avoid this message.
6767
PasswordTooLong=An error occurred during encryption of a password in node '{0}'. Most likely the password entered is too long to be encrypted using the selected certificate. Please either use a shorter password or select a certificate with a larger key.
68+
PsDscRunAsCredentialNotSupport=The 'PsDscRunAsCredential' property is not currently support when using Invoke-DscResource.
6869
'@
6970
}
7071
Set-StrictMode -Off
@@ -4650,6 +4651,7 @@ function Invoke-DscResource
46504651
[ValidateSet('Get','Set','Test')]
46514652
[string]
46524653
$Method,
4654+
[Parameter(Mandatory)]
46534655
[Hashtable]
46544656
$Property
46554657
)
@@ -4658,6 +4660,13 @@ function Invoke-DscResource
46584660
Name = $Name
46594661
}
46604662

4663+
if($Property.ContainsKey('PsDscRunAsCredential'))
4664+
{
4665+
$errorMessage = $LocalizedData.PsDscRunAsCredentialNotSupport -f $name
4666+
$exception = [System.ArgumentException]::new($errorMessage,'Name')
4667+
ThrowError -ExceptionName 'System.ArgumentException' -ExceptionMessage $errorMessage -ExceptionObject $exception -ErrorId 'PsDscRunAsCredentialNotSupport,Invoke-DscResource' -ErrorCategory InvalidArgument
4668+
}
4669+
46614670
if($ModuleName)
46624671
{
46634672
$getArguments.Add('Module',$ModuleName)

0 commit comments

Comments
 (0)