Param( [Parameter (Mandatory=$true)] [string]$drive, [string] $computerName #end param $env:computerName Function Check-AllowedValue ($drive, { $drives Get-WmiObject -class Win32_Volume -computername...



Book reference: Windows PowerShell Step by Step 3rd Edition - Ed Wilson


Chapter 19


10. On the attached script, do you know what is the error handling function?


Param(<br>[Parameter (Mandatory=$true)]<br>[string]$drive,<br>[string] $computerName<br>#end param<br>$env:computerName<br>Function Check-AllowedValue ($drive,<br>{<br>$drives<br>Get-WmiObject -class Win32_Volume -computername<br>Where-Object { $ _ . DriveLetter } I<br>ForEach-–Object { $drives += @{ $ .DriveLetter<br>$drives.contains ($drive)<br>}<br>$computerName)<br>= $null<br>$computerName |<br>$ . DriveLetter } }<br>#end function Check-AllowedValue<br>Function Get-DiskInformation($computerName,$drive)<br>{<br>Get-WmiObject -class Win32_volume -computername<br>}<br>$computername -filter

Extracted text: Param( [Parameter (Mandatory=$true)] [string]$drive, [string] $computerName #end param $env:computerName Function Check-AllowedValue ($drive, { $drives Get-WmiObject -class Win32_Volume -computername Where-Object { $ _ . DriveLetter } I ForEach-–Object { $drives += @{ $ .DriveLetter $drives.contains ($drive) } $computerName) = $null $computerName | $ . DriveLetter } } #end function Check-AllowedValue Function Get-DiskInformation($computerName,$drive) { Get-WmiObject -class Win32_volume -computername } $computername -filter "DriveLetter '$drive'" #end function Get-BiosName *** Entry Point To Script *** if(Check-AllowedValue -drive $drive -computername $computerName) { Get-DiskInformation -computername $computerName -drive $drive } else { Write-Host -foregroundcolor blue "$drive is not an allowed value:" }

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here