Answers to Exercises
1.1. PowerShell can be run using command line options from another tool such as Cmd.exe or bash or by starting a new session on the PowerShell command line.
1.2. PowerShell, .NET Core and C#.
1.3. Yes, by using the PowerShell extension.
1.4. PowerShellGet module.
1.5 It is a package repository containing scripts, modules, and Desired State Configuration (DSC) resources can be downloaded and leveraged.
1.6. VS Code --install-extension command line switch providing the path a .vsix file. as follows: code --install-extension <File path>/myextension.vsix
2.1. 15
2.2. In simple terms, cmdlets perform an action and typically return a Microsoft .NET Framework object to the next command in the pipeline.
2.3. It makes it possible to perform customized administrative actions in PowerShell.
2.4. Implementing a cmdlet class that derives from one of two specialized cmdlet base classes.
2.5. Verb and Noun specification to invoke the cmdlet.
2.6. 35
2.7. Using command syntax diagrams.
2.8. Aliases are alternate names for cmdlets or command elements such as a function, script, file, or executable file.
2.9. 5. They are Get-Alias, New-Alias, Set-Alias, Export-Alias, and Import-Alias.
2.10. Get-Help cmdlet.
3.1. A unit of memory in which values are stored.
3.2. Text strings that start with a dollar ($) sign.
3.3. These may be difficult to use.
3.4. No.
3.5. Yes.
3.6. Using the Get-Variable cmdlet.
3.7. Variables are not limited to specific types of objects.
3.8. By the .NET types of the values of the variables.
3.9. Enclose the variable name with curly braces {}.
3.10. Variables are only available in the scope in which they are created.
3.11. Using the PowerShell Variable provider. It behaves similar to a file system drive. Contains PowerShell variables in your session and their values.
3.12. With command: Get-Command -Noun Variable
4.1. Using a pipeline operator.
4.2. Left to right.
4.3. As a single operation.
4.4. By-Value or By-PropertyName.
4.5.Parameters must be able to accept input from a pipeline. Parameters must be able to accept the type of object sent or a type that can be converted to the expected type. Parameters are not used in the command.
4.6. One at a time.
5.1. As if typed on the command prompt.
5.2. Yes, named, positional, switch and dynamic.
5.3. Command line or from the pipeline.
5.4. A Function keyword, a scope (optional), a name that you select, any number of named parameters (optional), and one or more PowerShell commands enclosed in braces {}
5.5. Any.
5.6. A function only exists in the scope in which it was created.
5.7. Automatically stores all functions and filters in PowerShell.
6.1. Modules allow administrators who write commands to organize them and share them with others.
6.2. All cmdlets and providers in a PowerShell session are added by a module or a snap-in.
6.3. Get-Module -ListAvailable
6.4. Get-Module
6.5. By adding the Import-Module command into your PowerShell profile.
6.6. $Env:PSModulePath
6.7. A name conflict is when more than one command has the same name. Name conflicts are caused by importing modules when the imported module has commands that have the same name as other commands or items in the session.
6.8. They can result in important commands being hidden or replaced.
6.9. Alias, Certificate, Environment, FileSystem, Function, Registry, Variable and WSMan.
6.10. Get-PSProvider
6.11. The same way you would data on a file system drive.
6.12. Get-Help <provider-name>
7.1. .ps1
7.2. Commands in a script can be run simply by typing the script path and file name.
7.3. The default PowerShell execution policy is "restricted,” and prevents all scripts from running, including those written on the local computer.
7.4. Set-ExecutionPolicy AllSigned , Set-Executionpolicy RemoteSigned
7.5. get-help <path to script>\<ScriptName>.ps1
7.6. Using a text editor (such as Notepad) or a script editor (such as VS Code).
7.7. Using the Param keyword.
7.8. Using dot sourcing.
7.9. A script module is a module that consists entirely or primarily of a script and supporting resources. .psm1
7.10. A set of statements or expressions that can be used as a single unit.
8.1. Enter-PSSession cmdlet
8.2. 16
8.3. Using the ComputerName and ScriptBlock parameters.
8.4. New-PSSession cmdlet
8.5. Using the Invoke-Command cmdlet with the Session and ScriptBlock parameters.
8.6. Using the Invoke-Command cmdlet with the ComputerName and FilePath parameters.
8.7. PowerShellGet module.
8.8. Modules, DSC resources, role capabilities, and scripts.
8.9. Install-PackageProvider -Name NuGet -Force
8.10. Install-Module -Name PowerShellGet -Force
8.11. [Update-Module][] cmdlet
8.12. [Update-Script][] cmdlet
8.13. Get-InstalledModule cmdlet
8.14. Get-InstalledScript cmdlet