Powershell - Exam 2

0.0(0)
studied byStudied by 14 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/45

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

46 Terms

1
New cards

The ___________________ command takes row JSON as input and converts it into PowerShell objects.

ConvertFrom-Json

2
New cards

To continue to add records to a CSV file rather than overwriting the existing records, use the ______________ option to the Export-CSV command.

-append

3
New cards

The statement below

$employees =Import-CSV "Employee.csv"

populates the array $employees with the contents of the specified file.

4
New cards

_______________________ data means to convert it into data that can be used in your script.

Parsing

5
New cards

To add the worksheet, WK1,  to an existing Excel workbook, Processes.xlsx:

Get-Process | Export-Excel -Worksheetname WK1

6
New cards

The __________________ command reads a spreadsheet into a PSCustomObject.

Import-Excel

7
New cards

JSON stands for Javascript Object Notation

True

8
New cards

JSON is a file format that is heavily used in web and cloud development.

True

9
New cards

The command used to create CSV files from a PowerShell object is 

Export-CSV

10
New cards

You can create a CSV file in Excel by saving as .CSV

True

11
New cards

You can create a .CSV file in notepad by separating each value with ; and including headers in the first row.

False

12
New cards

PowerShell can read data from _______________ files.  Select ALL the answers you mark as correct.

JSON & CSV

13
New cards

A CSV file must be in a specific format with headers for each column of data in the first row.

True

14
New cards

Assuming that the file Emp.csv hold the following data,

SSN, Name, Wage

344-22-9999, "Doe, John", 10.50

444-23-2323, "Smith, Mary", 15.50

555-33-333, "Gonzales, Henry", 15.00

 

If the following script begins running, which statement below would replace "statement1" to print the name of each employee?

$Employees = Import-CSV "Emp.csv"

foreach ($emp in $Employees)

{

     statement1

     ...

}

write-host $emp.name

15
New cards

A PowerShell module typically is composed of one or more  ____________.

functions

16
New cards

Which of the commands below would help you to find modules dealing with printing?

Find-Module -name "*print*"

17
New cards

Once a module folder path is in the PSModulePath environment variable, you have to import the module into the current session to use it. Because of PowerShell’s auto-importing feature, if you have a module installed, you can usually call the function you want first, and PowerShell will auto-import the module it belongs to.

True

18
New cards

PowerShell Modules all have the extension _____________

.psm1

19
New cards

To manually import a module xyz, use the ____________________ command.

import-Module -name xyz

20
New cards

______________ are groups of similar functions that are packaged together and distributed for others to use across many scripts. 

Modules

21
New cards

A module can be imported either manually or automatically.

True

22
New cards

Get-Module -_________ displays a list of all of the modules currently available to you within your session.

listavailable

23
New cards

Before using a module, you must 

install it and then import it.

24
New cards

The ___________________ command allows you to see all the modules on your system available to you in your current session.

Get-Module

25
New cards

The ______________________ is a repository of thousands of PowerShell modules and scripts that anyone with an account can freely upload to or download from.

PowerShell Gallery

26
New cards

To add a directory  such as C:\Scripts to the path, for the current PowerShell session only, enter the following

$env:PSModulePath + ';C:\Scripts'

27
New cards

As of PowerShellv3,  PowerShell auto-imports modules when a command is referenced.

True

28
New cards

PowerShel comes with many modules installed by default.

True

29
New cards

Uninstalling and Removing a module both accomplish the same thing.

False

30
New cards

A __________________ function is a function that isn't exported to a user and only works inside a script or module.

private

31
New cards
  • A typical PowerShell module consists of 

  • A. a .psmod1 file (the module)

  • B. a .psmm file

  • C. a .psm1 file (the module)

  • D. a .psd1 file (the module manifest)

  • E. a Folder

C, D & E

32
New cards

Modules that are installed by default are typically stored in

C:\Windows\System32\WindowsPowerShell\1.0 \Modules

33
New cards

You can tell PowerShell to add a new module path by using the ______________ environment variable, which defines each module folder separated by a semicolon

$PSModulePath

34
New cards

To create a .psd1 file template, you can use the ________________ command.

New-ModuleManifest

35
New cards

 A ___________ is a labeled piece of code that performs a single task.

function

36
New cards

Assuming that the specified file exists, what will happen when the following code is executed?

function Test-Object { 
 param( 
  [Parameter(Mandatory, ValueFromPipeline)] 
  [string]$C
   ) 

 process {
 $f = "\\$C\windows\system32\config-file"
   get-childItem $f

   $f

    } 
  } 

$computers = @("Cottonmouth", "Diamondback", "Python") 
$computers | Test-Object 

The contents of windows\system32\config-file on Cottonmouth, Diamondback and Python is displayed.

37
New cards

$computers = @("Cottonmouth", "Diamondback", "Python") 

Assuming the above and that the specified file exists, choose the correct way to call the function below.

function Test-Object { 
 param( 
  [Parameter(Mandatory, ValueFromPipeline)] 
  [string]$C
   )

process { 
 $f = "\\$C\windows\system32\config-file"
   get-childItem $f

   $f

  }
  } 

$computers | Test-Object

38
New cards

Choose the best answer to call the function defined below:

function Function1 

{

     function statement 1

     function statement 2

}

Function1

39
New cards

What would be the result of the following?

function Install-Software
  { [CmdletBinding()]
  param(
  [Parameter()]
  [string]$Version = 2)
  Write-Host "I installed software version $Version. Yippee!“
   }

Install-Software 

I installed software version 2. Yippee!

40
New cards

For a function to be executed, it must be called.

True

41
New cards

A PowerShell function can use two kinds of pipeline input.  Choose the types listed below. 

ByValue & ByPropertyName

42
New cards

________________ allow you to "pass in" different values to the function each time that you run it.

Parameters

43
New cards

What happens if I have a parameter defined as mandatory in my function definition, but it is not included in the function call?

An error occurs

44
New cards

What output results from the following function and call?

Function Do-What

     [CmdletBinding()]
          param(                   
                 [Parameter(Mandatory)]
                     [int] $Val1,
                 [Parameter(Mandatory)]
                     [int] $Val2,
                  [Parameter(Mandatory)]
                    [int] $Val3
                )
        $Val4 = [double]($val1 + $val2 + $val3)/3
        write-host $val4
        }

        Do-What 80 90 100

90

45
New cards

What happens when the function below is called as listed below?

function Do-this {
  param( 
  [Parameter(Mandatory)] 
  [ValidateSet('1','2')] 
  [string]$n
  )  
 }
do-this 3

An error will occur

46
New cards

Assume you have entered the following function into PowerShell:

function Install-Software

    {

       [CmdletBinding()]

          param(                   

                 [Parameter()]

                     [string] $Version    

                    )

    Write-Host "I installed software version $Version. Yippee!"

      }

Your function is called as follows:  Install-Software 5

What output will result from your call?

I installed software version 5. Yippee!