Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Needing some help, using powershell, I'm havin trouble creating a datatable and then inserting that datatable into a database I created. Below are the steps for the project and the script I have written so far that is working properly.

1.  Create an Active Directory organizational unit (OU) named “finance.”

2.  Import the financePersonnel.csv file (found in the “Requirements2” directory) into your Active Directory domain and directly into the finance OU. Be sure to include the following properties:

•  First Name

•  Last Name

•  Display Name (First Name + Last Name, including a space between)

•  Postal Code

•  Office Phone

•  Mobile Phone

3.  Create a new database on the Microsoft SQL server instance called “ClientDB.”

4.  Create a new table and name it “Client_A_Contacts.” Add this table to your new database.

5.  Insert the data from the attached “NewClientData.csv” file (found in the “Requirements2” folder) into the table created in part B4.

New-ADOrganizationalUnit -Name finance -Path "DC=consultingfirm,DC=COM"

Import-Module activedirectory

$ADUsers = Import-csvC:\Users\LabAdmin\Desktop\Requirements2\financePersonnel.csv

$TargetOU = "OU=finance,DC=consultingfirm,DC=com"

foreach ($User in $ADUsers)

{

$Parameters = @{

Name = $User.samAccount

GivenName = $User.First_Name

Surname = $User.Last_Name

PostalCode = $User.PostalCode

DisplayName = $($User.First_Name) + " " + $($User.Last_Name)

OfficePhone = $User.OfficePhone MobilePhone = $User.MobilePhone Path = $TargetOU } New-ADUser @Parameters -PassThru

}

$ConnectionString = "Data Source=.\SQLEXPRESS;initial catalog=master;Integrated Security=True;"

$NewDatabaseName = "ClientDB"

$con = New-Object Data.SqlClient.SqlConnection;

$con.ConnectionString = $ConnectionString;

$con.Open();

$sql = "CREATE DATABASE [$NewDatabaseName] COLLATE SQL_Latin1_General_CP1_CI_AS;"

$cmd = New-Object Data.SqlClient.SqlCommand $sql, $con;

$cmd.ExecuteNonQuery();

Write-Host "Database $NewDatabaseName is created!";

$cmd.Dispose();

$con.Close();

$con.Dispose();

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Storage Devices
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education