Vinnaren i pepparkakshustävlingen!
2018-01-25, 09:58
  #1
Medlem
Hej!
Jag försöker klura ut å lära mig Windows powershell i windows 10 . Men de går inte sådär riktigt bra..
Har stött på problem där jag inte får till det så de fungerar.
Kommer säkert va skrattretande för många men , men alla e vi nybörjar i början..

Mitt problem är.

Write a PowerShell script that asks users to choose between these four items:

See a list of processes on the system
See a list of services on the system
Send a ping
Double a number

Write the script to implement each choice:

If the user picks the first option, display a list of processes on the system.
If the user picks the second option, display a list of services on the system.
If the user picks the third option, ask the user for an IP address or FQDN (fully qualified domain name) to ping, and then send a ping using the appropriate PowerShell cmdlet (not the ping utility).
If the user picks the fourth option, ask the user for a number, and then display the output like this: Your original number was 5, but now it’s 10.

Jag vet inte riktigt hur jag ska börja och å få till det.
Började scriptet med

#clear of console
clear-host

#promts the user to choose from list,which is stored in a variable called $list
$list = Read - Host " Processes and Service
Service and System
Send ping
Double number"
#promts the user to choose from list, which is stoerd in a variable called $processes
$processes = Read-Host "Processe1,
Processe2
Service1
Service2"
...

Sen är det stop.
Citera
2018-01-25, 12:40
  #2
Medlem
Dhalsims avatar
En start i alla fall

Kod:
function Show-Menu
{
	param (
		[string]$Title = 'Menu'
		)
		cls
		Write-Host "==============$Title=============="
		
		Write-Host "1: See a list of processes on the system"
		Write-Host "2: See a list of services on the system."
		}
		do
{
     Show-Menu
     $input = Read-Host "Please make a selection"
     switch ($input)
     {
           '1' {
                cls
                Get-Process
           } '2' {
                cls
                Get-Service
           } 
     }
     pause
}
until ($input -eq 'q')
Citera
2018-01-25, 12:42
  #3
Medlem
tusen tack!
Citera
2018-01-25, 14:18
  #4
Moderator
Protons avatar
Programvara: Windows --> C#, VB.NET och .NET Framework
/Moderator
Citera

Stöd Flashback

Flashback finansieras genom donationer från våra medlemmar och besökare. Det är med hjälp av dig vi kan fortsätta erbjuda en fri samhällsdebatt. Tack för ditt stöd!

Stöd Flashback