to type "System.Int32"Error:"Input string was not in a correct format - mysql

I Run the this power shell script
"$InstallPh\Database\bin\mysql.exe" -'uroot' -'e''select status from zibcatalog.zibmonitor where backupset="$BACKUPSET" AND operation="ZIB_BACKUP";' > 'c:\\auto\\firstbackup-result.txt'
Powershell throws this error message:
Cannot convert value "\Database\bin\mysql.exe" to type "System.Int32". Error: "Input string was not in a correct format."
At line:1 char:2
+ "$InstallPh\Database\bin\mysql.exe" -'uroot' -'e''select status from zibcatalog ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvalidCastFromStringToInteger

Your problems the way your trying to execute and pass the parameters to MySQL.exe. Try using the & operator to execute the exe file.
& "$InstallPh\Database\bin\mysql.exe" "-uroot -e'select status from zibcatalog.zibmonitor where backupset=`"$BACKUPSET`" AND operation=`"ZIB_BACKUP`";'" > 'c:\auto\firstbackup-result.txt'

Related

Connect-MsolService using graph access tokens failed

I usually run a modified version of the script provided by Microsoft on how to “Convert per-user MFA enabled and enforced users to disabled”.
If I run it interactively, the cmdlet “Connect-MsolService” works like a charm. However, as soon as I tried to use the parameters “AdGraphAccessToken” and “MsGraphAccessToken” it throws the following errors:
Connect-MsolService : An unexpected error occurred.
At line:1 char:1
+Connect-MsolService -AdGraphAccessToken $AadAccessToken -MsGraphAcces ...
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo : OperationStopped: (:) [Connect-MsolService], MicrosoftOnlineException
+FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.InvalidHeaderException,Microsoft.Online.Administration.Automation.ConnectMsolService
Connect-MsolService : Exception of type 'Microsoft.Online.Administration.Automation.MicrosoftOnlineException' was thrown.
At line:1 char:1
+Connect-MsolService -AdGraphAccessToken $AadAccessToken -MsGraphAcces ...
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo : OperationStopped: (:) [Connect-MsolService], MicrosoftOnlineException
+FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.MicrosoftOnlineException,Microsoft.Online.Administration.Automation.ConnectMsolService
When passing the same tokens to the cmdlet “Connect-AzureAD”, it goes as expected.
I use the following snippet for acquiring the tokens:
$TenantId = 'MyTenantId'
$Authority = 'https://login.microsoftonline.com/{0}/oauth2/v2.0/token' -f $TenantId
$ClientId = 'MyAzureActiveDirectoryAppId'
$ClientSecret = 'MyAzureActiveDirectoryAppSecret'
$Parameters =
#{
Authority = $Authority
ClientId = $ClientId
ClientSecret = (ConvertTo-SecureString -String $ClientSecret -AsPlainText -Force)
}
$AadAccessToken = (Get-MsalToken #Parameters -Scopes 'https://graph.windows.net/.default').AccessToken
$MsAccessToken = (Get-MsalToken #Parameters -Scopes 'https://graph.microsoft.com/.default').AccessToken
#Connect-AzureAD -AadAccessToken $AadAccessToken -MsAccessToken $MsAccessToken -AccountId $ClientId -TenantId $TenantId
Connect-MsolService -AdGraphAccessToken $AadAccessToken -MsGraphAccessToken $MsAccessToken -AzureEnvironment AzureCloud
I know that the modules MSOnline a AzureAD have been deprecated in favor of Microsoft.Graph, but since there is no other programmatic way to Enable per-user MFA I would kindly ask you people for some guidance: am I missing something here?
There is a way to create phoneAuthenticationMethod MFA using the MS graph which is still in beta phase:
https://learn.microsoft.com/en-us/graph/api/authentication-post-phonemethods?view=graph-rest-beta&tabs=powershell

jinja2.exceptions.TemplateSyntaxError: expected token ':', got '}'

I'm trying to use an xcom_pull inside an SQL phrase executed by a Snowflake operator in Airflow.
I need the task_id name to use a variable since I want to support different tasks.
I tried this syntax but seems it is not being rendered ok.
Anyone has an idea how to do it?
This is the Python code:
for product, val in PRODUCTS_TO_EXTRACT_INC.items():
product_indicator, prefix = val
params['product_prefix'] = prefix
calculate_to_date = SnowflakeOperator(
dag=dag,
task_id=f'calculate_to_date_{prefix}',
snowflake_conn_id = SF_CONNECTION_ID,
warehouse=SF_WAREHOUSE,
database=BI_DB,
schema=STG_SCHEMA,
role=SF_ROLE,
sql= [ """
{SQL_FILE}
""".format(SQL_FILE="{% include '" + QUERIES_DIR + ETL + "/calculate_to_date.sql'" + " %}")
],
params=params
)
This is the SQL code for calculate_to_date.sql:
select '{{{{ (ti.xcom_pull(key="return_value", task_ids=["calculate_from_date_{}"])[0][0]).get("FROM_DATE") }}}}'.format(params.product_prefix) AS TO_DATE
This is the error message:
File "/home/airflow/gcs/dags/Test/queries/fact_subscriptions_events/calculate_to_date.sql", line 11, in template
select '{{{{ (ti.xcom_pull(key="return_value", task_ids=["calculate_from_date_{}"])[0][0]).get("FROM_DATE") }}}}'.format(params.product_prefix)
jinja2.exceptions.TemplateSyntaxError: expected token ':', got '}'
the correct syntax is
select '{{ (ti.xcom_pull(key="return_value", task_ids="calculate_from_date_{}".format(params.product_prefix))[0]).get("FROM_DATE") }}' AS TO_DATE
it works like a charm

Error in fromJSON(commandArgs(1)) : unexpected character '''

I am calling a R script from Scala by using scala.sys.process. This script takes a command line argument in JSON format and processes it. I am using rjson's fromJSON function to store the JSON in a list.
This works very fine when I execute the R script from the command line:
$ ./dfChargerFlink.R '{"Id":"1","value":"ABC"}'
But when I call it from scala, I get the following error:
Error in fromJSON(commandArgs(1)) : unexpected character '''
Execution halted
This is the code I am using:
val shellCommand = "./dfChargerFlink.R '"+arg+"'"
return shellCommand !!
where arg is the JSON string.
You can notice that I have appended " ' " to both the sides of the JSON string as if I don't, I get this error:
Error in fromJSON(commandArgs(1)) : unclosed string
Execution halted
How can this be solved? Is it some bug?

Convert yymmdd to datetime using ssis derived column

Below are the strings representing date of birth (yymmdd). I want to convert it into datetime format and load into a database using ssis. How can I do it? In my derived column I have (DT_DATE)(SUBSTRING([Drv DOB],1,2) + "-" + SUBSTRING([Drv DOB],3,2) + "-" + SUBSTRING([Drv DOB],5,2)), but it's not working.
I GET THESE ERRORS:
[Derived Column [2]] Error: An error occurred while attempting to perform a type cast.
[Derived Column [2]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Derived Column" failed because error code 0xC0049064 occurred, and the error row disposition on "Derived Column.Inputs[Derived Column Input].Columns[Drv DOB]" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.
•470324
•470324
•470209
•101
•0
YEAR have 4 digits not 2, so it would be:
(DT_DATE)("20" + SUBSTRING([Drv DOB],1,2) + "-" +
SUBSTRING([Drv DOB],3,2) + "-" +
SUBSTRING([Drv DOB],5,2))
This works for me! Thanks everyone
([Drv DOB] == "0") || ([Drv DOB] == "101") ? NULL(DT_DBTIMESTAMP) : (DT_DBTIMESTAMP)(SUBSTRING([Drv DOB],1,2) + "-" + SUBSTRING([Drv DOB],3,2) + "-" + SUBSTRING([Drv DOB],5,2))

Error : Exception calling "MoveTo" with "1" argument(s): "The server is unwilling to process the request. "

I am trying to write a script to move OU of users in AD 2008
$Alias = "hareeshvm"
# Finding the location of the user account harveesm:
$Root = [ADSI]("LDAP://DC=corp,DC=bharatpetroleum,DC=com")
$searcher = new-object System.DirectoryServices.DirectorySearcher($root)
$searcher.filter = "(&(objectClass=user)(mailNickName= $Alias))"
$User = $searcher.findone()
# Binding the user account to $AUser and the OU to move to to $MovetoOU
$ADSPath = $User.Properties.adspath
$MoveToOU = [ADSI]("LDAP://OU=Temp,DC=corp,DC=bharatpetroleum,DC=com")
$AUser = [ADSI]("$ADSPath")
# Command to Do the actual move
$AUser.PSBase.moveto($MoveToOU)
And I am getting below mentioned error
Exception calling "MoveTo" with "1" argument(s): "The server is unwilling to process the request.
"
At D:\Ashish\MS Exchange\New User\newuserscreation.ps1:39 char:21
+ $AUser.PSBase.moveto <<<< ($MoveToOU)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
thx in advance