Powershell.org



VERIFIED EFFECTIVEPOWERSHELL TOOLMAKERThis entire examination packet must be turned in.PRINT LEGIBLY, IN CAREFULLY-FORMED UPPERCASE BLOCK LETTERS (AND NUMBERS) ONLY.PRINT ONE LETTER OR NUMBER PER BLOCK TO ENSURE LEGIBILITY.USE RED BALL POINT PEN ONLY.CANDIDATE ID (from cover sheet)SURNAME / LAST NAMEGIVEN NAME / FIRST NAMEIn taking this exam, you are agreeing that the contents of the exam are confidential and protected by intellectual property law. You agree not to disclose the contents of this exam, your answers, or the exam instructions to anyone, without the written permission of the CEO of The DevOps Collective, Inc.___________________________________________________________SignatureDateINSTRUCTIONSOn the next page, you will see a Windows PowerShell console transcript. It shows a particular function being used from within the shell.On the final page of this packet, you will find the code for a function. The code provided here is incorrect. As-is, it may run, but it will not produce the exact same results as shown in the transcript.Using a red ballpoint pen, you must:Cross out any portions of the code that should not be there. This applies to any code that does not contribute to the exact output shown in the transcript.Circle any portions of code that should be there, but are incorrect, because as provided they do not generate the same output as shown in the transcript.Make a note about anything that is missing from the code provided, which would need to be added in order to produce the transcript shown. You do not need to write the exact code that is missing; simply indicate what is missing, and where the missing code should go.You can assume that property values shown in the transcript were correct for the machine that they were run on.You may not use any kind of computer, smartphone, tablet, or other device during the exam, whether connected to the Internet or not.In order to pass, you must find at least 80% of the problems in the code provided.You may not ask any questions of the exam proctor.You may detach the page containing the code, so that you can more easily compare it to the transcript. When turning in your packet, please ensure that the first page and the function page are still attached. The remainder of this packet may be turned in and discarded. The proctor has a stapler that can be used to attach the code page to this first page.TRANSCRIPT**********************Windows PowerShell transcript startStart time: 20160306122218Username : COMPANY\Administrator Machine : WIN81 (Microsoft Windows NT 6.3.9600.0) **********************Transcript started, output file is c:\Sample.txtPS C:\> Get-Command -Module CorpToolsCommandType Name ModuleName ----------- ---- ---------- Function Get-CorpNodeInfo CorpTools PS C:\> Help Get-CorpNodeInfo -fullPS C:\> Get-CorpNodeInfocmdlet Get-CorpNodeInfo at command pipeline position 1Supply values for the following parameters:ComputerName[0]: win81ComputerName[1]: dcComputerName[2]: CDiskSize : 42580570112ComputerName : win81SPVersion : 0OSVersion : 6.3.9600CDiskFree : 23200825344CDiskSize : 31843151872ComputerName : dcSPVersion : 0OSVersion : 6.3.9600CDiskFree : 24902488064PS C:\> "win81","dc" | Get-CorpNodeInfo -verboseVERBOSE: Connecting to win81 via WsmanVERBOSE: Operation '' complete.VERBOSE: Perform operation 'Enumerate CimInstances' with following parameters, ''namespaceName' = root\cimv2,'className' = Win32_OperatingSystem'.VERBOSE: Operation 'Enumerate CimInstances' complete.VERBOSE: Perform operation 'Query CimInstances' with following parameters, ''queryExpression' = SELECT * FROM Win32_Volume WHERE Name = 'C:\\','queryDialect' = WQL,'namespaceName' = root\cimv2'.VERBOSE: Operation 'Query CimInstances' complete.CDiskSize : 42580570112ComputerName : win81SPVersion : 0OSVersion : 6.3.9600CDiskFree : 23200825344VERBOSE: Connecting to dc via WsmanVERBOSE: Operation '' complete.VERBOSE: Perform operation 'Enumerate CimInstances' with following parameters, ''namespaceName' = root\cimv2,'className' = Win32_OperatingSystem'.VERBOSE: Operation 'Enumerate CimInstances' complete.VERBOSE: Perform operation 'Query CimInstances' with following parameters, ''queryExpression' = SELECT * FROM Win32_Volume WHERE Name = 'C:\\','queryDialect' = WQL,'namespaceName' = root\cimv2'.VERBOSE: Operation 'Query CimInstances' complete.CDiskSize : 31843151872ComputerName : dcSPVersion : 0OSVersion : 6.3.9600CDiskFree : 24902488064PS C:\> Get-CorpNodeInfo -ComputerName offlineWARNING: Failed to connect to offlinePS C:\> Get-CorpNodeInfo -ComputerName win81,offline,dc -Protocol DcomCDiskSize : 42580570112ComputerName : win81SPVersion : 0OSVersion : 6.3.9600CDiskFree : 23201869824WARNING: Failed to connect to offlineCDiskSize : 31843151872ComputerName : dcSPVersion : 0OSVersion : 6.3.9600CDiskFree : 24902488064PS C:\> Stop-Transcript**********************Windows PowerShell transcript endEnd time: 20160306122414**********************CODE<#.SYNOPSISRetrieves OS versioning and disk informationfrom one or more machines using either WS-MANor DCOM..PARAMETER ComputerNameOne or more computer names..PARAMETER ProtocolDefaults to Wsman; can be Dcom also. Dcomuses the older WMI service; Wsman is CIM.#>function Get-CorpNodeInfo { Param( [Parameter(ValueFromPipelineByPropetyName=$True)] [string[]]$ComputerName, [ValidateSet('Cim','Wmi')] [string]$Protocol = 'Cim' ) PROCESS { ForEach ($comp in $ComputerName) { Write-Output "Connecting to $comp via $protocol" if ($Protocol -eq 'Dcom') { $opt = New-CimSessionOption -Protocol Dcom } else { $opt = New-CimSessionOption -Protocol Wsman } try { $session = New-CimSession -SessionOption $opt ` -ComputerName $Comp $os = Get-CimInstance -CimSession $session ` -ClassName Win32_OperatingSystem $disk = Get-CimInstance -CimSession $session ` -ClassName Win32_Volume ` -Filter "Name = 'C:\\'" $props = @{'ComputerName' = $Computername 'OSVersion' = $os.version 'SPVersion' = $os.ServicePackMajorVersion 'CDiskSize' = $disk.Capacity 'CDiskFree' = $disk.FreeSpace} New-Object -TypeName PSObject ` -Property $props } catch { Write-Error "Failed to connect to $comp" } } }} ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download