Hello,
I tried your suggestion and now it’s taking the database name which I am providing in the prompt option. But now I am getting a different error which is as below.
It is showing as a parser error but I am not able to find it. So please help.
Also below is the playbook that I am using.
fatal: [SQLSERVER2]: FAILED! => {“changed”: true, “cmd”: “$sql= "create database "Praveen800"\n ON (NAME = "Praveen800_dat", FILENAME = E:\Database\"Praveen800.mdf", SIZE = 10MB, MAXSIZE = 50MB, FILEGROWTH = 5MB)\n LOG ON (NAME = "Praveen800_log", FILENAME = E:\Database\"Praveen800.ldf", SIZE = 5MB, MAXSIZE = 25MB, FILEGROWTH = 5MB)"\n Invoke-SqlCmd -Query $sql”, “delta”: “0:00:01.468781”, “end”: “2021-01-14 07:50:05.202033”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2021-01-14 07:50:03.733252”, “stderr”: “At line:1 char:89\r\n+ … -Object Text.UTF8Encoding $false; $sql= "create database "Praveen800"\r\n+ ~~~~~~~~~~~\r\nUnexpected token ‘Praveen800"\r\n ON (NAME = "Praveen800_dat", FILENAME = E:\Database\"Praveen800.mdf", SIZE = 10MB, MAXSIZE = 50MB, FILEGROWTH = \r\n5MB)\r\n LOG ON (NAME = "Praveen800_log", FILENAME = E:\Database\"Praveen800.ldf", SIZE = 5MB, MAXSIZE = 25MB, \r\nFILEGROWTH = 5MB)"’ in expression or statement.\r\n + CategoryInfo : ParserError: ( , ParentContainsErrorRecordException\r\n + FullyQualifiedErrorId : UnexpectedToken”, “stderr_lines”: [“At line:1 char:89”, “+ … -Object Text.UTF8Encoding $false; $sql= "create database "Praveen800"”, “+ ~~~~~~~~~~~”, “Unexpected token 'Praveen800"”, " ON (NAME = "Praveen800_dat", FILENAME = E:\Database\"Praveen800.mdf", SIZE = 10MB, MAXSIZE = 50MB, FILEGROWTH = “, “5MB)”, " LOG ON (NAME = "Praveen800_log", FILENAME = E:\Database\"Praveen800.ldf", SIZE = 5MB, MAXSIZE = 25MB, “, “FILEGROWTH = 5MB)"’ in expression or statement.”, " + CategoryInfo : ParserError: ( , ParentContainsErrorRecordException”, " + FullyQualifiedErrorId : UnexpectedToken”], “stdout”: “”, “stdout_lines”: }