Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/dsc/psresourceget.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,11 @@ function GetOperation {
[string]$ResourceType
)

if ([string]::IsNullOrEmpty($stdinput)) {
Comment thread
Gijsreyn marked this conversation as resolved.
Write-Trace -level error -message "Get operation requires --input with the resource properties. No input was provided."
exit [ExitCode]::Error
}

$inputObj = $stdinput | ConvertFrom-Json -ErrorAction Stop

Write-Trace -message "Starting Get operation for ResourceType: $ResourceType" -level trace
Expand Down
6 changes: 6 additions & 0 deletions test/DscResource/PSResourceGetDSCResource.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ Describe 'Repository Resource Tests' -Tags 'CI' {
}
}

It 'Get operation without --input exits with a non-zero code and does not produce an unhandled exception' {
$output = & $script:dscExe resource get --resource Microsoft.PowerShell.PSResourceGet/Repository -o json 2>&1
$LASTEXITCODE | Should -Not -Be 0
($output | Out-String) | Should -Not -Match 'Cannot bind argument to parameter'
Comment thread
Gijsreyn marked this conversation as resolved.
Outdated
}

It 'Can delete a Repository resource instance' {
# First, create a repository to delete
Register-PSResourceRepository -Name 'TestRepoToDelete' -uri 'https://www.doesnotexist.com' -ErrorAction SilentlyContinue -APIVersion Local
Expand Down