Skip to content

Latest commit

 

History

History
49 lines (33 loc) · 1.9 KB

chapter-4.md

File metadata and controls

49 lines (33 loc) · 1.9 KB

Chapter 4 | Parameters

  • Parameters provide required inputs to Cmdlets if needed. Few CmdLets do not require any inputs few have mandatory parameters

  • Paremeters are provided using a - hyphon i.e. Any-Cmdlet -Parameter1 -Parameter2

  • Parameter values are supplied through a <space> char.

  • Example of such parameter is Get-Process -Name svchost here -Name is a Parameter and 'svchost' is its value.

  • If you use a Get-Help and see the syntax section, you will see a list of parameters which you can supply to given CmdLet

image

  • If you directly supply parameter without using -ParameterName the first positional parameter will be considered as default

image

  • Single-Value Vs Multi-Value Parameter | Notice <string> vs <string[]>

image

  • Help shows Parameter data type.
  • <string> is a single string i.e. Single Value can be supplied.
  • <string[]> is an array of strings i.e. Multiple string values can be supplied
  • Example Test-Connection -ComputerName 127.0.0.1 10.0.0.1 here -ComputerName parameter is <string[]> type hence two IPs are supplied as input

image

Common Parameters

image

  • What and How many are these CommonParameters ?
 The common parameters are:
    -Verbose
    -Debug
    -WarningAction
    -WarningVariable
    -ErrorAction
    -ErrorVariable
    -OutVariable
    -OutBuffer
    
 The risk mitigation parameters are:
    -WhatIf
    -Confirm