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 Play-SpeechText { | |
| [CmdletBinding( | |
| DefaultParameterSetName = 'Default', | |
| ConfirmImpact = [System.Management.Automation.ConfirmIMpact]::Medium)] | |
| param( | |
| [Parameter(Mandatory)] | |
| [string] $ApiKey, |
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
| // 本物の PSCmdlet 派生クラス | |
| namespace CmdletTest | |
| { | |
| using System; | |
| using System.Management.Automation; | |
| [Cmdlet("Test", "PSCmdlet")] | |
| public class TestPSCmdletCommand : PSCmdlet, IDisposable | |
| { | |
| protected IDatabaseConnection Connection { get; set; } |
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
| <# | |
| .Synopsis | |
| 新規にDatetime型のオブジェクトを生成します。 | |
| .DESCRIPTION | |
| 新規にDatetime型のオブジェクトを生成します。 | |
| Get-Dateとは異なり現在時刻を基準とせず、未指定のパラメーターには初期値を割り当ててオブジェクトを生成します。 | |
| .OUTPUTS | |
| Format パラメーターまたは UFormat パラメーターを使用した場合、Get-Date は文字列を返します。それ以外の場合は、DateTime オブジェクトが返されます。 | |
| .EXAMPLE | |
| New-Date -Year 2016 -Month 3 -Day 7 |
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
| case (order) | |
| { | |
| case "Small Coffee": | |
| return 5.0; | |
| case "Small Coffee. please.": | |
| return 3.0; | |
| case "Hello, one small coffee please.": | |
| return 1.75; |
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
| # This query is valid. __InstanceCreationEvent class has TargetInstance property. | |
| $query = @' | |
| SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process' AND TargetInstance.Name = 'cmd.exe' | |
| '@ | |
| $evt = Register-CimIndicationEvent -Query $query -SourceIdentifier 'TestEvent' -Action { | |
| $EventArgs | Get-Member -Force | Out-Default | |
| $EventArgs | Format-List * | Out-Default | |
| $e = $EventArgs.NewEvent |
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-CommonParameter { | |
| [OutputType([Hashtable])] | |
| [CmdletBinding( | |
| SupportsShouldProcess)] | |
| [System.Diagnostics.CodeAnalysis.SuppressMessage('PSShouldProcess', '')] | |
| param( |
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
| HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Ssh | |
| Proxy | |
| @completion-port-threads | |
| @ip4-bind-port | |
| @ip6-bind-port | |
| @listeners | |
| @session-pipe-prefix | |
| @session-app-name | |
| @session-pipe-timeout | |
| @session-timeout |
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 Uninstall-OldModule { | |
| [CmdletBinding( | |
| SupportsShouldProcess, | |
| ConfirmImpact = 'High')] | |
| param( | |
| [string] $Name, | |
| [switch] $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
| $module = Get-Module -ListAvailable | |
| # $module = Get-InstalledModule | |
| $module | | |
| Select-Object -Property 'Name', 'Version' | | |
| Group-Object -Property 'Name' | | |
| ForEach-Object -PipelineVariable 'm' { | |
| $_.Group | | |
| Sort-Object -Property 'Version' -Descending | | |
| Select-Object -First 1 |
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 Show-Hoge { | |
| Write-Host 'Hoge' | |
| } | |
| $func = ${function:Show-Hoge} | |
| Invoke-Command -Session $session -ScriptBlock { | |
| New-Item -Path 'Function:\Show-Hoge' -Value $using:func > $null | |
| Show-Hoge | |
| } |