Do { Show-Menu $CN = Read-Host "Enter PC name" $input = Read-Host "Please make a selection" switch ($input) { '1' { cls Write-Host "Bios info:" $x = Get-WmiObject -Class win32_bios -ComputerName $CN $x break; } '2' { cls Write-Host "System info:" $x = Get-WmiObject -Class win32_computersystem -ComputerName $CN $x break; } '3' { cls Write-Host "HDD free space info:" $x = Get-WmiObject -Class win32_logicaldisk -ComputerName $CN | select deviceid,drivetype,@{Label='freespace(gb)'; Expression={$_.freespace/1GB -as [int]}} $x break; } 'q' { return } default {Write-Host "Make sure to choose one of the options from the menu" -ForegroundColor Red} } $saveOrNot = Read-Host "Would you like to save these information in a file? (Y/N)" if ($saveOrNot -like "Y") { $ext = Read-Host "Please choose a file format (.txt, .csv or .htm)" SaveInfo $CN $ext } } while ($saveOrNot -like "N") Function SaveInfo($ComputerName,$fileformat) { $FN = $ComputerName + "_Info"+$fileformat $SavePath = "C:\TEMP\$FN" Switch ($ext) { '.txt' {Out-File -FilePath $SavePath -Inputobject $x} '.csv' {Export-Csv -Path $SavePath -InputObject $x -NoTypeInformation} '.htm' {Out-File -FilePath $SavePath -InputObject $x} } } function Show-Menu { cls Write-Host "================ My menu ================" -ForegroundColor Cyan Write-Host "1: Press '1' for BIOS information." Write-Host "2: Press '2' for System information." Write-Host "3: Press '3' for HDD free space information." Write-Host "q: Press 'q' to quit." }