Using Release Management, I am trying to execute a Powershell to create a new release using the InitiateRelease REST API. I am using Update 4 with RM Server on prem.
The response I get is a 500 error. On the RM server, there is no error logged. However Fiddler gives a bit more details:
{"Message":"An error has occurred.","ExceptionMessage":"The given key
was not present in the dictionary.",
"ExceptionType":"System.Collections.Generic.KeyNotFoundException","StackTrace":"
at
System.Web.Http.ApiController.d__1.MoveNext()\r\n---
End of stack trace from previous location where exception was thrown
---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Dispatcher.HttpControllerDispatcher.d__0.MoveNext()"}
Here is my PS1.
$releaseDefinition = "MyReleaseTemplateName"
$releaseName = $releaseDefinition + (Get-Date).DateTime
$deploymentPropertyBag = "{
""MyComponentName:Build"" : ""MyBuildNumber"",
""ReleaseName"" : ""$releaseName""
}"
$propertyBag = [System.Uri]::EscapeDataString($deploymentPropertyBag)
$url = "http://myserver:1000/account/releaseManagementService/_apis/releaseManagement/OrchestratorService/InitiateRelease?releaseTemplateName=" + $releaseDefinition + "&deploymentPropertyBag=" + $propertyBag + "&api-version=3.0"
Write-Host $url
$wc = New-Object System.Net.WebClient
$wc.UseDefaultCredentials = $true
$releaseId = $wc.UploadString($url,"")
The problem I was facing was that the component name in the DeploymentPropertyBag was misspelled.
The error is not helping so I thought I would share my solution here.
Related
I'm currently writing a script to install a new SQL Server instance with PowerShell.
In this script, after the instance has been created, I disable the dynamic port and give it a new fixed port.
Import-Module SqlPs
[...] # Install a new instance SQL Server
$wmi = (Get-Item "SQLServer:\SQL\$Env:ComputerName").ManagedComputer
$urn = "ManagedComputer[#Name='$Env:ComputerName']/ ServerInstance[#Name='$Instance']/ ServerProtocol[#Name='Tcp']"
$tcp = $wmi.GetSmoObject($urn)
$tcp.IPAddresses['IPAll'].IPAddressProperties['TcpPort'].Value = "$Port"
$tcp.IPAddresses['IPAll'].IPAddressProperties['TcpDynamicPorts'].Value = ""
$tcp.Alter()
This script works correctly but when I try to run it a second times on the same PowerShell window, it return the following error :
Exception calling "GetSmoObject" with "1" argument(s): "Attempt to retrieve data for object failed for ManagedComputer 'MYSERVER'."
At .\New-Instance.ps1:316 char:5
+ $tcp = $wmi.GetSmoObject($urn)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FailedOperationException
$Error[0] | Format-List -Force
Exception : System.Management.Automation.MethodInvocationException: Exception calling "GetSmoObject" with "1" argument(s): "Attempt to retrieve data for object failed for ManagedComputer 'MYSERVER'." --->
Microsoft.SqlServer.Management.Smo.FailedOperationException: Attempt to retrieve data for object failed for ManagedComputer 'MYSERVER'. ---> Microsoft.SqlServer.Management.Smo.MissingObjectException: The
ServerInstance 'MYINSTANCE' does not exist on the server.
at Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer.GetSmoObjectRec(Urn urn)
at Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer.GetSmoObjectRec(Urn urn)
at Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer.GetSmoObject(Urn urn)
--- End of inner exception stack trace ---
at Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer.GetSmoObject(Urn urn)
at CallSite.Target(Closure , CallSite , Object , Object )
--- End of inner exception stack trace ---
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject :
CategoryInfo : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : FailedOperationException
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, D:\SqlServer\Scripts\New-Instance.ps1: line 316
at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
PSMessageDetails :
Yet, the instance 'MYINSTANCE' has been installed successfully. I think the recovered ManagedComputer hasn't been update and doesn't include the new instance 'MYINSTANCE'.
How can I force the refresh of the recovered ManagedComputer ?
My PowerShell Version :
$PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 14393 3471
Upgrading my code from DacStore to work in SQL Server 2016 and running into issues with DacServices. The goal here is to unregister the data tier of a preexisting database before updating the schema.
Code snippet:
$serverconnection = New-Object System.Data.SqlClient.SqlConnection
If (!$uid -And !$pwd){
$serverconnection.ConnectionString = "Server = $server; Database = $database; Integrated Security = True;"
}
Else{
$serverconnection.ConnectionString = "server = $server; Database = $database; Integrated Security = False; User ID = $uid; Password = $pwd;"
}
# Load the DAC assembly
$validate = Test-Path $dacfxPath
if (!$dacfxPath){
throw 'No usable version of Dac Fx found.'
}
Add-Type -Path $dacfxPath # Attempt to load DAC assembly
$DacService = New-Object Microsoft.SqlServer.Dac.DacServices($serverconnection)
$dacName = $database
## Only delete the DAC definition from msdb, the associated database remains active.
$DacService.Unregister($dacName)
Error received when creating DacServices object:
New-Object : Exception calling ".ctor" with "1" argument(s): "Format of the initialization string does not conform to
specification starting at index 0."
At C:\Users\Administrator\AppData\Local\Temp\2\_ir_sf_temp_0\UnregisterDataTier.ps1:34 char:15
+ ... acService = New-Object Microsoft.SqlServer.Dac.DacServices($servercon ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
My connection string appears correct, and worked in the past. What else could I be doing incorrectly?
Update: Specifying in the DacServices constructor arg that it was a connection string seemed to fix the issue.
$DacService = New-Object Microsoft.SqlServer.Dac.DacServices($serverconnection.ConnectionString)
Having an issue with the Unregister() method now, but one step closer!
I'm trying to create a ssis catalog with power-shell
i'm getting a weird error. this is the code i'm running:
i took the code from msdn
$SQLserver = "BM-ELAD\DRC_BUG_RESTORE"
$Link = "false"
$pass = "123456"
# Load the IntegrationServices Assembly
[Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.IntegrationServices")
# Store the IntegrationServices Assembly namespace to avoid typing it every time
$ISNamespace = "Microsoft.SqlServer.Management.IntegrationServices"
# Create a connection to the server
$sqlConnectionString = "Data Source=$SQLserver;Initial Catalog=master;Integrated Security=SSPI;"
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection $sqlConnectionString
# Create the Integration Services object
$integrationServices = New-Object $ISNamespace".IntegrationServices" $sqlConnection
# Provision a new SSIS Catalog
$catalog = New-Object $ISNamespace".Catalog" ($integrationServices, "SSISDB", "$pass")
$catalog.Create()
and this is the error i'm getting:
GAC Version Location
--- ------- --------
True v2.0.50727 C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.Management.IntegrationServices\13.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Management.IntegrationServices.dll
New-Object : The term 'New-Object' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:13 char:18
+ $sqlConnection = New-Object System.Data.SqlClient.SqlConnection $sqlConnectionSt ...
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (New-Object:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Has anyone ever encountered this problem? am i missing a file?
i tried this fix: failed fix and it didn't work.
my powershell version is 4.0
when i do this manually, it works.
I need to import a .csv file with 350 columns into a SQL Server 2008 R2 database.
Surfing the internet I came up with a function called Out-DataTable from Chad Miller: link to script on Technet
I have used this to complete the PowerShell script as follows:
#----------------------------------------------------------------
$logNaam=MylogFileName
TRY
{
$ConnectionString = "Data Source=mySQLServer; Initial Catalog=MyDB; Trusted_Connection=True;";
. ".\Out-DataTable.ps1"
$csvDataTable = Import-CSV -Path "MyCSV_FileAndPath" | Out-DataTable
$bulkCopy = new-object ("Data.SqlClient.SqlBulkCopy") $ConnectionString
$bulkCopy.DestinationTableName = "to_MyTableName"
$bulkCopy.WriteToServer($csvDataTable)
}
Catch
{
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
"Error: Job starten lukt niet : ($ErrorMessage) " | out-file $logNaam -append
"Error: Job starten lukt niet : ($FailedItem) " | out-file $logNaam -append
}
Finally
{}
#----------------------------------------------------------------
Running this code in the PowerShell command prompt, I get this error:
Unexpected token 'data' in expression or statement.
At .\MyScript.ps1:20 char:27
+ $ConnectionString = "Data <<<< Source=MySQLServer; Initial Catalog=MyDB
; Trusted_Connection=True;";
+ CategoryInfo : ParserError: (data:String) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken
I'm stuck with this and have no clue where to start. Changing Data Source=MySQLServer to Server=MySQLServer does not solve it. The message only changed pointing to the position following MySQLServer<<<.
Also adding the Windows server-name to it (MyWinServer\MySQLServer) did not help, either.
Any advise, directions, explanation or help to code this script would by much appreciated.
I've created a Drupal7 module to extract the data from Salesforce
The idea is that I should be able to run a SOQL query and load this into an array.
I'm getting an error message saying
"SOAP Error Parsing WSDL: Couldn't load from 'soapclient/partner.wsdl.xml'
failed to load external entity "soapclient/partner.wsdl.xml" in SoapClient->SoapClient()
I've checked the path and confirm this is pointing to the correct file.
Here is my code
define("USERNAME", "salesforce#decawave.com");
define("PASSWORD", "Decawave3");
define("SECURITY_TOKEN", "MfNG8OgO06l4hVWFpi0MjDMeN");
require_once ('soapclient/SforcePartnerClient.php');
$connection = new SforcePartnerClient();
$connection->createConnection("soapclient/partner.wsdl.xml");
$connection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
$query = "SELECT Name FROM TREK__c";
$result = $Connection->query($query);
foreach($result as $record)
{
$id[] = $record->Name;
}