Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 12890

SQL Store procedure to run PowerShell commands ( need to add active directory user to security Group)

$
0
0

we have the list of the new members in CSV file (coming every week to update)

the CSV file name is c:\scripts\members.csv

and have two columns

GroupName                   Member

SG-BI-USERS                 XXXXX@ABC.ORG

SG-BI-USERS                  YYYYY@ABC.ORG

SG-BI-USERS                  ZZZZZ@ABC.ORG

the powershell screipt to add the member to security group command is below 

$csv = Import-Csv -Path "c:\scripts\members.csv"<o:p></o:p>

ForEach ($item In $csv) {  $Add_group = Add-ADGroupMember -Identity $item.GroupName -Members $item.Membername }

Or

using  Exchange PowerShell.

import-Csvc:\scripts\members.csv | Foreach {Add-ADGroupMember -Identity $_.Group -Members $_.Member}

<o:p style="">Note: USER Credential  to update/insert the members to security group is  ABC\poweruser1   password= xxyyzz</o:p>

The Question is how to write/include this powershell scripts in store procedure?

or write a sql store procedure to run this powershell command ..



Viewing all articles
Browse latest Browse all 12890

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>