Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-DbaAgentJobStep erros when used with -WhatIf [Bug] #5812

Closed
2 of 5 tasks
cfradenburg opened this issue Jun 24, 2019 · 1 comment · Fixed by #5834
Closed
2 of 5 tasks

New-DbaAgentJobStep erros when used with -WhatIf [Bug] #5812

cfradenburg opened this issue Jun 24, 2019 · 1 comment · Fixed by #5834
Assignees

Comments

@cfradenburg
Copy link
Contributor

Environmental information

#### PowerShell version:

Name                           Value                                                                                                                                                                                     
----                           -----                                                                                                                                                                                     
PSVersion                      5.1.17134.765                                                                                                                                                                             
PSEdition                      Desktop                                                                                                                                                                                   
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                   
BuildVersion                   10.0.17134.765                                                                                                                                                                            
CLRVersion                     4.0.30319.42000                                                                                                                                                                           
WSManStackVersion              3.0                                                                                                                                                                                       
PSRemotingProtocolVersion      2.3                                                                                                                                                                                       
SerializationVersion           1.1.0.1                                                                                                                                                                                   




#### dbatools Module version:


Name    : dbatools
Path    : C:\Program Files\WindowsPowerShell\Modules\dbatools\1.0.4\dbatools.psd1
Version : 1.0.4




# Replace with output of Get-Culture

SQL Server:

Microsoft SQL Server 2016 (SP2-CU5) (KB4475776) - 13.0.5264.1 (X64) 
	Jan 10 2019 18:51:38 
	Copyright (c) Microsoft Corporation
	Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2016 Standard 10.0 <X64> (Build 14393: ) (Hypervisor)
/* REPLACE WITH output of @@LANGUAGE */

Report

Host used

  • powershell.exe
  • ISE
  • VS Code
  • Other (please specify)

If anything other than powershell.exe was used, please confirm that you can duplicate the issue with powershell.exe

  • Still buggy in powershell.exe

Errors Received

Steps to Reproduce

New-DbaAgentJob -SqlInstance shareddbtest2\sql2016 -Job 'Test Job'
New-DbaAgentJobStep -SqlInstance shareddbtest2\sql2012 -Job 'Test Job' -StepId 1 -StepName 'Test Step' -Subsyste
m TransactSql -Command 'SELECT 1' -Database 'master' -WhatIf

Expected Behavior

The job step to not be created but no error information displayed.

Actual Behavior

format-default : To accomplish this action, set property CommandExecutionSuccessCode.
+ CategoryInfo : NotSpecified: (:) [format-default], PropertyNotSetException
+ FullyQualifiedErrorId : Microsoft.SqlServer.Management.Smo.PropertyNotSetException,Microsoft.PowerShell.Commands
.FormatDefaultCommand

I was able to duplicate this behavior by manually creating a job step using SMO and trying to output it before it was created. It appears there are several fields it expect to always be set when outputting a job step but they can be defaulted when creating so aren't required. Piping to Select-Object and just selecting properties that had been set did work.

@potatoqualitee
Copy link
Member

Thanks for the report! @sanderstad can you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants