1/45
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
The ___________________ command takes row JSON as input and converts it into PowerShell objects.
ConvertFrom-Json
To continue to add records to a CSV file rather than overwriting the existing records, use the ______________ option to the Export-CSV command.
-append
The statement below
$employees =Import-CSV "Employee.csv"
populates the array $employees with the contents of the specified file.
_______________________ data means to convert it into data that can be used in your script.
Parsing
To add the worksheet, WK1, to an existing Excel workbook, Processes.xlsx:
Get-Process | Export-Excel -Worksheetname WK1
The __________________ command reads a spreadsheet into a PSCustomObject.
Import-Excel
JSON stands for Javascript Object Notation
True
JSON is a file format that is heavily used in web and cloud development.
True
The command used to create CSV files from a PowerShell object is
Export-CSV
You can create a CSV file in Excel by saving as .CSV
True
You can create a .CSV file in notepad by separating each value with ; and including headers in the first row.
False
PowerShell can read data from _______________ files. Select ALL the answers you mark as correct.
JSON & CSV
A CSV file must be in a specific format with headers for each column of data in the first row.
True
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
A PowerShell module typically is composed of one or more ____________.
functions
Which of the commands below would help you to find modules dealing with printing?
Find-Module -name "*print*"
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
PowerShell Modules all have the extension _____________
.psm1
To manually import a module xyz, use the ____________________ command.
import-Module -name xyz
______________ are groups of similar functions that are packaged together and distributed for others to use across many scripts.
Modules
A module can be imported either manually or automatically.
True
Get-Module -_________ displays a list of all of the modules currently available to you within your session.
listavailable
Before using a module, you must
install it and then import it.
The ___________________ command allows you to see all the modules on your system available to you in your current session.
Get-Module
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
To add a directory such as C:\Scripts to the path, for the current PowerShell session only, enter the following
$env:PSModulePath + ';C:\Scripts'
As of PowerShellv3, PowerShell auto-imports modules when a command is referenced.
True
PowerShel comes with many modules installed by default.
True
Uninstalling and Removing a module both accomplish the same thing.
False
A __________________ function is a function that isn't exported to a user and only works inside a script or module.
private
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
Modules that are installed by default are typically stored in
C:\Windows\System32\WindowsPowerShell\1.0 \Modules
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
To create a .psd1 file template, you can use the ________________ command.
New-ModuleManifest
A ___________ is a labeled piece of code that performs a single task.
function
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.
$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
Choose the best answer to call the function defined below:
function Function1
{
function statement 1
function statement 2
}
Function1
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!
For a function to be executed, it must be called.
True
A PowerShell function can use two kinds of pipeline input. Choose the types listed below.
ByValue & ByPropertyName
________________ allow you to "pass in" different values to the function each time that you run it.
Parameters
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
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
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
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!