官术网_书友最值得收藏!

  • PowerShell for Office 365
  • Martin Machado Prashant G Bhoyar
  • 244字
  • 2021-07-02 18:50:37

Parameters

Parameters are the input values that we pass to a cmdlet. For example, if we have to get the time zone, we can use the following cmdlet:

Get-TimeZone

This cmdlet gets the current time zone or a list of available time zones.

These are the parameters:

  • [-Id]: Specifies, as a string array, the ID or IDs of the time zones that this cmdlet gets
  • [-ListAvailable]: Indicates that this cmdlet gets all available time zones
  • [-Name]: Specifies, as a string array, the name or names of the time zones that this cmdlet gets

We can use this command with or without these parameters:

Get-TimeZone

The following screenshot shows the output for the preceding command:

We can use this command with the Name parameter:

Get-TimeZone -Name "*pac*"

The following screenshot shows the output for the preceding command:

We can use this command with the ListAvailable parameter:

Get-TimeZone -ListAvailable

The following screenshot shows the output for the preceding command:

In PowerShell, variables are always prefixed by the character $ and can include any alphanumeric character or underscore in their names. We can store the output from a cmdlet in a variable and use it later on in other cmdlets or for other purposes in the script, such as writing to the host, using it for comparison, or creating another variable, such as this, for example:

$timeZone = Get-TimeZone
Write-Host "The current time zone is " $timeZone

The following screenshot shows the output for the preceding command:

主站蜘蛛池模板: 光山县| 淮北市| 福泉市| 莎车县| 盐津县| 突泉县| 工布江达县| 河津市| 大英县| 桐城市| 惠东县| 朝阳区| 浙江省| 乡城县| 靖安县| 嵩明县| 阿城市| 青龙| 辉县市| 浏阳市| 商洛市| 虹口区| 新乡县| 长垣县| 桓台县| 英德市| 临潭县| 呼伦贝尔市| 铜陵市| 左权县| 仙居县| 德惠市| 泗阳县| 诸暨市| 安福县| 西贡区| 芒康县| 凌云县| 通榆县| 平利县| 红原县|