This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create a Resource Group | |
| $rgName = 'Test-RG' | |
| $location = 'westus' | |
| $null = New-AzResourceGroup -Name $rgName -Location $location | |
| # Create a Virtual Machine | |
| $vmName = 'Test-VM' | |
| $userName = 'sysadmin' | |
| $plainTextPassword = 'P@ssw0rd!' | |
| $securePassword = $plainTextPassword | ConvertTo-SecureString -AsPlainText -Force |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Test-Args | |
| { | |
| [cmdletbinding()] | |
| param | |
| ( | |
| [parameter(Mandatory)] | |
| [string] $var1, | |
| [parameter(Mandatory)] | |
| [string] $var2, | |
| [parameter(Mandatory = $false)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ScriptBlock = [scriptblock]::Create({ | |
| param ( $CommandName, | |
| $ParameterName, | |
| $WordToComplete, | |
| $CommandAst, | |
| $FakeBoundParameters ) | |
| $Shares = Get-SmbShare | Where-Object {$_.Name -like "$WordToComplete*"} | |
| $Shares | ForEach-Object { | |
| New-Object -Type System.Management.Automation.CompletionResult -ArgumentList $_.Name, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ScriptBlock = [scriptblock]::Create({ | |
| param ( $CommandName, | |
| $ParameterName, | |
| $WordToComplete, | |
| $CommandAst, | |
| $FakeBoundParameters ) | |
| $CountriesByContinent = @{ | |
| 'North America' = @('USA', 'Canada') | |
| Europe = @('UK', 'Germany') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Get-Country | |
| { | |
| [CmdLetBinding()] | |
| param | |
| ( | |
| [parameter(Mandatory = $false)] | |
| [ValidateSet('''North America''', 'Europe', 'Asia', 'Oceania')] | |
| [string] $Continent, | |
| [parameter(Mandatory = $true)] | |
| [string] $CountryName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Get-Country | |
| { | |
| [CmdLetBinding()] | |
| param | |
| ( | |
| [parameter(Mandatory = $false)] | |
| [ValidateSet('''North America''', 'Europe', 'Asia', 'Oceania')] | |
| [string] $Continent, | |
| [parameter(Mandatory = $true)] | |
| [ArgumentCompleter( { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Get-Country | |
| { | |
| [CmdLetBinding()] | |
| param | |
| ( | |
| [parameter(Mandatory = $true)] | |
| [ArgumentCompleter( { | |
| param ( $CommandName, | |
| $ParameterName, | |
| $WordToComplete, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SupportedCountries : System.Management.Automation.IValidateSetValuesGenerator | |
| { | |
| [string[]] GetValidValues() | |
| { | |
| ## Write your code here | |
| $Countries = @('India', 'USA', 'UK', 'Canada', 'Australia') | |
| return $Countries | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Get-Country | |
| { | |
| [CmdLetBinding()] | |
| param | |
| ( | |
| [parameter(Mandatory = $true)] | |
| [ValidateSet('India', 'USA', 'UK', 'Canada', 'Australia')] | |
| [string] $CountryName | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Get-LastRebootTime | |
| { | |
| [CmdLetBinding()] | |
| param | |
| ( | |
| [parameter(Mandatory)] | |
| [string] $ResourceGroupName, | |
| [string] $VMName | |
| ) |