Ask Your Question
0

how to create new user in MSSQL on Windows 2008 R2 node using powershell script.

asked 2014-08-19 03:21:40 -0500

sayali gravatar image

updated 2014-09-15 14:46:05 -0500

I have installed a puppet master on Centos 5.6, the agent on windows 2008 R2, I have also installed MSSQL on windows 2008, I want to create a new user in MSSQL using powershell script, which is not getting created, please help I have written the following script for creating a new user:- the following script was written which was not giving any error:- param (
[String]$servername,
[String]$loginname,
[String]$LoginType,
[String]$Password
)

$login = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Login -ArgumentList $servername, $loginname
$login.LoginType = $LoginType
$login.Create($Password)

param (
[String]$servername,
[String]$loginname,
[String]$LoginType,
[String]$Password
)

$login = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Login -ArgumentList $servername, $loginname
$login.LoginType = $LoginType
$login.Create($Password)

the following script was written on puppet master:- class powershell { exec{'createuser': command => 'C:\userscript1\usercreation.ps1 localhost testuser6 SqlLogin password', command => 'write-output hostname', provider => powershell, } }

edit retag flag offensive close merge delete

Comments

first off. Why do you have two `command` parameter's set? second: any error output would be helpful.

ptierno gravatar imageptierno ( 2014-08-19 17:28:04 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-09-15 14:48:07 -0500

updated 2014-09-15 14:49:10 -0500

You may want to be sure you are on the latest version of the powershell provider. Earlier versions had a bug which prevented them running in a 64bit space. If you find this works outside of Puppet but fails inside Puppet runs, it is likely that issue.

We also have an x64 version of Puppet available as of 3.7.0. You will want to review the release notes to determine if it is right for you to upgrade: https://docs.puppetlabs.com/puppet/3....

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-08-19 03:21:40 -0500

Seen: 173 times

Last updated: Sep 15 '14